List of utility methods to do XML JAXB Unserialize
T | loadXml(File file, Class load Xml JAXBContext context = JAXBContext.newInstance(requireType);
Unmarshaller um = context.createUnmarshaller();
return (T) um.unmarshal(file);
|
Object | loadXML(Object object, String fileNamePath) load XML Unmarshaller unmarshaller = createUnmarshaller(object); Object loaded = null; File fileXML = createFile(fileNamePath); if (fileXML.length() > 0) { try { loaded = unmarshaller.unmarshal(new FileReader(fileNamePath)); } catch (FileNotFoundException e) { e.printStackTrace(); ... |
Object | loadXMLFromString(Object object, String line) load XML From String Unmarshaller unmarshaller = createUnmarshaller(object); Object loaded = null; StringReader stringReader = new StringReader(line); if (!line.isEmpty()) { try { loaded = unmarshaller.unmarshal(stringReader); } catch (JAXBException e) { e.printStackTrace(); ... |
T | parse(final Class parse try { final JAXBContext jaxbContext = JAXBContext.newInstance(clazz); final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); final Object deserialized = jaxbUnmarshaller.unmarshal(inputStream); if (clazz.isAssignableFrom(deserialized.getClass())) { return clazz.cast(deserialized); } else { final JAXBElement<T> jaxbElement = (JAXBElement<T>) deserialized; ... |
Calendar | parseIsoDate(String lexicalDate) Parses an ISO 8601 date string. return javax.xml.bind.DatatypeConverter.parseDate(lexicalDate);
|
T | parseJaxb(Class Parse XML using JAXB and a model class. JAXBContext context = JAXBContext.newInstance(cls);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
Unmarshaller um = context.createUnmarshaller();
return (T) um.unmarshal(in);
|
K | parseXml(final Class parse Xml JAXBContext context = JAXBContext.newInstance(klass);
return (K) context.createUnmarshaller().unmarshal(xmlReader);
|
T | parseXML(String content, Class parse XML Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setSchema(metadataSchema); JAXBElement<T> unmarshalled = unmarshaller.unmarshal(new StreamSource(new StringReader(content)), clazz); return unmarshalled.getValue(); |
T | parseXmlFile(Class parse Xml File T instance = null; File file = new File(filePath); JAXBContext jaxbContext = JAXBContext.newInstance(type); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); instance = (T) jaxbUnmarshaller.unmarshal(file); return instance; |
T | read(Class read JAXBContext context = JAXBContext.newInstance(cl);
Unmarshaller unmarshaller = context.createUnmarshaller();
T o = cl.cast(unmarshaller.unmarshal(is));
return o;
|