com.metamatrix.common.util
Class MultipleRequestConfirmation

java.lang.Object
  extended by com.metamatrix.common.util.MultipleRequestConfirmation
All Implemented Interfaces:
java.io.Serializable

public class MultipleRequestConfirmation
extends java.lang.Object
implements java.io.Serializable

This class is used to return to a client the results of a complex management request. The meaning of "result object" and "failured objects" is dependent upon the context of the method from which this instance is returned.

This class uses a Map to hold those objects that were not successfully operated upon and a corresponding exception; therefore, only objects which have a unique hash code for different (but unequivalent) instances should be inserted as failed objects.

See Also:
Serialized Form

Constructor Summary
MultipleRequestConfirmation()
          Construct an empty confirmation instance.
 
Method Summary
 void addFailure(java.lang.Object obj, java.lang.Throwable e)
          Add the object that was not successfully operated upon.
 java.util.Map getFailures()
          Get the object that were not successfully operated upon, and an exception for each that may describe why the operation failed.
 int getFailuresCount()
          Get the number of objects that were not successfully operated upon.
 java.lang.Object getResult()
          Get the result of the operation.
 boolean hasFailures()
          Determine whether there are any objects that were not successfully operated upon.
 boolean hasResult()
           
 void setResult(java.lang.Object result)
          Set the result of the method request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipleRequestConfirmation

public MultipleRequestConfirmation()
Construct an empty confirmation instance.

Method Detail

setResult

public void setResult(java.lang.Object result)
Set the result of the method request.

Parameters:
obj - the result object

getResult

public java.lang.Object getResult()
Get the result of the operation.

Returns:
the object that contains or is the results for the operation; while this class can contain a null value for the result, the method from which this object is returned should document whether null results are allowed or expected.

addFailure

public void addFailure(java.lang.Object obj,
                       java.lang.Throwable e)
Add the object that was not successfully operated upon.

Parameters:
obj - the object with which the operation failed.
e - an exception that describes the failure of this object; may be null

getFailures

public java.util.Map getFailures()
Get the object that were not successfully operated upon, and an exception for each that may describe why the operation failed.

Returns:
the map keyed upon the objects with which the operation failed; the value for each object key is the exception that was thrown during the operation upon that object, or null if no exception was thrown during the operation but failure still occurred.

getFailuresCount

public int getFailuresCount()
Get the number of objects that were not successfully operated upon.

Returns:
the number of objects with which the operation failed.

hasResult

public boolean hasResult()

hasFailures

public boolean hasFailures()
Determine whether there are any objects that were not successfully operated upon.

Returns:
true if at least one operation upon an object was added as failed, or false otherwise.


Copyright © 2009. All Rights Reserved.