/** * Create a new {@code IUnmarshallingContext}. * @return the created unmarshalling context * @throws JiBXException in case of errors */ protected IUnmarshallingContext createUnmarshallingContext() throws JiBXException { Assert.state(this.bindingFactory != null, "JibxMarshaller not initialized"); return this.bindingFactory.createUnmarshallingContext(); }
/** * Creates a new <code>IUnmarshallingContext</code>, set with the correct indentation. * * @return the created unmarshalling context * @throws JiBXException in case of errors */ protected IUnmarshallingContext createUnmarshallingContext() throws JiBXException { return bindingFactory.createUnmarshallingContext(); }
private Order decode2Order(String xmlBody) throws JiBXException { reader = new StringReader(xmlBody); IUnmarshallingContext uctx = factory.createUnmarshallingContext(); Order order = (Order) uctx.unmarshalDocument(reader); return order; }
protected Object decode0(ChannelHandlerContext arg0, ByteBuf body) throws Exception { factory = BindingDirectory.getFactory(clazz); String content = body.toString(UTF_8); if (isPrint) System.out.println("The body is : " + content); reader = new StringReader(content); IUnmarshallingContext uctx = factory.createUnmarshallingContext(); Object result = uctx.unmarshalDocument(reader); reader.close(); reader = null; return result; }
public static <T> T fromXML(byte[] bytes, Class<T> clazz) throws Exception { ByteArrayInputStream baos = new ByteArrayInputStream(bytes); IBindingFactory bfact = BindingDirectory.getFactory(clazz); UnmarshallingContext uctx = (UnmarshallingContext) bfact.createUnmarshallingContext(); Object obj = uctx.unmarshalDocument(baos, "UTF-8"); return clazz.cast(obj); }
public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { Class<?> unmarshallType = exchange.getIn().getHeader(UNMARSHALL_CLASS, Class.class); if (unmarshallType == null) { unmarshallType = getUnmarshallClass(); } ObjectHelper.notNull(unmarshallType, "unmarshallClass or CamelJibxUnmarshallClass header"); IBindingFactory bindingFactory = createBindingFactory(unmarshallType, bindingName); IUnmarshallingContext unmarshallingContext = bindingFactory.createUnmarshallingContext(); return unmarshallingContext.unmarshalDocument(stream, null); }
/** * Read in this catalog. * @param catalogLocation * @return */ public Catalog getCatalog(String catalogLocation) { try { IBindingFactory jc = BindingDirectory.getFactory(Catalog.class); IUnmarshallingContext unmarshaller = jc.createUnmarshallingContext(); URL url = new URL(catalogLocation); InputStream inStream = url.openStream(); Catalog message = (Catalog)unmarshaller.unmarshalDocument( inStream, URL_ENCODING); return message; } catch (JiBXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }
/** * Unmarshal this xml Message to a JIBX object. * @param xml * @param system * @return */ public static Object unmarshalMessage(String xml, Class<?> clazz) { try { IBindingFactory jc = BindingDirectory.getFactory(clazz); IUnmarshallingContext unmarshaller = jc.createUnmarshallingContext(); Reader inStream = new StringReader(xml); Object message = unmarshaller.unmarshalDocument(inStream); return message; } catch (JiBXException e) { e.printStackTrace(); } return null; } /**
/** * Unmarshal this xml Message to a JIBX object. * @param xml * @param system * @return */ public static Object unmarshalMessage(String xml, Class<?> clazz) { try { IBindingFactory jc = BindingDirectory.getFactory(clazz); IUnmarshallingContext unmarshaller = jc.createUnmarshallingContext(); Reader inStream = new StringReader(xml); Object message = unmarshaller.unmarshalDocument(inStream); return message; } catch (JiBXException e) { e.printStackTrace(); } return null; } /**
/** * Read the template into the model. * @return */ public Object getBindingFromStream(Class<?> bindingClass, InputStream inStream) { try { IBindingFactory jc = BindingDirectory.getFactory(bindingClass); IUnmarshallingContext unmarshaller = jc.createUnmarshallingContext(); Model message = (Model)unmarshaller.unmarshalDocument( inStream, URL_ENCODING); return message; } catch (JiBXException e) { e.printStackTrace(); } return null; } /**
/** * 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); } }
/** * 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); } }
protected void loadCustomizations(String path, IClassLocator loc, ValidationContext vctx) throws JiBXException, IOException { // load or create customization information setLocator(loc); m_global = new GlobalCustom(loc); if (path != null) { IBindingFactory fact = BindingDirectory.getFactory("class_customs_binding", GlobalCustom.class); IUnmarshallingContext ictx = fact.createUnmarshallingContext(); FileInputStream is = new FileInputStream(path); ictx.setDocument(is, null); ictx.setUserContext(vctx); ((IUnmarshallable)m_global).unmarshal(ictx); } }
protected void loadCustomizations(String path, IClassLocator loc, ValidationContext vctx) throws JiBXException, IOException { // load or create customization information m_global = new GlobalCustom(loc); m_global.setNamespaceStyle(new Integer(CustomBase.DERIVE_FIXED)); if (path != null) { IBindingFactory fact = BindingDirectory.getFactory("class-customs-binding", GlobalCustom.class); IUnmarshallingContext ictx = fact.createUnmarshallingContext(); FileInputStream is = new FileInputStream(path); ictx.setDocument(is, null); ictx.setUserContext(vctx); ((IUnmarshallable)m_global).unmarshal(ictx); } setLocator(loc); }
protected final void init(InputStream is) throws RepositoryConfigurationException { try { IBindingFactory factory = BindingDirectory.getFactory(RepositoryServiceConfiguration.class); IUnmarshallingContext uctx = factory.createUnmarshallingContext(); RepositoryServiceConfiguration conf = (RepositoryServiceConfiguration)uctx.unmarshalDocument(is, null); this.defaultRepositoryName = conf.getDefaultRepositoryName(); this.repositoryConfigurations = conf.getRepositoryConfigurations(); } catch (JiBXException e) { throw new RepositoryConfigurationException("Error in config initialization " + e, e); } }
getFactory(m_versionBindings[i], clas); UnmarshallingContext context = (UnmarshallingContext)fact.createUnmarshallingContext();
private static UnmarshallingContext getUnmarshallingContext(XMLStreamReader reader, Class jtype) throws JiBXException { IBindingFactory factory; if (JibxSimpleTypes.isSimpleType(jtype)) { factory = JibxNullBindingFactory.getFactory(); } else { factory = BindingDirectory.getFactory(jtype); } UnmarshallingContext ctx = (UnmarshallingContext)factory.createUnmarshallingContext(); StAXReaderWrapper wrapper = new StAXReaderWrapper(reader, "Data-element", true); ctx.setDocument(wrapper); ctx.toTag(); return ctx; }
private static UnmarshallingContext getUnmarshallingContext(XMLStreamReader reader, Class<?> jtype) throws JiBXException { IBindingFactory factory; if (JibxSimpleTypes.isSimpleType(jtype)) { factory = JibxNullBindingFactory.getFactory(); } else { factory = BindingDirectory.getFactory(jtype); } UnmarshallingContext ctx = (UnmarshallingContext)factory.createUnmarshallingContext(); StAXReaderWrapper wrapper = new StAXReaderWrapper(reader, "Data-element", true); ctx.setDocument(wrapper); ctx.toTag(); return ctx; } }
} else { IBindingFactory fact = BindingDirectory.getFactory(WsdlCustom.class); IUnmarshallingContext ictx = fact.createUnmarshallingContext(); FileInputStream is = new FileInputStream(path); ictx.setDocument(is, null);
private StyledLayerDescriptorInfo parseXml(String name, String raw) throws JiBXException { IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); Object object = uctx.unmarshalDocument(new StringReader(raw)); StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object; if (sld.getName() == null) { sld.setName(name); } if (sld.getTitle() == null) { sld.setTitle(getTitle(sld, name)); } if (sld.getVersion() == null) { sld.setVersion("1.0.0"); } return sld; }