|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.AbstractXmlObject
com.waveset.object.WavesetResult
An object used to encapsulate a complex set of results. Originally developed to capture status from background workflow tasks, now also being used by provisioning operations that may affect more than one resource.
A result is a list of items, defined by the ResultItem
class.
Each item has a value which may be any XmlObject. Items may
have an optional name and an optional type.
Some item values are self describing and need no type qualifier. Others may use the type to indicate the semantics of the value. For example the value of an item containing a message may be a simple String object. To indicate that this is a displayable message the item type ResultItem.TYPE_MESSAGE is used.
NOTE: This has evolved several times. We originally supported the notion of a "status" on each item which was an indication of error severity: ok, warning, and error. This was confusing since not all items have a severity level. The new ErrorMessage object is a better way to express this. // *
// * I thought about eliminating the ResultItem object and instead just // * maintaining a list of things, but this would require a different // * kind of wrapper object for simple items like messages to distinguish // * them from non-displayable data values. So we either get rid of // * ResultItem and introduce ResultMessage and ResultData, or keep // * ResultItem and live with a sometimes unnecessary level of indirection. // * Having ResultItem also allows us to give items names, which comes // * in handy with workflow, where we may wish to modify previously // * added results. // *
ResultItem
Field Summary | |
static java.lang.String |
code_id
|
static java.lang.String |
ELEMENT
The name of our XML element. |
static java.lang.String |
ITEM_TYPE
Value for the ResultItem type of a nested result object. |
Fields inherited from class com.waveset.util.AbstractXmlObject |
_trace |
Constructor Summary | |
WavesetResult()
Construct an empty result |
|
WavesetResult(org.w3c.dom.Element e)
Construct a result object from its DOM representation. |
|
WavesetResult(java.lang.String xml)
Create a result object by parsing its XML representation. |
Method Summary | |
ResultItem |
add(java.lang.Object object)
Add an object to the result. |
void |
addError(ErrorMessage msg)
|
void |
addError(Message msg)
Deprecated. Use addError(ErrorMessage) instead. |
void |
addError(ResultError err)
Add a ResultError object. |
void |
addException(java.lang.Throwable t)
Add an exception to the result. |
ResultItem |
addMessage(Message msg)
|
ResultItem |
addMessage(java.lang.String msg)
Add an pre-formatted ordinary message to the result. |
ResultItem |
addNamedResult(java.lang.String name,
java.lang.Object value)
Add a named data object to the result. |
ResultItem |
addNamedResult(java.lang.String name,
java.lang.String type,
java.lang.Object value)
Add a named object to the result. |
void |
addResult(ResultItem item)
Add a new item to the result object. |
ResultItem |
addResult(java.lang.String type,
java.lang.Object value)
Add a typed string result. |
void |
addWarning(Message msg)
Add an warning message to the result. |
void |
assimilate(WavesetResult res)
Appends the items in one result with this one. |
void |
assimilateMessages(WavesetResult src)
Append the messages or errors from another result. |
java.lang.String |
getElementName()
Return the name of our XML element, required by XmlObject. |
Message |
getErrorMessage()
Convenience method to return the first error message in the result. |
java.util.List |
getErrorMessages()
Convenience method to return a list of all error messages found in this result. |
java.util.List |
getErrorMessages(int maxMessages)
Convenience method to return up to the specified number of error messages from this result. |
java.util.List |
getErrors()
Convenience method to extract a flat list of String objects for each error item in the result, formatted according to the current locale. |
void |
getErrors(java.util.List errors)
Convenience method to extract a flat list of String objects for each error item in the result, formatted according to the current locale. |
void |
getErrors(java.util.List errors,
java.util.Locale locale)
Convenience method to extract a flat list of String objects for each error item in the result, formatted according to the given locale. |
java.util.List |
getErrors(java.util.Locale locale)
Convenience method to extract a flat list of String objects for each error item in the result, formatted according to the given locale. |
java.util.List |
getMessages()
Convenience method to extract a flat list of String objects for each non-error message in the result, formatted according to the current locale. |
void |
getMessages(java.util.List messages)
Convenience method to extract a flat list of String objects for each non-error message in the result, formatted according to the current locale. |
void |
getMessages(java.util.List messages,
java.util.Locale locale)
Convenience method to extract a flat list of String objects for each non-error message in the result, formatted according to the given locale. |
java.util.List |
getMessages(java.util.Locale locale)
Convenience method to extract a flat list of String objects for each non-error message in the result, formatted according to the given locale. |
java.lang.String |
getName()
Get the result name. |
java.lang.Object |
getNamedResultValue(java.lang.String name)
Convenience method to return the value of the first item that has a given name. |
WavesetResult |
getNestedResult(java.lang.String name)
Recursively search for a nested WavesetResult with the given name. |
ResourceResult |
getResourceResult(java.lang.String name)
Return a specific resource result. |
java.lang.Object |
getResult(java.lang.String type)
Convenience method to return the value of the first item that has a given type. |
ResultItem |
getResultByClass(java.lang.Class c)
Search for a result value by class. |
ResultItem |
getResultByName(java.lang.String name)
Return the first ResultItem with the given name. |
ResultItem |
getResultByType(java.lang.String type)
Return the first ResultItem with the given type. |
ResultItem |
getResultItem(java.lang.String type)
Return the first ResultItem with the given type. |
java.util.List |
getResultItemList(java.lang.String type)
Return a list of ResultItems with the given type. |
java.util.ArrayList |
getResults()
Return the list of results. |
java.util.List |
getResultsByClass(java.lang.Class c)
Return the list of ResultItems with the given class. |
ResultTable |
getResultTable()
Return the first ResultTable in the result item list. |
Message |
getTitle()
Get the optional Message object containing the result title. |
boolean |
hasError()
Originally we tried to maintain the _status field as an indication of whether there were any error in this result. |
boolean |
hasWarning()
Originally we tried to maintain the _status field as an indication of whether there were any error in this result. |
boolean |
isEmpty()
|
boolean |
isError()
The first version of the class defined this method which checked a field we tried to keep up to date. |
void |
parseXml(org.w3c.dom.Element e)
Parse the DOM representation of a result, and set the corresponding fields. |
void |
removeResult(ResultItem item)
Remove a result item. |
void |
removeResultByName(java.lang.String name)
Remove a result item with the given name. |
void |
removeResultByType(java.lang.String type)
Remove a result item with the given type. |
void |
setName(java.lang.String name)
Set the result name. |
ResultItem |
setNamedResult(java.lang.String name,
java.lang.String type,
java.lang.Object value)
Add or update a result item. |
ResultItem |
setResult(java.lang.String type,
java.lang.Object value)
Assing a result by type, overwriting any current result with that type. |
void |
setTitle(Message msg)
Set the title message. |
void |
toXml(java.lang.StringBuffer b,
int indent)
Serialize the result to an XML buffer. |
Methods inherited from class com.waveset.util.AbstractXmlObject |
addXmlHeader, cloneObject, dump, dumpFile, getReference, println, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml, toXml, toXml |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
public static final java.lang.String ELEMENT
public static final java.lang.String ITEM_TYPE
Constructor Detail |
public WavesetResult()
public WavesetResult(java.lang.String xml) throws WavesetException
public WavesetResult(org.w3c.dom.Element e) throws WavesetException
Method Detail |
public java.lang.String getElementName()
getElementName
in interface XmlObject
getElementName
in class AbstractXmlObject
public java.lang.String getName()
public void setName(java.lang.String name)
public Message getTitle()
public void setTitle(Message msg)
public boolean isEmpty()
public java.util.ArrayList getResults()
ResultItem
objects.
public ResourceResult getResourceResult(java.lang.String name)
public ResultTable getResultTable()
public ResultItem add(java.lang.Object object)
public void assimilate(WavesetResult res)
This may be used in places where a "master" result is being maintained and sub-operations produce result objects of their own that need to be assimilated into the master result.
public void assimilateMessages(WavesetResult src)
public ResultItem addMessage(java.lang.String msg)
You should be using Message objects, but this is supported to ease the transition to message catalogs, or for emergency "can't happen" messages.
public ResultItem addNamedResult(java.lang.String name, java.lang.String type, java.lang.Object value)
public ResultItem addNamedResult(java.lang.String name, java.lang.Object value)
public ResultItem setNamedResult(java.lang.String name, java.lang.String type, java.lang.Object value)
You would call this if for result items that can be changed after having been added. If the value is null, the existing item will be removed.
public void removeResult(ResultItem item)
public void removeResultByName(java.lang.String name)
public void removeResultByType(java.lang.String type)
public ResultItem getResultByName(java.lang.String name)
public ResultItem getResultByType(java.lang.String type)
public ResultItem getResultByClass(java.lang.Class c)
public java.util.List getResultsByClass(java.lang.Class c)
public ResultItem getResultItem(java.lang.String type)
This should only be used if you know from context that there will only be one item of this type in the result. It should not be used for displaying messages, since there can be more than one message in the result. !! Would like to change the behavior to search by name only
public java.util.List getResultItemList(java.lang.String type)
This should only be used if you know from context that there will only be one item of this type in the result. It should not be used for displaying messages, since there can be more than one message in the result. !! Would like to change the behavior to search by name only
public java.lang.Object getResult(java.lang.String type)
This should only be used if you know from context that there will only be one item of this type in the result. It should not be used for displaying messages, since there can be more than one message in the result.
public java.lang.Object getNamedResultValue(java.lang.String name)
public WavesetResult getNestedResult(java.lang.String name)
public void getErrors(java.util.List errors, java.util.Locale locale)
public void getErrors(java.util.List errors)
public java.util.List getErrors(java.util.Locale locale)
public java.util.List getErrors()
public void getMessages(java.util.List messages, java.util.Locale locale)
public void getMessages(java.util.List messages)
public java.util.List getMessages(java.util.Locale locale)
public java.util.List getMessages()
public boolean hasError()
public boolean hasWarning()
public java.util.List getErrorMessages()
error messages
found in this result.
public java.util.List getErrorMessages(int maxMessages)
error messages
from this result.
public Message getErrorMessage()
Similar to hasError, but we look specifically for Message objects whereas hasError will stop on the first item with an error status.
public ResultItem setResult(java.lang.String type, java.lang.Object value)
public ResultItem addMessage(Message msg)
public boolean isError()
public void addResult(ResultItem item)
The global status will be updated if the item status is more severe than the current global status.
public ResultItem addResult(java.lang.String type, java.lang.Object value)
You would call this if you wanted your own item type, beyond the build-in types for messages and errors.
public void addException(java.lang.Throwable t)
This gets converted into a MESSAGE item, with a status of ERROR, and whose value is the text of the message.
Note that we store the com.waveset.msgcat.Message object if the exception has one since we may want to reformat the message for a different locale when it is eventually rendered. If the exception has no Message, we just store the message text.
We might have to store more here, possibly the class name of the exception, that would potentially allow us to recreate the exception object when the item is deserialized.
public void addWarning(Message msg)
public void addError(Message msg)
public void addError(ErrorMessage msg)
public void addError(ResultError err)
public void toXml(java.lang.StringBuffer b, int indent)
toXml
in interface XmlObject
toXml
in class AbstractXmlObject
public void parseXml(org.w3c.dom.Element e) throws WavesetException
WavesetException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |