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.
XMLUnmarshaller
document, locator, namespaceDeclarations, nodes, stringBuffer, xmlPlatform
Modifier and Type | Method and Description |
---|---|
void |
endDocument() |
Object |
getResult()
Returns the object that was unmarshalled from the SAX events.
|
void |
startDocument() |
addNamespaceDeclaration, appendChildNode, characters, characters, comment, endCDATA, endDTD, endElement, endEntity, endPrefixMapping, getDocument, getInitializedDocument, ignorableWhitespace, processingInstruction, setDocumentLocator, setNil, skippedEntity, startCDATA, startDTD, startElement, startEntity, startPrefixMapping
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
characters, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startElement, startPrefixMapping
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
endDocument
in class SAXDocumentBuilder
SAXException
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
startDocument
in class SAXDocumentBuilder
SAXException
public Object getResult()
getResult
in interface org.eclipse.persistence.internal.oxm.UnmarshallerHandler
XMLMarshalException
- if an error occurred during unmarshallingCopyright © 2007–2020 Eclipse.org - EclipseLink Project. All rights reserved.