com.esri.adf.web.data.results
Class ResultNode

java.lang.Object
  extended by com.esri.adf.web.data.results.ResultNode
All Implemented Interfaces:
Serializable

public class ResultNode
extends Object
implements Serializable

The ResultNode object wraps the actual result objects that are added to the WebResults. The ResultNode is the one which actually invokes the appropriate methods on the actual results to retrieve the 4 pieces of information expected of a result (display text, details, actions and on-remove).

The ResultNode maintains the metadata for the result in a ResultDescriptor. This metadata includes the methods for the display text, details, actions and on-remove.

Since the ResultNodes are maintained as a tree, each node maintains references to its parent node as well as children nodes.

See Also:
Serialized Form

Constructor Summary
ResultNode(Object result, ResultDescriptor resultDesc)
           Creates a new ResultNode object.
ResultNode(Object result, ResultDescriptor resultDesc, List<? extends ResultNode> children)
           Creates a new ResultNode object.
ResultNode(Object result, String displayNameMethodName, String detailsMethodName, Map<String,String> actionMethodNames, String onRemoveMethodName)
           Creates a new ResultNode object.
ResultNode(String stringResult)
           Creates a new ResultNode object for this String result.
 
Method Summary
 void addChild(int index, ResultNode child)
           Adds this ResultNode as a child of this node at the given index.
 void addChild(ResultNode child)
           Adds this ResultNode as a child of this node.
 void addChildren(List<? extends ResultNode> children)
           Adds the List of ResultNodes as children of this node.
 List<String> getActionNames()
           Returns a List of action display names for this result.
 List<ResultNode> getChildren()
           Returns the List of children nodes.
 Map<String,Object> getDetails()
           Returns the details for this result.
 String getDisplayName()
           Returns the display name for this result.
 ResultNode getParent()
           Returns the parent ResultNode for this node.
 Object getResult()
           Returns the actual result object wrapped by this ResultNode object.
 ResultDescriptor getTaskResultDescriptor()
           Returns the ResultDescriptor associated with this result.
 boolean isHasDetails()
           Returns true if a details method was designated for this result.
 Object onRemove()
           Invokes the designated on-remove method on this result as well as its children.
 Object processAction(String actionName)
           Invokes the action corresponding to the given actionName.
 String recursiveToString(int indent)
           A convenience method to recursively iterate through and return the contents of the children nodes as a String.
 void setTaskResultDescriptor(ResultDescriptor resultDesc)
           Sets the ResultDescriptor to be associated with this result.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultNode

public ResultNode(String stringResult)

Creates a new ResultNode object for this String result.

Same as:

 this(stringResult, ResultDescriptor.STRING_RESULT_DESCRIPTOR, null);
 

Parameters:
stringResult -

ResultNode

public ResultNode(Object result,
                  String displayNameMethodName,
                  String detailsMethodName,
                  Map<String,String> actionMethodNames,
                  String onRemoveMethodName)

Creates a new ResultNode object.

The ResultDescriptor representing the metadata for this result is created by using the various method names provided as arguments to this constructor.

Parameters:
result - the result to be wrapped by this node
displayNameMethodName - the name of the method which returns the display text for the result
detailsMethodName - the name of the method which returns the result details as a java.util.Map of name-value pairs
actionMethodNames - an array of names of methods for performing actions on the result
onRemoveMethodName - the name of the method to be called when the result is removed

ResultNode

public ResultNode(Object result,
                  ResultDescriptor resultDesc)

Creates a new ResultNode object.

The newly created node wraps the given result. The metadata for the result is included in the resultDesc.

Same as:

 this(result, resultDesc, null);
 

Parameters:
result - the result to be wrapped by this node
resultDesc - the ResultDescriptor representing the metadata for this result

ResultNode

public ResultNode(Object result,
                  ResultDescriptor resultDesc,
                  List<? extends ResultNode> children)

Creates a new ResultNode object.

The newly created node wraps the given result. The metadata for the result is included in the resultDesc. Optionally, one can also provide a List of children nodes, if any.

Parameters:
result - the result to be wrapped by this node
resultDesc - the ResultDescriptor representing the metadata for this result
children - the List of children ResultNodes, if any
Method Detail

getDisplayName

public String getDisplayName()

Returns the display name for this result.

The display name is retrieved by invoking the desginated method name on the result.

Returns:
the display name for this result

getDetails

public Map<String,Object> getDetails()

Returns the details for this result. The details are represented as a java.util.Map of name-value pairs.

The details are retrieved by invoking the desginated method name on the result.

Returns:
a java.util.Map of name-value pairs

isHasDetails

public boolean isHasDetails()

Returns true if a details method was designated for this result.

Returns:
true if a details method was designated for this result

getActionNames

public List<String> getActionNames()

Returns a List of action display names for this result.

Returns:
a List of action display names for this result

processAction

public Object processAction(String actionName)

Invokes the action corresponding to the given actionName.

Parameters:
actionName - the name corresponding to which the action is to be invoked
Returns:
the object returned by the action method invoked

onRemove

public Object onRemove()

Invokes the designated on-remove method on this result as well as its children.

Returns:
the object returned by the on-remove method invoked

addChildren

public void addChildren(List<? extends ResultNode> children)

Adds the List of ResultNodes as children of this node.

Parameters:
children - a List of ResultNodes to be added as children of this node

addChild

public void addChild(ResultNode child)

Adds this ResultNode as a child of this node.

Parameters:
child - the ResultNode to be added as a child of this node

addChild

public void addChild(int index,
                     ResultNode child)

Adds this ResultNode as a child of this node at the given index.

If the index is invalid, then the child is added as the last child of this node.

Parameters:
index - the index at which the child is to be added
child - the ResultNode to be added as a child of this node

getChildren

public List<ResultNode> getChildren()

Returns the List of children nodes.

Returns:
the List of children nodes

getResult

public Object getResult()

Returns the actual result object wrapped by this ResultNode object.

Returns:
the actual result Object wrapped by this ResultNode object

getTaskResultDescriptor

public ResultDescriptor getTaskResultDescriptor()

Returns the ResultDescriptor associated with this result.

Returns:
the ResultDescriptor associated with this result

setTaskResultDescriptor

public void setTaskResultDescriptor(ResultDescriptor resultDesc)

Sets the ResultDescriptor to be associated with this result.

Parameters:
resultDesc - the ResultDescriptor to be associated with this result

getParent

public ResultNode getParent()

Returns the parent ResultNode for this node.

Returns:
the parent ResultNode for this node

recursiveToString

public String recursiveToString(int indent)

A convenience method to recursively iterate through and return the contents of the children nodes as a String.

Parameters:
indent - number of whitespaces
Returns:
the contents of the children nodes

toString

public String toString()
Overrides:
toString in class Object