org.rhq.core.pluginapi.operation
Class OperationResult

java.lang.Object
  extended by org.rhq.core.pluginapi.operation.OperationResult

public class OperationResult
extends Object

An object that encapsulates the results of a single operation invocation. Since this class contains a Configuration object, it can be used to store complex results. However, if an operation needs to only return a single string result, use the convenience constructor OperationResult(String) or the method setSimpleResult(String) to pass in that simple string value without the need to use the more complex Configuration API.

See Also:
Configuration, OperationFacet

Field Summary
static String SIMPLE_OPERATION_RESULT_NAME
           
 
Constructor Summary
OperationResult()
          Constructor that builds an empty result.
OperationResult(String simpleResult)
          Convenience constructor that builds a result that contains a single, simple result string.
 
Method Summary
 Configuration getComplexResults()
          Returns the Configuration object that is used to contain all the complex data that resulted from an operation invocation.
 String getErrorMessage()
          Returns the plugin-specific error message for this operation, or null if the operation was successful.
 String getSimpleResult()
          Gets the simple string result that was stored in this object.
 void setErrorMessage(String errorMessage)
          Sets whether or not this operation was successful.
 void setSimpleResult(String simpleResult)
          Use this method if an operation returned a simple string result.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIMPLE_OPERATION_RESULT_NAME

public static final String SIMPLE_OPERATION_RESULT_NAME
See Also:
Constant Field Values
Constructor Detail

OperationResult

public OperationResult()
Constructor that builds an empty result. You can then use getComplexResults() to obtain the Configuration object in order to populate it with complex results returned by the operation. You are also free to store a simple result by using setSimpleResult(String). Typically, you will normally want to store either a simple result or a complex result, but not both (although technically you are not prohibited from using both).

See Also:
getComplexResults()

OperationResult

public OperationResult(String simpleResult)
Convenience constructor that builds a result that contains a single, simple result string. You can technically still use getComplexResults() to obtain the Configuration object in order to populate it with additional, complex results returned by the operation but, typically, callers that use this constructor only need to store a single result string in the results.

Parameters:
simpleResult - the single, simple result string to store in the results object
See Also:
getSimpleResult()
Method Detail

getSimpleResult

public String getSimpleResult()
Gets the simple string result that was stored in this object.

Returns:
the simple string result
See Also:
OperationResult(String), setSimpleResult(String)

setSimpleResult

public void setSimpleResult(String simpleResult)
Use this method if an operation returned a simple string result. This is a convenience method that places the given result string in the getComplexResults() object under the name SIMPLE_OPERATION_RESULT_NAME.

Parameters:
simpleResult - a simple string result

getErrorMessage

public String getErrorMessage()
Returns the plugin-specific error message for this operation, or null if the operation was successful.

Returns:
The stored message or null.

setErrorMessage

public void setErrorMessage(String errorMessage)
Sets whether or not this operation was successful. If this method is never called, the operation is assumed a success. If your operation has logically failed but you don't want to throw an exception because the results object contains meaningful data at the time of failure, you can pass an error message and the operation will be marked as FAILURE

Parameters:
errorMessage - a plugin specific error that indicates why this operation has failed

getComplexResults

public Configuration getComplexResults()
Returns the Configuration object that is used to contain all the complex data that resulted from an operation invocation. The returned object is not a copy, so you can use this object to populate the complex results.

Note that this is the same object that will be populated by the convenience method setSimpleResult(String).

Returns:
the object that will contain the complex results

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.