public interface UnmarshallerHandler extends ContentHandler
应用程序可以使用此接口将其JAXB提供程序用作XML管道中的组件。 例如:
  JAXBContext context = JAXBContext.newInstance( "org.acme.foo" );
       Unmarshaller unmarshaller = context.createUnmarshaller();
       UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();
       SAXParserFactory spf = SAXParserFactory.newInstance();
       spf.setNamespaceAware( true );
       XMLReader xmlReader = spf.newSAXParser().getXMLReader();
       xmlReader.setContentHandler( unmarshallerHandler );
       xmlReader.parse(new InputSource( new FileInputStream( XML_FILE ) ) );
       MyObject myObject= (MyObject)unmarshallerHandler.getResult();  
       该界面是可重用的:即使用户未能解组对象,他/他仍然可以开始新一轮的解组。
Unmarshaller.getUnmarshallerHandler() 
       | Modifier and Type | Method and Description | 
|---|---|
| Object | getResult()
              获得未组织的结果。 
             | 
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMappingObject getResult() throws JAXBException, IllegalStateException
IllegalStateException - 如果在此处理程序接收到endDocument事件之前调用此方法。 
           JAXBException - 如果有任何解组错误。 
            请注意,在解析过程中发现错误时,允许实现抛出SAXException。 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.