use of org.jibx.runtime.IBindingFactory in project tutorials by eugenp.
the class CustomerIntegrationTest method WhenUnmarshal_ThenMappingInherited.
@Test
public void WhenUnmarshal_ThenMappingInherited() throws JiBXException, FileNotFoundException {
IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream inputStream = classLoader.getResourceAsStream("Customer1.xml");
Customer customer = (Customer) uctx.unmarshalDocument(inputStream, null);
assertEquals(12345, customer.getPerson().getCustomerId());
}
use of org.jibx.runtime.IBindingFactory in project alfresco-repository by Alfresco.
the class SystemInfo method toXML.
/**
* Create XML representation of System Info
*
* @param xml xml representation of system info
*/
public void toXML(OutputStream xml) {
try {
IBindingFactory factory = BindingDirectory.getFactory(SystemInfo.class);
IMarshallingContext context = factory.createMarshallingContext();
context.setIndent(4);
context.marshalDocument(this, "UTF-8", null, xml);
} catch (JiBXException e) {
throw new DictionaryException("Failed to create System Info", e);
}
}
use of org.jibx.runtime.IBindingFactory in project alfresco-repository by Alfresco.
the class SystemInfo method createSystemInfo.
/**
* Create System Info from XML representation
*
* @param xml xml representation of system info
* @return the System Info
*/
public static SystemInfo createSystemInfo(InputStream xml) {
try {
IBindingFactory factory = BindingDirectory.getFactory(SystemInfo.class);
IUnmarshallingContext context = factory.createUnmarshallingContext();
Object obj = context.unmarshalDocument(xml, null);
return (SystemInfo) obj;
} catch (JiBXException e) {
throw new DictionaryException("Failed to parse System Info", e);
}
}
Aggregations