org.xins.server
Class FunctionResult

java.lang.Object
  extended byorg.xins.server.FunctionResult
Direct Known Subclasses:
org.xins.server.InvalidMessageResult

public class FunctionResult
extends Object

Result from a function call. Defines an error code, parameters and output data section. All are optional.

Since:
XINS 1.0.0
Version:
$Revision: 1.43 $ $Date: 2007/09/18 08:45:05 $
Author:
Anthony Goubard, Ernst de Haan
See Also:
FunctionRequest

Constructor Summary
FunctionResult()
          Creates a new successful FunctionResult instance with no parameters.
FunctionResult(String code)
          Creates a new FunctionResult instance with no parameters.
FunctionResult(String code, BasicPropertyReader parameters)
          Creates a new FunctionResult instance with a specified set of parameters.
 
Method Summary
protected  void add(Element element)
          Adds a new Element to the data element.
 InvalidResponseResult checkOutputParameters()
          Checks that the output parameters are set as specified.
 Element getDataElement()
          Gets the data element from this result.
 String getErrorCode()
          Returns the result code.
 String getParameter(String name)
          Gets the value of the specified parameter.
 PropertyReader getParameters()
          Gets all parameters.
protected  void param(String name, String value)
          Adds an output parameter to the result.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionResult

public FunctionResult()
Creates a new successful FunctionResult instance with no parameters.


FunctionResult

public FunctionResult(String code)
Creates a new FunctionResult instance with no parameters.

Parameters:
code - the error code, can be null if the result is successful.

FunctionResult

public FunctionResult(String code,
                      BasicPropertyReader parameters)
Creates a new FunctionResult instance with a specified set of parameters.

Parameters:
code - the error code, can be null if the result is successful.
parameters - the parameters for the result, can be null if there are no parameters.
Method Detail

getErrorCode

public String getErrorCode()
Returns the result code.

Returns:
the result code or null if no code was returned.

checkOutputParameters

public InvalidResponseResult checkOutputParameters()
Checks that the output parameters are set as specified. If a parameter is missing or if the value for it is invalid, then an InvalidResponseResult is returned. Otherwise the parameters are considered valid, and null is returned.

The implementation of this method in class FunctionResult always returns null.

Returns:
an InvalidResponseResult instance if at least one output parameter is missing or invalid, or null otherwise.
Since:
XINS 2.0.

param

protected void param(String name,
                     String value)
              throws IllegalArgumentException
Adds an output parameter to the result. The name and the value must both be specified.

Parameters:
name - the name of the output parameter, not null and not an empty string.
value - the value of the output parameter, not null and not an empty string.
Throws:
IllegalArgumentException - if name == null || "".equals(name) || value == null || "".equals(value).

getParameters

public PropertyReader getParameters()
Gets all parameters.

Returns:
a PropertyReader containing all parameters, never null; the keys will be the names of the parameters (String objects, cannot be null), the values will be the parameter values (String objects as well, cannot be null).

getParameter

public String getParameter(String name)
                    throws IllegalArgumentException
Gets the value of the specified parameter.

Parameters:
name - the parameter element name, cannot be null.
Returns:
string containing the value of the parameter element, or null if the value is not set.
Throws:
IllegalArgumentException - if name == null.

add

protected void add(Element element)
            throws IllegalArgumentException
Adds a new Element to the data element.

Parameters:
element - the new element to add to the result, cannot be null.
Throws:
IllegalArgumentException - if element == null.
Since:
XINS 1.1.0

getDataElement

public Element getDataElement()
Gets the data element from this result.

Returns:
the data element of the result, can be null.

toString

public String toString()


See http://www.xins.org/.