|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An extension of the org.xml.sax.ContentHandler that allows to retrieve a parsed result.
Method Summary | |
java.lang.String |
getContext()
Returns the context to use in error messages. |
java.lang.String |
getContext(java.lang.String pName)
Returns the context to use in error messages, extended by the given element or attribute name. |
Observer |
getObserver()
Returns a possible observer. |
java.util.Collection |
getResultCollection()
Returns a collection where to add successfully parsed elements, Strings or other JMNode instances. |
java.lang.Object |
getResultNode()
This method may be called after a startDocument() ,
..., endDocument() sequence. |
void |
setContext(java.lang.String pContext)
Sets a context to use in error messages. |
void |
setObserver(Observer pObserver)
Sets a possible observer. |
void |
setResultCollection(java.util.Collection pCollection)
Sets a collection where to add successfully parsed elements, Strings or other JMNode instances. |
Methods inherited from interface org.xml.sax.ContentHandler |
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping |
Method Detail |
public void setObserver(Observer pObserver)
Sets a possible observer. If the observer is non-null, then it will be notified for any element, String or JMNode that has been read successfully. The parsed element can be accessed as follows:
public void notify(Object o) { ObservedHandler handler = (ObservedHandler) o; Object o = handler.getResultNode(); if (o instanceof JMAnyElement) { JMAnyElement element = (JMAnyElement) o; ... // Do something here } else { ... // Other possibilities: String, JMPI, JMEntity } }
pObserver
- The observer being notified or null to disable
notification.getObserver()
public Observer getObserver()
Returns a possible observer. If the observer is non-null, then it will be notified for any element, String or JMNode that has been read successfully.
setObserver(de.ispsoft.jaxme.Observer)
public java.lang.Object getResultNode()
This method may be called after a startDocument()
,
..., endDocument()
sequence. It returns the result
object, which may be either of
public void setResultCollection(java.util.Collection pCollection)
Sets a collection where to add successfully parsed elements, Strings or other JMNode instances. The collection can be processed if the parsing is done completely.
This collection is relevant only, if you expect to parse multiple documents in a sequence. For example, you might read a SOAP reply where the actual result consists of a single root node and a lot of childs.
If you expect a single result element only, you might
prefer using the getResultNode()
method.
The collection can be processed as follows:
for (java.util.Iterator iter = handler.getResultCollection(); iter.hasNext(); ) { Object o = iter.next(); if (o instanceof JMAnyElement) { JMAnyElement element = (JMAnyElement) o; ... // Do something here } else { ... // Other possibilities: String, JMPI or JMEntity } }
getResultCollection()
public java.util.Collection getResultCollection()
Returns a collection where to add successfully parsed elements, Strings or other JMNode instances. The collection can be processed if the parsing is done completely.
This collection is relevant only, if you expect to parse multiple documents in a sequence. For example, you might read a SOAP reply where the actual result consists of a single root node and a lot of childs.
If you expect a single result element only, you might
prefer using the getResultNode()
method.
setResultCollection(java.util.Collection)
public void setContext(java.lang.String pContext)
Sets a context to use in error messages.
pContext
- or null for top level elements.public java.lang.String getContext()
Returns the context to use in error messages.
public java.lang.String getContext(java.lang.String pName)
Returns the context to use in error messages, extended by the given element or attribute name.
Example:
String context = "/Address/Name"; setContext(context); getContext("FirstName"); // Returns "/Address/Name/FirstName"
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |