Refine search
/** * Reads in a Java object tree from the given XML input. * * @param xml * The XML infoset that the {@link Source} represents is read. */ public static <T> T unmarshal( Source xml, Class<T> type ) { try { JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type); return item.getValue(); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e); } }
context = getContext(((JAXBElement<?>)jaxbObject).getDeclaredType()); } else { Class<?> clazz = jaxbObject.getClass(); XmlRootElement r = clazz.getAnnotation(XmlRootElement.class); context = getContext(clazz); if(r==null) { jaxbObject = new JAXBElement(new QName(inferName(clazz)),clazz,jaxbObject); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(jaxbObject, toResult(xml)); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e);
public static void marshal(Object object, Result result) { try { JAXBContext context; if (object instanceof JAXBElement) { context = getContext(((JAXBElement<?>) object).getDeclaredType()); } else { Class<?> clazz = object.getClass(); XmlRootElement r = clazz.getAnnotation(XmlRootElement.class); if (r == null) { // we need to infer the name object = new JAXBElement(new QName(Introspector.decapitalize(clazz.getSimpleName())), clazz, object); } context = getContext(clazz); } Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(object, result); } catch (JAXBException e) { throw new DataBindingException(e); } }
private final JAXBContext initCtx() { try { return JAXBContext.newInstance(type); } catch (JAXBException e) { throw new DataBindingException(e); } }
/** * Creates a new unmarshaller, which can be used to unmarshal XML to objects. * <p> * Note that the returned unmarshaller is not thread-safe. * </p> * * @return The unmarshaller. * @see #createMarshaller() */ public final Unmarshaller createUnmarshaller() { try { return configuration.getJAXBContext().createUnmarshaller(); } catch (JAXBException e) { throw new DataBindingException(e); } }
public static <T> T unmarshal(URI uri, Class<T> type) { if (uri == null) { throw new IllegalStateException("No uri is given"); } try { return unmarshal(uri.toURL(), type); } catch (MalformedURLException e) { throw new DataBindingException(e); } }
public static void marshal(Object object, URI uri) { if (uri == null) { throw new IllegalStateException("No uri is given"); } try { marshal(object, uri.toURL()); } catch (IOException e) { throw new DataBindingException(e); } }
static <T> T execute(JaxbCallback<T> callback) { try { return callback.doExecute(); } catch (JAXBException ex) { throw new DataBindingException(ex); } }
context = getContext(((JAXBElement<?>)jaxbObject).getDeclaredType()); } else { Class<?> clazz = jaxbObject.getClass(); XmlRootElement r = clazz.getAnnotation(XmlRootElement.class); context = getContext(clazz); if(r==null) { jaxbObject = new JAXBElement(new QName(inferName(clazz)),clazz,jaxbObject); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(jaxbObject, toResult(xml)); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e);
public static void marshal(Object object, Result result) { try { JAXBContext context; if (object instanceof JAXBElement) { context = getContext(((JAXBElement<?>) object).getDeclaredType()); } else { Class<?> clazz = object.getClass(); XmlRootElement r = clazz.getAnnotation(XmlRootElement.class); if (r == null) { // we need to infer the name object = new JAXBElement(new QName(Introspector.decapitalize(clazz.getSimpleName())), clazz, object); } context = getContext(clazz); } Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(object, result); } catch (JAXBException e) { throw new DataBindingException(e); } }
public static <T> T unmarshal(URI uri, Class<T> type) { if (uri == null) { throw new IllegalStateException("No uri is given"); } try { return unmarshal(uri.toURL(), type); } catch (MalformedURLException e) { throw new DataBindingException(e); } }
public static void marshal(Object object, URI uri) { if (uri == null) { throw new IllegalStateException("No uri is given"); } try { marshal(object, uri.toURL()); } catch (IOException e) { throw new DataBindingException(e); } }
static <T> T execute(JaxbCallback<T> callback) { try { return callback.doExecute(); } catch (JAXBException ex) { throw new DataBindingException(ex); } }
/** * Reads in a Java object tree from the given XML input. * * @param xml * The resource pointed by the URL is read in its entirety. */ public static <T> T unmarshal( URL xml, Class<T> type ) { try { JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type); return item.getValue(); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e); } }
context = getContext(((JAXBElement<?>)jaxbObject).getDeclaredType()); } else { Class<?> clazz = jaxbObject.getClass(); XmlRootElement r = clazz.getAnnotation(XmlRootElement.class); context = getContext(clazz); if(r==null) { jaxbObject = new JAXBElement(new QName(inferName(clazz)),clazz,jaxbObject); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(jaxbObject, toResult(xml)); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e);
public static void marshal(Object object, Result result) { try { JAXBContext context; if (object instanceof JAXBElement) { context = getContext(((JAXBElement<?>) object).getDeclaredType()); } else { Class<?> clazz = object.getClass(); XmlRootElement r = clazz.getAnnotation(XmlRootElement.class); if (r == null) { // we need to infer the name object = new JAXBElement(new QName(Introspector.decapitalize(clazz.getSimpleName())), clazz, object); } context = getContext(clazz); } Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(object, result); } catch (JAXBException e) { throw new DataBindingException(e); } }
public static <T> T unmarshal(URI uri, Class<T> type) { if (uri == null) { throw new IllegalStateException("No uri is given"); } try { return unmarshal(uri.toURL(), type); } catch (MalformedURLException e) { throw new DataBindingException(e); } }
public static void marshal(Object object, URI uri) { if (uri == null) { throw new IllegalStateException("No uri is given"); } try { marshal(object, uri.toURL()); } catch (IOException e) { throw new DataBindingException(e); } }
/** * Reads in a Java object tree from the given XML input. * * @param xml * The URI is {@link URI#toURL() turned into URL} and then * follows the handling of {@code URL}. */ public static <T> T unmarshal( URI xml, Class<T> type ) { try { JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type); return item.getValue(); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e); } }
context = getContext(((JAXBElement<?>)jaxbObject).getDeclaredType()); } else { Class<?> clazz = jaxbObject.getClass(); XmlRootElement r = clazz.getAnnotation(XmlRootElement.class); context = getContext(clazz); if(r==null) { jaxbObject = new JAXBElement(new QName(inferName(clazz)),clazz,jaxbObject); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); m.marshal(jaxbObject, toResult(xml)); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e);