javax.xml.bind.JAXB.toSource()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中javax.xml.bind.JAXB.toSource()方法的一些代码示例,展示了JAXB.toSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JAXB.toSource()方法的具体详情如下:
包路径:javax.xml.bind.JAXB
类名称:JAXB
方法名:toSource

JAXB.toSource介绍

[英]Creates Source from various XML representation. See #unmarshal for the conversion rules.
[中]从各种XML表示创建源。有关转换规则,请参见#解组。

代码示例

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: stackoverflow.com

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)

代码示例来源:origin: org.jboss.spec.javax.xml.bind/jboss-jaxb-api_2.2_spec

/**
 * 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);
  }
}

代码示例来源:origin: org.glassfish.metro/webservices-api

/**
 * 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);
  }
}

代码示例来源:origin: org.glassfish.metro/webservices-api

/**
 * 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);
  }
}

代码示例来源:origin: javax/javaee-endorsed-api

/**
 * 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);
  }
}

代码示例来源:origin: org.jboss.spec.javax.xml.bind/jboss-jaxb-api_2.2_spec

/**
 * 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);
  }
}

代码示例来源:origin: sun-jaxb/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: jakarta.xml.bind/jakarta.xml.bind-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api-osgi

/**
 * 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);
  }
}

代码示例来源:origin: sun-jaxb/jaxb-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/jaxb-api-osgi

/**
 * 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);
  }
}

代码示例来源:origin: javax/javaee-endorsed-api

/**
 * 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);
  }
}

代码示例来源:origin: javax.xml.bind/com.springsource.javax.xml.bind

/**
 * 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);
  }
}

代码示例来源:origin: org.jboss.spec.javax.xml.bind/jboss-jaxb-api_2.2_spec

/**
 * 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);
  }
}

相关文章