Methods defined in this class are convenience methods that combine several basic operations
in the JAXBContext, Unmarshaller, and Marshaller.
They are designed
to be the prefered methods for developers new to Jakarta XML Binding. They have
the following characterstics:
DataBindingException (which will have JAXBException
as its cause. It is expected that
people who prefer the checked exception would use
the rest of the Jakarta XML Binding API directly.
In addition, the unmarshal methods have the following characteristic:
DataBindingException.
Similarly, the marshal methods have the following characteristic:
DataBindingException.
All the methods on this class require non-null arguments to all parameters.
The unmarshal methods either fail with an exception or return
a non-null value.
| Modifier and Type | Class and Description |
|---|---|
| private static class | JAXB.Cache
To improve the performance, we'll cache the last |
| Modifier and Type | Field and Description |
|---|---|
| private static volatile WeakReference | cache
Cache. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| private static void | _marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, Object JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.Represents the receiver of XML. Objects of the following types are allowed.
xml)
Writes a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| private static <T> JAXBContext | getContext(Class<T> type)
Obtains the | ||||||||||||||||
| private static String | |||||||||||||||||
| public static void | marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, File JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.XML will be written to this file. If it already exists,
it will be overwritten. xml)Writes a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| public static void | marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, URL xml)JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.Writes a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| public static void | marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, URI JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.The URI is xml)turned into URL and then
follows the handling of URL. See above.Writes a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| public static void | marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, String JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.The string is first interpreted as an absolute xml)URI.
If it's not a valid absolute URI,
then it's interpreted as a FileWrites a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| public static void | marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, OutputStream JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.The XML will be sent to the given xml)OutputStream.
Upon a successful completion, the stream will be closed by this method.Writes a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| public static void | marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, Writer JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.The XML will be sent as a character stream to the given xml)Writer.
Upon a successful completion, the stream will be closed by this method.Writes a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| public static void | marshal(Object
The Java object to be marshalled into XML. If this object is
a jaxbObject, Result JAXBElement, it will provide the root tag name and
the body. If this object has XmlRootElement
on its class definition, that will be used as the root tag name
and the given object will provide the body. Otherwise,
the root tag name is inferred from
the short class name.
This parameter must not be null.The XML will be sent to the xml)Result object.Writes a Java object tree to XML and store it to the specified location. | ||||||||||||||||
| private static Result | |||||||||||||||||
| private static Source | |||||||||||||||||
| public static <T> T | |||||||||||||||||
| public static <T> T | |||||||||||||||||
| public static <T> T | unmarshal(URI
The URI is xml, Class<T> type)turned into URL and then
follows the handling of URL.Reads in a Java object tree from the given XML input. | ||||||||||||||||
| public static <T> T | unmarshal(String
The string is first interpreted as an absolute xml, Class<T> type)URI.
If it's not a valid absolute URI,
then it's interpreted as a FileReads in a Java object tree from the given XML input. | ||||||||||||||||
| public static <T> T | unmarshal(InputStream
The entire stream is read as an XML infoset.
Upon a successful completion, the stream will be closed by this method. xml, Class<T> type)Reads in a Java object tree from the given XML input. | ||||||||||||||||
| public static <T> T | |||||||||||||||||
| public static <T> T |
| cache | back to summary |
|---|---|
| private static volatile WeakReference<JAXB. Cache. We don't want to prevent the | |
| JAXB | back to summary |
|---|---|
| private JAXB() No instantiation is allowed. | |
| _marshal | back to summary | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| private static void _marshal(Object jaxbObject, Object xml) Writes a Java object tree to XML and store it to the specified location.
This method is a convenience method that combines several basic operations
in the
| |||||||||||||||||
| getContext | back to summary |
|---|---|
| private static <T> JAXBContext getContext(Class<T> type) throws JAXBException Obtains the
We don't use locks to control access to | |
| inferName | back to summary |
|---|---|
| private static String inferName(Class<?> clazz) | |
| marshal | back to summary |
|---|---|
| public static void marshal(Object jaxbObject, File xml) Writes a Java object tree to XML and store it to the specified location.
| |
| marshal | back to summary |
|---|---|
| public static void marshal(Object jaxbObject, URL xml) Writes a Java object tree to XML and store it to the specified location.
| |
| marshal | back to summary |
|---|---|
| public static void marshal(Object jaxbObject, URI xml) Writes a Java object tree to XML and store it to the specified location.
| |
| marshal | back to summary |
|---|---|
| public static void marshal(Object jaxbObject, String xml) Writes a Java object tree to XML and store it to the specified location.
| |
| marshal | back to summary |
|---|---|
| public static void marshal(Object jaxbObject, OutputStream xml) Writes a Java object tree to XML and store it to the specified location.
| |
| marshal | back to summary |
|---|---|
| public static void marshal(Object jaxbObject, Writer xml) Writes a Java object tree to XML and store it to the specified location.
| |
| marshal | back to summary |
|---|---|
| public static void marshal(Object jaxbObject, Result xml) Writes a Java object tree to XML and store it to the specified location.
| |
| toResult | back to summary |
|---|---|
| private static Result toResult(Object xml) throws IOException Creates | |
| toSource | back to summary |
|---|---|
| private static Source toSource(Object xml) throws IOException Creates | |
| unmarshal | back to summary |
|---|---|
| public static <T> T unmarshal(File xml, Class<T> type) Reads in a Java object tree from the given XML input.
| |
| unmarshal | back to summary |
|---|---|
| public static <T> T unmarshal(URL xml, Class<T> type) Reads in a Java object tree from the given XML input.
| |
| unmarshal | back to summary |
|---|---|
| public static <T> T unmarshal(URI xml, Class<T> type) Reads in a Java object tree from the given XML input.
| |
| unmarshal | back to summary |
|---|---|
| public static <T> T unmarshal(String xml, Class<T> type) Reads in a Java object tree from the given XML input.
| |
| unmarshal | back to summary |
|---|---|
| public static <T> T unmarshal(InputStream xml, Class<T> type) Reads in a Java object tree from the given XML input.
| |
| unmarshal | back to summary |
|---|---|
| public static <T> T unmarshal(Reader xml, Class<T> type) Reads in a Java object tree from the given XML input.
| |
| unmarshal | back to summary |
|---|---|
| public static <T> T unmarshal(Source xml, Class<T> type) Reads in a Java object tree from the given XML input. | |
JAXBContext used.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final JAXBContext | |
| pack-priv final Class |
| context | back to summary |
|---|---|
| pack-priv final JAXBContext context | |
| type | back to summary |
|---|---|
| pack-priv final Class<?> type | |
| Cache | back to summary |
|---|---|
| public Cache(Class<?> type) throws JAXBException | |