org.ws4d.java.io.xml
Interface ElementHandler

All Known Implementing Classes:
CustomizeMDataHandler

public interface ElementHandler

Implementations of this interface are responsible for parsing a specific XML element and re-creating its content as a Java object graph. Warning: Each element handler instance may and will be called simultaneously by different threads! Therefore, element handlers must not keep any state about the current parse process within local variables or similar or they always must associate it with the current thread.


Method Summary
 java.lang.Object handleElement(QName elementName, ElementParser parser)
          Processes the content (both child elements and attributes) of the element with the specified elementName and returns its representation as a Java object.
 void serializeElement(XmlSerializer serializer, QName qname, java.lang.Object value)
          Method to serialize the UnknownElement
 

Method Detail

handleElement

java.lang.Object handleElement(QName elementName,
                               ElementParser parser)
                               throws org.xmlpull.v1.XmlPullParserException,
                                      java.io.IOException
Processes the content (both child elements and attributes) of the element with the specified elementName and returns its representation as a Java object. The element content can be obtained successively from the provided parser. It is guaranteed that this parser will be always namespace-aware. Note that the parser's current position is already at the start position of the current element, that is, the following assumptions hold immediately after entering this method:

parser.getEventType() == XmlPullParser.START_TAG

parser.getName() == elementName.getLocalPart()

parser.getNamespace() == elementName.getNamespace()

Attention! The provided parser supports neither custom properties, nor any features! Also, it doesn't accept any entity replacement text.

Parameters:
elementName - the qualified name of the element to process
parser - the parser to obtain element data from
Returns:
a Java object corresponding to the content of the given XML element
Throws:
org.xmlpull.v1.XmlPullParserException - if an error during processing of the element content occurs
java.io.IOException - if an error during reading the element source occurs

serializeElement

void serializeElement(XmlSerializer serializer,
                      QName qname,
                      java.lang.Object value)
                      throws java.lang.IllegalArgumentException,
                             WS4DIllegalStateException,
                             java.io.IOException
Method to serialize the UnknownElement

Parameters:
serializer - ,the Serializer which is used to serialize the UnknownElement
qname - ,the qualified name of the UnknownElement to process
value - ,the value of the UnknownElement
Throws:
java.lang.IllegalArgumentException
WS4DIllegalStateException
java.io.IOException