List of utility methods to do XML JAXB Marshaller
boolean | isSunCanonicalization(@Nonnull final Marshaller aMarshaller) is Sun Canonicalization final String sPropertyName = isInternalSunJAXB2Marshaller(aMarshaller) ? SUN_C14N_INTERNAL : SUN_C14N; return _getBooleanProperty(aMarshaller, sPropertyName); |
boolean | isSunJAXB2Marshaller(@Nullable final Marshaller aMarshaller) Check if the passed Marshaller is a Sun JAXB v2 marshaller. if (aMarshaller == null) return false; final String sClassName = aMarshaller.getClass().getName(); return sClassName.equals(JAXB_EXTERNAL_CLASS_NAME) || sClassName.equals(JAXB_INTERNAL_CLASS_NAME); |
void | marshal(Class clz, T marshalObj) marshal JAXBContext context = JAXBContext.newInstance(clz); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(marshalObj, System.out); |
T | marshal(Class marshal T res; if (c == xml.getClass()) { res = (T) xml; else { JAXBContext ctx = JAXBContext.newInstance(c); Unmarshaller marshaller = ctx.createUnmarshaller(); res = (T) marshaller.unmarshal(new StringReader(xml)); ... |
T | marshal(Class marshal T res; if (c == xml.getClass()) { res = (T) xml; } else { JAXBContext ctx = JAXBContext.newInstance(c); Unmarshaller marshaller = ctx.createUnmarshaller(); res = (T) marshaller.unmarshal(new StringReader(xml)); return res; |
String | marshal(Class marshal StringWriter out = new StringWriter(); JAXBContext context = JAXBContext.newInstance(clazz); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(obj, out); return out.toString(); |
String | marshal(Class marshal StringWriter writer = new StringWriter(); JAXBContext jc = JAXBContext.newInstance(clazz); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(new JAXBElement<T>(new QName("body"), clazz, object), writer); String actual = writer.toString(); return actual; |
String | marshal(final Object obj, final Class... classes) JAXBContext.newInstance(..) is a slow operation. return marshal(JAXBContext.newInstance(classes), obj);
|
String | marshal(final Object object) marshal try { final JAXBContext context = JAXBContext.newInstance(object.getClass()); final Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); final StringWriter out = new StringWriter(); marshaller.marshal(object, out); return out.toString(); } catch (JAXBException e) { ... |
String | marshal(final Object object) marshal Gson gson = new Gson(); return gson.toJson(object); |