net.sf.xolite.utils
Class RootHolder

java.lang.Object
  extended by net.sf.xolite.utils.RootHolder
All Implemented Interfaces:
XMLSerializable

public class RootHolder
extends Object
implements XMLSerializable

Utility class used when the root of a object tree parsed from XML is not known statically.
This class is used internally by XML event parsers to dynamically instantiate the tree root when there is a factory defined.


Constructor Summary
RootHolder()
           
 
Method Summary
 void endElement(String uri, String localName, XMLEventParser parser)
          Notification of the end tag of the root element.
 XMLSerializable getRoot()
           
 void serialize(XMLSerializer serializer)
          Serialize the inner root object.
 void startElement(String uri, String localName, XMLEventParser parser)
          Instantiate the real root element from the parser factory and delegate parsing to it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RootHolder

public RootHolder()
Method Detail

getRoot

public XMLSerializable getRoot()

startElement

public void startElement(String uri,
                         String localName,
                         XMLEventParser parser)
                  throws XMLParseException
Instantiate the real root element from the parser factory and delegate parsing to it.

Specified by:
startElement in interface XMLSerializable
Parameters:
uri - The started element namespace URI.
localName - The started element local name (= name without the namespace prefix) .
parser - The current XML event parser. From this parser you can get the attributes of the started element, the SAX Locator, the defined namespace prefix mappings.
Throws:
NullPointerException - if the factory is not defined.
XMLParseException - if the object corresponding to the started element is not defined or cannot be instantiated.
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(String uri,
                       String localName,
                       XMLEventParser parser)
                throws XMLParseException
Notification of the end tag of the root element.

Specified by:
endElement in interface XMLSerializable
Parameters:
uri - The ended element namespace URI.
localName - The ended element local name (= name without the namespace prefix) .
parser - The current XML event parser. From this parser you can get SAX Locator or the text content of the ended element.
Throws:
XMLParseException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

serialize

public void serialize(XMLSerializer serializer)
               throws XMLSerializeException
Serialize the inner root object.

Specified by:
serialize in interface XMLSerializable
Parameters:
serializer - The object implementing the actual serialization.
Throws:
XMLSerializeException - if something fails.


Copyright © 2012. All Rights Reserved.