public abstract class AbstractXMLObjectUnmarshaller extends Object implements Unmarshaller
Text.getWholeText()
to retrieve the textual content. This is probably exceptable in almost all cases, if, however, you need to deal with
elements that contain multiple text node children you will need to override
unmarshallTextContent(XMLObject, Text)
and do "the right thing" for your implementation.Modifier | Constructor and Description |
---|---|
protected |
AbstractXMLObjectUnmarshaller()
Constructor.
|
protected |
AbstractXMLObjectUnmarshaller(String targetNamespaceURI,
String targetLocalName)
Deprecated.
no replacement
|
Modifier and Type | Method and Description |
---|---|
protected XMLObject |
buildXMLObject(Element domElement)
Constructs the XMLObject that the given DOM Element will be unmarshalled into.
|
protected void |
checkElementIsTarget(Element domElement)
Checks that the given DOM Element's XSI type or namespace qualified element name matches the target QName of this
unmarshaller.
|
protected void |
checkIDAttribute(Attr attribute)
Check whether the attribute's QName is registered in the global ID attribute registry.
|
protected abstract void |
processAttribute(XMLObject xmlObject,
Attr attribute)
Called after an attribute has been unmarshalled so that it can be added to the XMLObject.
|
protected abstract void |
processChildElement(XMLObject parentXMLObject,
XMLObject childXMLObject)
Called after a child element has been unmarshalled so that it can be added to the parent XMLObject.
|
protected abstract void |
processElementContent(XMLObject xmlObject,
String elementContent)
Called if the element being unmarshalled contained textual content so that it can be added to the XMLObject.
|
XMLObject |
unmarshall(Element domElement)
Unmarshalls the given W3C DOM element into a XMLObject.
|
protected void |
unmarshallAttribute(XMLObject xmlObject,
Attr attribute)
Unmarshalls the attributes from the given DOM Attr into the given XMLObject.
|
protected void |
unmarshallChildElement(XMLObject xmlObject,
Element childElement)
Unmarshalls given Element's children.
|
protected void |
unmarshallNamespaceAttribute(XMLObject xmlObject,
Attr attribute)
Unmarshalls a namespace declaration attribute.
|
protected void |
unmarshallSchemaInstanceAttributes(XMLObject xmlObject,
Attr attribute)
Unmarshalls the XSI type, schemaLocation, and noNamespaceSchemaLocation attributes.
|
protected void |
unmarshallTextContent(XMLObject xmlObject,
Text content)
Unmarshalls the given Text node into a usable string by way of
Text.getWholeText() and passes it off to
processElementContent(XMLObject, String) if the string is not null and
contains something other than whitespace. |
protected AbstractXMLObjectUnmarshaller()
protected AbstractXMLObjectUnmarshaller(String targetNamespaceURI, String targetLocalName)
targetNamespaceURI
- the namespace URI of either the schema type QName or element QName of the elements this
unmarshaller operates ontargetLocalName
- the local name of either the schema type QName or element QName of the elements this
unmarshaller operates onpublic XMLObject unmarshall(Element domElement) throws UnmarshallingException
unmarshall
in interface Unmarshaller
domElement
- the DOM ElementUnmarshallingException
- thrown if an error occurs unmarshalling the DOM element into the XMLObjectprotected void checkElementIsTarget(Element domElement) throws UnmarshallingException
domElement
- the DOM element to checkUnmarshallingException
- thrown if the DOM Element does not match the target of this unmarshallerprotected XMLObject buildXMLObject(Element domElement) throws UnmarshallingException
XMLObjectBuilder.buildObject(String, String, String)
. Extending classes may wish to override
this logic if more than just schema type or element name (e.g. element attributes or content) need to be used to
determine which XMLObjectBuilder should be used to create the XMLObject.domElement
- the DOM Element the created XMLObject will representUnmarshallingException
- thrown if there is now XMLObjectBuilder registered for the given DOM Elementprotected void unmarshallAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException
unmarshallNamespaceAttribute(XMLObject, Attr)
. If it is an schema type
decleration (xsi:type) it is ignored because this attribute is handled by buildXMLObject(Element)
. All
other attributes are passed to the processAttribute(XMLObject, Attr)
attribute
- the attribute to be unmarshalledxmlObject
- the XMLObject that will recieve information from the DOM attributeUnmarshallingException
- thrown if there is a problem unmarshalling an attributeprotected void unmarshallNamespaceAttribute(XMLObject xmlObject, Attr attribute)
xmlObject
- the xmlObject to recieve the namespace declerationattribute
- the namespace decleration attributeprotected void unmarshallSchemaInstanceAttributes(XMLObject xmlObject, Attr attribute)
xmlObject
- the xmlObject to recieve the namespace declerationattribute
- the namespace decleration attributeprotected void checkIDAttribute(Attr attribute)
attribute
- the DOM attribute to be checkedprotected void unmarshallChildElement(XMLObject xmlObject, Element childElement) throws UnmarshallingException
UnmarshallerFactory.getUnmarshaller(Element)
. The unmarshaller is then used to unmarshall the child
element and the resultant XMLObject is passed to processChildElement(XMLObject, XMLObject)
for further
processing.xmlObject
- the parent object of the unmarshalled childrenchildElement
- the child element to be unmarshalledUnmarshallingException
- thrown if an error occurs unmarshalling the chilren elementsprotected void unmarshallTextContent(XMLObject xmlObject, Text content) throws UnmarshallingException
Text.getWholeText()
and passes it off to
processElementContent(XMLObject, String)
if the string is not null and
contains something other than whitespace.xmlObject
- the XMLObject recieving the element contentcontent
- the textual contentUnmarshallingException
- thrown if there is a problem unmarshalling the text nodeprotected abstract void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException
parentXMLObject
- the parent XMLObjectchildXMLObject
- the child XMLObjectUnmarshallingException
- thrown if there is a problem adding the child to the parentprotected abstract void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException
xmlObject
- the XMLObjectattribute
- the attributeUnmarshallingException
- thrown if there is a problem adding the attribute to the XMLObjectprotected abstract void processElementContent(XMLObject xmlObject, String elementContent)
xmlObject
- XMLObject the content will be given toelementContent
- the Element's contentCopyright © 2018 JBoss by Red Hat. All rights reserved.