public class JAXBResult extends SAXResult
Result实现解组JAXB对象。
此实用程序类将JAXB与其他Java / XML技术相结合是有用的。
以下示例显示如何使用JAXB解组XSLT转换导致的文档。
JAXBResult result = new JAXBResult(
JAXBContext.newInstance("org.acme.foo") );
// set up XSLT transformation
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource("test.xsl"));
// run transformation
t.transform(new StreamSource("document.xml"),result);
// obtain the unmarshalled content tree
Object o = result.getResult();
JAXBResult源自SAXResult的事实是一个实现细节。 因此,一般来说,强烈建议不要访问SAXResult上定义的方法。
特别是不要尝试调用setHandler,setLexicalHandler和setSystemId方法。
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING| Constructor and Description |
|---|
JAXBResult(JAXBContext context)
创建一个使用指定的JAXBContext解组的新实例。
|
JAXBResult(Unmarshaller _unmarshaller)
创建一个使用指定的Unmarshaller解组对象的新实例。
|
| Modifier and Type | Method and Description |
|---|---|
Object |
getResult()
获取由转换创建的未编组对象。
|
getHandler, getLexicalHandler, getSystemId, setHandler, setLexicalHandler, setSystemIdpublic JAXBResult(JAXBContext context) throws JAXBException
context - 将用于创建必要的Unmarshaller的JAXBContext。
此参数不能为空。
JAXBException - 如果在创建JAXBResult或者context参数为空时遇到错误。
public JAXBResult(Unmarshaller _unmarshaller) throws JAXBException
此JAXBResult对象将使用指定的Unmarshaller实例。 呼叫者有责任在此对象使用的同时使用相同的Unmarshaller进行其他用途。
此方法的主要目的是允许客户端配置Unmarshaller。 除非你知道你在做什么,否则传递一个JAXBContext更容易和更安全。
_unmarshaller - unmarshaller。
此参数不能为空。
JAXBException - 如果在创建JAXBResult或Unmarshaller参数为空时遇到错误。
public Object getResult() throws JAXBException
IllegalStateException - 如果在对象被取消编组之前调用此方法。
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.