本文整理汇总了Java中javax.xml.bind.Binder.unmarshal方法的典型用法代码示例。如果您正苦于以下问题:Java Binder.unmarshal方法的具体用法?Java Binder.unmarshal怎么用?Java Binder.unmarshal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.Binder
的用法示例。
在下文中一共展示了Binder.unmarshal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCamelModelObjectFromXML
import javax.xml.bind.Binder; //导入方法依赖的package包/类
/**
* Creates camel model object like CamelContextFactoryBean, RouteDefinition or RoutesDefinition
* from XML file.
*
* @param xmlPath path to the file
* @return created camel model object
* @throws Exception failed to unmarshall camel model object from XML file
*/
public static Object createCamelModelObjectFromXML(String xmlPath) throws Exception {
InputStream input = Classes.getResourceAsStream(xmlPath);
if (input == null) {
throw CommonCamelMessages.MESSAGES.specifiedCamelContextFileIsNotFound(xmlPath);
}
InputSource source = new InputSource(input);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(source);
Element element = document.getDocumentElement();
Element camelModelElement = findCamelModelElement(element, xmlPath);
if (camelModelElement == null) {
throw CommonCamelMessages.MESSAGES.noCamelContextElementFound(xmlPath);
}
Binder<Node> binder = JAXB_CONTEXT.createBinder();
Object obj = binder.unmarshal(camelModelElement);
injectNamespaces(camelModelElement, binder);
return obj;
}
示例2: parseUsingJaxb
import javax.xml.bind.Binder; //导入方法依赖的package包/类
protected Object parseUsingJaxb(Element element, ParserContext parserContext, Binder<Node> binder) {
try {
return binder.unmarshal(element);
} catch (JAXBException e) {
throw new ComponentDefinitionException("Failed to parse JAXB element: " + e, e);
}
}
示例3: parseUsingJaxb
import javax.xml.bind.Binder; //导入方法依赖的package包/类
protected Object parseUsingJaxb(Element element, ParserContext parserContext, Binder<Node> binder) {
try {
return binder.unmarshal(element);
} catch (JAXBException e) {
throw new BeanDefinitionStoreException("Failed to parse JAXB element", e);
}
}
示例4: fromXMLString
import javax.xml.bind.Binder; //导入方法依赖的package包/类
public static WindowState fromXMLString(String s){
try {
JAXBContext context = JAXBContext.newInstance(WindowState.class);
Binder<Node> binder = context.createBinder();
Document doc = XMLUtils.parse(s);
return (WindowState)binder.unmarshal(doc);
} catch (Throwable e) {
return null;
}
}