本文整理了Java中javax.xml.bind.JAXB.getContext()
方法的一些代码示例,展示了JAXB.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JAXB.getContext()
方法的具体详情如下:
包路径:javax.xml.bind.JAXB
类名称:JAXB
方法名:getContext
[英]Obtains the JAXBContext from the given type, by using the cache if possible.
We don't use locks to control access to #cache, but this code should be thread-safe thanks to the immutable Cache and volatile.
[中]尽可能使用缓存从给定类型获取JAXBContext。
我们不使用锁来控制对#缓存的访问,但是由于不可变缓存和易失性,这段代码应该是线程安全的。
代码示例来源:origin: javax.xml.bind/jaxb-api
/**
* 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);
}
}
代码示例来源: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: javax.xml.bind/jaxb-api
context = getContext(((JAXBElement<?>)jaxbObject).getDeclaredType());
} else {
Class<?> clazz = jaxbObject.getClass();
XmlRootElement r = clazz.getAnnotation(XmlRootElement.class);
context = getContext(clazz);
if(r==null) {
代码示例来源:origin: org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.1
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);
}
}
代码示例来源:origin: org.apache.openejb/javaee-api
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);
}
}
代码示例来源:origin: org.apache.geronimo.specs/geronimo-jaxb_2.1_spec
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);
}
}
代码示例来源: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
* 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);
}
}
代码示例来源:origin: org.glassfish.metro/webservices-api
/**
* 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);
}
}
代码示例来源:origin: sun-jaxb/jaxb-api
/**
* 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);
}
}
代码示例来源:origin: jakarta.xml.bind/jakarta.xml.bind-api
/**
* 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);
}
}
代码示例来源:origin: javax.xml.bind/com.springsource.javax.xml.bind
/**
* 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);
}
}
代码示例来源:origin: javax/javaee-endorsed-api
/**
* 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);
}
}
代码示例来源:origin: javax.xml.bind/jaxb-api-osgi
/**
* 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);
}
}
代码示例来源:origin: jboss/jboss-javaee-specs
/**
* 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);
}
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!