|
||||||||||
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.ResultItem
Represents a single result which may be aggregated in a WavesetResult object.
There are two "classes" of items, one that represents a named value, and the other that represents a status/warning/error message. We might want to have actual subclasses for these, but that felt like overkill at the time.
The first thing you examine in a ResultItem is the "type" field which must be interpreted by the application in the context of the method that returned it. One common value for the type field is the string "message" which indicates that this is a message of some kind. I wanted to avoid a fixed set of static enumeration objects for these because we don't know what all of the types will be and they'll be extended all the time.
For "message" types, the object will always be a com.waveset.util.Message object.
Might want to have more than a success/failure boolean, possibly some constants?
Nested Class Summary | |
static class |
ResultItem.Status
Used for values of the _status field in both WavesetResult and ResultItem. |
Field Summary | |
static java.lang.String |
code_id
|
static java.lang.String |
DATA
Type used to indicate the item is a name/value pair. |
static java.lang.String |
ELEMENT
Our XML element name. |
static java.lang.String |
ERROR
Built-in item type for ResultError objects. |
static java.lang.String |
MESSAGE
Built-in item type for messages. |
static java.lang.String |
REPORT
Built-in item type for Report objects. |
static java.lang.String |
TABLE
Built-in item type for ResultTable objects. |
Fields inherited from class com.waveset.util.AbstractXmlObject |
_trace |
Constructor Summary | |
ResultItem()
|
|
ResultItem(org.w3c.dom.Element e)
|
Method Summary | |
java.lang.String |
getElementName()
Get the XML element name, required by XmlObject. |
Message |
getMessage()
Convenience method to access the Message object
for message items. |
Message |
getMessage(java.util.Locale locale)
|
java.lang.String |
getMessageText()
Convenience method to access the text of a message (or error) item. |
java.lang.String |
getMessageText(java.util.Locale locale)
Convenience method to access the text of a message (or error) item with a locale (if passed). |
java.lang.String |
getName()
|
ResultItem.Status |
getStatus()
Get the item status. |
java.lang.String |
getString()
Get the item value as a string. |
java.lang.String |
getType()
Get the item type. |
java.lang.Object |
getValue()
Get the item value. |
boolean |
isError()
Convenience method that tests to see if the item represents an error. |
boolean |
isMessage()
Convenience method that tests to see if this is a message item. |
boolean |
isReport()
Convenience method that tests to see if this is a report item. |
void |
parseXml(org.w3c.dom.Element e)
Build a result item by parsing its DOM representation and setting the corresponding fields. |
void |
setName(java.lang.String s)
|
void |
setStatus(ResultItem.Status status)
Set the item status. |
void |
setType(java.lang.String s)
Set the item type. |
void |
setValue(java.lang.Object o)
Set the item value. |
void |
toXml(java.lang.StringBuffer b,
int indent)
Serialize the item 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 MESSAGE
public static final java.lang.String ERROR
public static final java.lang.String REPORT
public static final java.lang.String TABLE
public static final java.lang.String DATA
Constructor Detail |
public ResultItem()
public ResultItem(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 s)
public java.lang.String getType()
public void setType(java.lang.String s)
WavesetResult
as
it builds it's item list.
public java.lang.Object getValue()
For items of type ResultItem.MESSAGE
, the value
is normally a java.lang.String or com.waveset.msgcat.Message object.
We try to use Message objects where possible, so the message
can be reformatted for different locals at the time it must be
presented, rather than the time it is captured in the result object.
public java.lang.String getString()
public void setValue(java.lang.Object o)
public boolean isError()
public boolean isMessage()
public boolean isReport()
public Message getMessage()
Message
object
for message items. The item may be an normal message or an error message.
If an error message, it may be any type of error container.
If the item was created with a String rather than a Message, we'll fake up a Message object containing the string, just so we can have a consistent return.
NOTE: This is called in several places that expect a non-null Message to be returned, so always return something. The original code did however return null if _value was null. Need to examine the callers!!
public Message getMessage(java.util.Locale locale)
public java.lang.String getMessageText()
public java.lang.String getMessageText(java.util.Locale locale)
public ResultItem.Status getStatus()
Status.OK
. Status will be
Status.ERROR
for error or exception messages.
public void setStatus(ResultItem.Status status)
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
Normally values are XmlObjects, but the agent still uses
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |