List of utility methods to do XML JAXB Unmarshaller
T | unmarshallXMLtoObject(final byte[] xmlObject, final Class unmarshall XM Lto Object if (xmlObject == null) { return null; if (schemaURL == null) { throw new IllegalArgumentException("schemaURL is null"); final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); final Schema schema = sf.newSchema(schemaURL); ... |
T | unmarshalObject(final InputStream input, final Class unmarshal Object Unmarshaller unmarshaller = JAXBContext.newInstance(clazz).createUnmarshaller();
return (T) unmarshaller.unmarshal(input);
|
Package | unmarshalPackage(InputStream pkgStream) unmarshal Package Source source = new StreamSource(pkgStream); JAXBContext jc = JAXBContext.newInstance(ORG_ZEND_SDKLIB_DESCRIPTOR_PKG); Unmarshaller u = jc.createUnmarshaller(); Package pkg = (Package) u.unmarshal(source); return pkg; |
T | unmarshalXML(String xmlString, Class Un-marshall given string to given class type T t = null; if (xmlString != null) { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlString.toString().getBytes()); JAXBContext jaxbContext = JAXBContext.newInstance(classType); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); t = (T) jaxbUnmarshaller.unmarshal(byteArrayInputStream); return t; ... |
T | unmarshalXmlToObject(String xmlFilePath, Class Consumes the contents of the specified XML file, and creates a new Java object of the specified class that will contain the consumed contents. if (clazz == null) { return null; JAXBContext jaxbContext = JAXBContext.newInstance(clazz); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); @SuppressWarnings("unchecked") T result = (T) jaxbUnmarshaller.unmarshal(new java.io.FileInputStream(xmlFilePath)); return result; ... |