Cytoscape 2.8.0 API

cytoscape.command
Class CyCommandResult

java.lang.Object
  extended by cytoscape.command.CyCommandResult

public class CyCommandResult
extends Object

CyCommandResult returns the results from the execution of a command. Generally, a command would create a CyCommandResult object at the beginning of the execute() method. A command should never return a null to indicate failure, and should throw CyCommandException instead. This will avoid a lot of redundant checking for null returns.


Constructor Summary
CyCommandResult()
          Create a new empty CyCommandResult.
CyCommandResult(String message, Map<String,Object> results)
          Create a new CyCommandResult with an initial message and execution results.
 
Method Summary
 void addError(String message)
          Add an error message to the list of errors for this execution.
 void addMessage(String message)
          Add a message to the list of messages that results from this execution.
 void addResult(Object value)
          Add the result for this execution.
 void addResult(String key, Object value)
          Add a result to the result set for this execution.
 List<String> getErrors()
          Return all of the erros from an execution.
 List<String> getMessages()
          Return all of the messages from an execution.
 Object getResult()
          Return the result from an execution.
 Object getResult(String key)
          Return a particular result from an execution.
 Map<String,Object> getResults()
          Return all of the results from an execution as a map indexed by the result name.
 String getStringResult()
          Return the result from an execution, as a string.
 String getStringResult(String key)
          Return a particular result from an execution as a String.
 void setResults(Map<String,Object> results)
          Set all of the results for this execution.
 boolean successful()
          Return true if the execution was successful, false if it failed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CyCommandResult

public CyCommandResult()
Create a new empty CyCommandResult.


CyCommandResult

public CyCommandResult(String message,
                       Map<String,Object> results)
Create a new CyCommandResult with an initial message and execution results.

Parameters:
message - a message to include in the result. Note that more messages may be added later.
results - a map of the results from the execution.
Method Detail

addMessage

public void addMessage(String message)
Add a message to the list of messages that results from this execution. This is an easy way to provide a record of the operation of a command that might be displayed to the user by a client plugin.

Parameters:
message - the message to add

addError

public void addError(String message)
Add an error message to the list of errors for this execution. As a byproduct, this will set the error flag.

Parameters:
message - the error message to add

addResult

public void addResult(Object value)
Add the result for this execution. Note that this version of the addResult method assumes there is only one result value. Subsequence calls to addResult(Object value) will overwrite this value.

Parameters:
value - the result value itself

addResult

public void addResult(String key,
                      Object value)
Add a result to the result set for this execution.

Parameters:
key - the result whose value we're setting
value - the result value itself

successful

public boolean successful()
Return true if the execution was successful, false if it failed.

Returns:
true if successful, false otherwise

setResults

public void setResults(Map<String,Object> results)
Set all of the results for this execution.

Parameters:
results - the map of key, value pairs

getStringResult

public String getStringResult(String key)
Return a particular result from an execution as a String. Internally, results are stored as name, value pairs where the value is an Object that can be converted to a Stirng. This method provides a short-hand to just calling toString on the Object-return signature.

Parameters:
key - the result value we're interested in
Returns:
the string equivilent of that value

getStringResult

public String getStringResult()
Return the result from an execution, as a string.

Returns:
the execution result

getResult

public Object getResult(String key)
Return a particular result from an execution. Internally, results are stored as name, value pairs where the value is an Object that can be converted to a Stirng. This method returns the stored Object with no attempt to do any conversion.

Parameters:
key - the result value we're interested in
Returns:
the resulting value

getResult

public Object getResult()
Return the result from an execution.

Returns:
the execution result

getResults

public Map<String,Object> getResults()
Return all of the results from an execution as a map indexed by the result name.

Returns:
the map of key, value pairs

getMessages

public List<String> getMessages()
Return all of the messages from an execution.

Returns:
list of message strings

getErrors

public List<String> getErrors()
Return all of the erros from an execution.

Returns:
list of erros strings

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.