List of utility methods to do XML JAXB Unmarshaller
Unmarshaller | getUnmarshaller() get Unmarshaller if (unmarshaller != null) { return unmarshaller; try { if (jc == null) { jc = JAXBContext.newInstance(REQ_PKG); unmarshaller = jc.createUnmarshaller(); ... |
Unmarshaller | getUnmarshaller() Gets the results Unmarshaller (for validation results.) try { return jaxbContext.createUnmarshaller(); } catch (JAXBException e) { throw new RuntimeException("Failed to create Unmarshaller", e); |
Unmarshaller | getUnmarshaller() get Unmarshaller Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() { public boolean handleEvent(ValidationEvent event) { boolean keepOn = false; return keepOn; }); return unmarshaller; ... |
Unmarshaller | getUnmarshaller(Class jaxbClass) get Unmarshaller JAXBContext jaxbContext = JAXBContext.newInstance(jaxbClass);
return jaxbContext.createUnmarshaller();
|
T | marshallUnmarshall(T inObj) Marshalls inObj and unmarshalls the result, returning the unmarshalled version DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); JAXBContext jc = JAXBContext.newInstance(inObj.getClass()); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FRAGMENT, true); JAXBElement inel = new JAXBElement(new QName("", "obj"), inObj.getClass(), inObj); m.marshal(inel, doc); ... |
T | unmarshal(Class unmarshal return (T) getUnmarshaller().unmarshal(is);
|
String | unmarshal(Class unmarshal JAXBContext ctx = JAXBContext.newInstance(c); Marshaller marshaller = ctx.createMarshaller(); StringWriter entityXml = new StringWriter(); marshaller.marshal(o, entityXml); String entityString = entityXml.toString(); return entityString; |
T | unmarshal(Class unmarshal JAXBContext jc = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = jc.createUnmarshaller();
JAXBElement<T> jaxbElement = unmarshaller.unmarshal(source, clazz);
T object = jaxbElement.getValue();
return object;
|
T | unmarshal(Class unmarshal T t = JAXB.unmarshal(new StringReader(xml), clazz); return t; |
T | unmarshal(Class unmarshal Reader reader = null; try { URL xmlUrl = Resources.getResource(xmlInClassPath); reader = new InputStreamReader(xmlUrl.openStream(), "UTF-8"); JAXBContext context = JAXBContext.newInstance(clazz); return (T) context.createUnmarshaller().unmarshal(reader); } catch (Exception e) { throw new RuntimeException("Failed to unmarshal object for class:" + clazz + " xml:" + xmlInClassPath, ... |