/** * 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); } }
Exception in thread "main" java.lang.IllegalArgumentException: URI is not absolute at java.net.URI.toURL(URI.java:1095) at javax.xml.bind.JAXB.toSource(JAXB.java:291) at javax.xml.bind.JAXB.unmarshal(JAXB.java:205) at forum23652823.Demo.main(Demo.java:8)
/** * 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 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 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 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 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 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 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 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 URI is {@link URI#toURL() turned into URL} and then * follows the handling of <tt>URL</tt>. */ 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); } }