List of utility methods to do XML JAXB Unmarshaller
T | unmarshalFromXml(Class unmarshal From Xml final JAXBContext context = JAXBContext.newInstance(clazz); return unmarshalFromXml(context, clazz, xml); |
T | unmarshalFromXml(final String xml, Class unmarshal From Xml JAXBContext jaxbContext = JAXBContext.newInstance(destinationClass); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(xml); return (T) unmarshaller.unmarshal(reader); |
T | unmarshalInstance(final String data, final Class unmarshal Instance try { final JAXBContext ctx = JAXBContext.newInstance(expectedType); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); final StreamSource streamSource = new StreamSource(new StringReader(data)); final JAXBElement<T> jaxbElement = unmarshaller.unmarshal(streamSource, expectedType); return jaxbElement.getValue(); } catch (JAXBException e) { throw new RuntimeException(e); ... |
CLAZZ | unmarshall(Class unmarshall JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller um = context.createUnmarshaller(); return (CLAZZ) um.unmarshal(new StringReader(string)); |
String | unmarshall(Class unmarshall JAXBContext ctx = JAXBContext.newInstance(c); Marshaller marshaller = ctx.createMarshaller(); StringWriter entityXml = new StringWriter(); marshaller.marshal(o, entityXml); return entityXml.toString(); |
T | unmarshall(Class Unmarshall from DOM Element to a generic JAXBElement try { JAXBContext jc = JAXBContext.newInstance(cls); Unmarshaller unmarshaller = jc.createUnmarshaller(); JAXBElement<T> jaxbObject = unmarshaller.unmarshal(domRequest, cls); return jaxbObject.getValue(); } catch (JAXBException e) { e.printStackTrace(); return null; |
S | unmarshall(InputStream is, Class unmarshall JAXBContext context = JAXBContext.newInstance(clz); Unmarshaller unmarshaller = context.createUnmarshaller(); JAXBElement<S> root = unmarshaller.unmarshal(new StreamSource(is), clz); return root.getValue(); |
T | unmarshall(InputStream toUnmarshall, Class UnMarshalls a String to the specidfied object type. Object unmarshalled = null; try { JAXBContext ctx = JAXBContext.newInstance(clazz.getPackage().getName()); unmarshalled = ctx.createUnmarshaller().unmarshal(new InputStreamReader(toUnmarshall)); } catch (Exception e) { throw new RuntimeException(e); return (T) unmarshalled; ... |
Object | unmarshall(JAXBContext c, Element e) unmarshall Unmarshaller u = c.createUnmarshaller(); try { u.setEventHandler(null); return u.unmarshal(e); } finally { closeUnmarshaller(u); |
Object | unmarshall(String cntxtPkg, InputStream in) unmarshall Unmarshaller unmarshaller = createUmarshall(cntxtPkg); if (unmarshaller == null) return null; return unmarshaller.unmarshal(in); |