/** * Reads in a Java object tree from the given XML input. * * @param xml * Reads the entire file as XML. */ public static <T> T unmarshal( File xml, Class<T> type ) { try { JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(new StreamSource(xml), type); return item.getValue(); } catch (JAXBException e) { throw new DataBindingException(e); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * Reads in a Java object tree from the given XML input. * * @param xml * The entire stream is read as an XML infoset. * Upon a successful completion, the stream will be closed by this method. */ public static <T> T unmarshal( InputStream 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); } }
/** * Reads in a Java object tree from the given XML input. * * @param xml * The string is first interpreted as an absolute {@code URI}. * If it's not {@link URI#isAbsolute() a valid absolute URI}, * then it's interpreted as a {@code File} */ public static <T> T unmarshal( String 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); } }
/** * Reads in a Java object tree from the given XML input. * * @param xml * The character stream is read as an XML infoset. * The encoding declaration in the XML will be ignored. * Upon a successful completion, the stream will be closed by this method. */ public static <T> T unmarshal( Reader 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); } }
m.marshal(jaxbObject, toResult(xml)); } catch (JAXBException e) { throw new DataBindingException(e); } catch (IOException e) { throw new DataBindingException(e);
private final JAXBContext initCtx() { try { return JAXBContext.newInstance(type); } catch (JAXBException 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); } }
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); } }
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 <T> T unmarshal(Source source, Class<T> type) { try { JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(source, type); return item.getValue(); } catch (JAXBException 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); } }
public static <T> T unmarshal(Source source, Class<T> type) { try { JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(source, type); return item.getValue(); } 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 <T> T unmarshal(Source source, Class<T> type) { try { JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(source, type); return item.getValue(); } catch (JAXBException e) { throw new DataBindingException(e); } }
static <T> T execute(JaxbCallback<T> callback) { try { return callback.doExecute(); } catch (JAXBException ex) { throw new DataBindingException(ex); } }
static <T> T execute(JaxbCallback<T> callback) { try { return callback.doExecute(); } catch (JAXBException ex) { throw new DataBindingException(ex); } }