Class XMLUnmarshallerHandler
- java.lang.Object
-
- org.eclipse.persistence.platform.xml.SAXDocumentBuilder
-
- org.eclipse.persistence.oxm.XMLUnmarshallerHandler
-
- All Implemented Interfaces:
org.eclipse.persistence.internal.oxm.record.ExtendedContentHandler
,org.eclipse.persistence.internal.oxm.UnmarshallerHandler
,org.xml.sax.ContentHandler
,org.xml.sax.ext.LexicalHandler
public class XMLUnmarshallerHandler extends SAXDocumentBuilder implements org.eclipse.persistence.internal.oxm.UnmarshallerHandler
Class used to unmarshal SAX events to objects.
Create an XMLUnmarshallerHandler from an XMLUnmarshaller.
Code Sample
XMLContext context = new XMLContext("mySessionName");
XMLUnmarshaller unmarshaller = context.createUnmarshaller();
XMLUnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();
Use the UnmarshallerHandler with an XMLReader
Code Sample
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setNamespaceAware(true);
SAXParser saxParser = saxParserFactory.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
xmlReader.setContentHandler(xmlUnmarshallerHandler);
FileInputStream inputStream = new FileInputStream("MyFile.xml");
InputSource inputSource = new InputSource(inputStream);
xmlReader.parse(inputSource);
Object result = xmlUnmarshallerHandler.getResult();
XML that can be unmarshalled is XML which has a root tag that corresponds to a default root element on an XMLDescriptor in the TopLink project associated with the XMLContext.
- See Also:
XMLUnmarshaller
-
-
Field Summary
-
Fields inherited from class org.eclipse.persistence.platform.xml.SAXDocumentBuilder
document, locator, namespaceDeclarations, nodes, stringBuffer, xmlPlatform
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endDocument()
java.lang.Object
getResult()
Returns the object that was unmarshalled from the SAX events.void
startDocument()
-
Methods inherited from class org.eclipse.persistence.platform.xml.SAXDocumentBuilder
addNamespaceDeclaration, appendChildNode, characters, characters, comment, endCDATA, endDTD, endElement, endEntity, endPrefixMapping, getDocument, getInitializedDocument, ignorableWhitespace, processingInstruction, setDocumentLocator, setNil, skippedEntity, startCDATA, startDTD, startElement, startEntity, startPrefixMapping
-
-
-
-
Method Detail
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in classSAXDocumentBuilder
- Throws:
org.xml.sax.SAXException
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classSAXDocumentBuilder
- Throws:
org.xml.sax.SAXException
-
getResult
public java.lang.Object getResult()
Returns the object that was unmarshalled from the SAX events.- Specified by:
getResult
in interfaceorg.eclipse.persistence.internal.oxm.UnmarshallerHandler
- Returns:
- the resulting object
- Throws:
XMLMarshalException
- if an error occurred during unmarshalling
-
-