Class XMLUnmarshallerHandler
- All Implemented Interfaces:
ExtendedContentHandler,UnmarshallerHandler,ContentHandler,LexicalHandler
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:
-
Field Summary
Fields inherited from class org.eclipse.persistence.platform.xml.SAXDocumentBuilder
document, locator, namespaceDeclarations, nodes, stringBuffer, xmlPlatform -
Method Summary
Modifier and TypeMethodDescriptionvoidReturns the object that was unmarshalled from the SAX events.voidMethods 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, startPrefixMappingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
characters, declaration, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startElement, startPrefixMapping
-
Method Details
-
endDocument
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classSAXDocumentBuilder- Throws:
SAXException
-
startDocument
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classSAXDocumentBuilder- Throws:
SAXException
-
getResult
Returns the object that was unmarshalled from the SAX events.- Specified by:
getResultin interfaceUnmarshallerHandler- Returns:
- the resulting object
- Throws:
XMLMarshalException- if an error occurred during unmarshalling
-