| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public final class JAXB extends Object
Class that defines convenience methods for common, simple use of JAXB.
Methods defined in this class are convenience methods that combine several basic operations in the {@link JAXBContext}, {@link Unmarshaller}, and {@link Marshaller}. They are designed to be the prefered methods for developers new to JAXB. They have the following characterstics:
In addition, the unmarshal methods have the following characteristic:
Similarly, the marshal methods have the following characteristic:
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.
Method Summary | |
---|---|
static void |
Writes a Java object tree to XML and store it to the specified location. |
static void |
marshal(Object jaxbObject, OutputStream xml) Writes a Java object tree to XML and store it to the specified location. |
static void |
Writes a Java object tree to XML and store it to the specified location. |
static void |
Writes a Java object tree to XML and store it to the specified location. |
static void |
Writes a Java object tree to XML and store it to the specified location. |
static void |
Writes a Java object tree to XML and store it to the specified location. |
static void |
Writes a Java object tree to XML and store it to the specified location. |
static Object |
Reads in a Java object tree from the given XML input. |
static Object |
unmarshal(InputStream xml, Class type) Reads in a Java object tree from the given XML input. |
static Object |
Reads in a Java object tree from the given XML input. |
static Object |
Reads in a Java object tree from the given XML input. |
static Object |
Reads in a Java object tree from the given XML input. |
static Object |
Reads in a Java object tree from the given XML input. |
static Object |
Reads in a Java object tree from the given XML input. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void marshal(Object jaxbObject, File xml)
jaxbObject
- The Java object to be marshalled into XML. If this object is
a {@link JAXBElement}, it will provide the root tag name and
the body. If this object has {@link 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 {@link Introspector#decapitalize(String) infered} from
{@link Class#getSimpleName() the short class name}.
This parameter must not be null.xml
- XML will be written to this file. If it already exists,
it will be overwritten.public static void marshal(Object jaxbObject, OutputStream xml)
jaxbObject
- The Java object to be marshalled into XML. If this object is
a {@link JAXBElement}, it will provide the root tag name and
the body. If this object has {@link 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 {@link Introspector#decapitalize(String) infered} from
{@link Class#getSimpleName() the short class name}.
This parameter must not be null.xml
- The XML will be sent to the given {@link OutputStream}.
Upon a successful completion, the stream will be closed by this method.public static void marshal(Object jaxbObject, Result xml)
jaxbObject
- The Java object to be marshalled into XML. If this object is
a {@link JAXBElement}, it will provide the root tag name and
the body. If this object has {@link 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 {@link Introspector#decapitalize(String) infered} from
{@link Class#getSimpleName() the short class name}.
This parameter must not be null.xml
- The XML will be sent to the {@link Result} object.public static void marshal(Object jaxbObject, String xml)
jaxbObject
- The Java object to be marshalled into XML. If this object is
a {@link JAXBElement}, it will provide the root tag name and
the body. If this object has {@link 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 {@link Introspector#decapitalize(String) infered} from
{@link Class#getSimpleName() the short class name}.
This parameter must not be null.xml
- The string is first interpreted as an absolute URI.
If it's not {@link URI#isAbsolute() a valid absolute URI},
then it's interpreted as a Filepublic static void marshal(Object jaxbObject, URI xml)
jaxbObject
- The Java object to be marshalled into XML. If this object is
a {@link JAXBElement}, it will provide the root tag name and
the body. If this object has {@link 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 {@link Introspector#decapitalize(String) infered} from
{@link Class#getSimpleName() the short class name}.
This parameter must not be null.xml
- The URI is {@link URI#toURL() turned into URL} and then
follows the handling of URL. See above.public static void marshal(Object jaxbObject, URL xml)
jaxbObject
- The Java object to be marshalled into XML. If this object is
a {@link JAXBElement}, it will provide the root tag name and
the body. If this object has {@link 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 {@link Introspector#decapitalize(String) infered} from
{@link Class#getSimpleName() the short class name}.
This parameter must not be null.xml
- The XML will be {@link URLConnection#getOutputStream() sent} to the
resource pointed by this URL. Note that not all URLs support
such operation, and exact semantics depends on the URL
implementations. In case of {@link HttpURLConnection HTTP URLs},
this will perform HTTP POST.public static void marshal(Object jaxbObject, Writer xml)
jaxbObject
- The Java object to be marshalled into XML. If this object is
a {@link JAXBElement}, it will provide the root tag name and
the body. If this object has {@link 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 {@link Introspector#decapitalize(String) infered} from
{@link Class#getSimpleName() the short class name}.
This parameter must not be null.xml
- The XML will be sent as a character stream to the given {@link Writer}.
Upon a successful completion, the stream will be closed by this method.public static Object unmarshal(File xml, Class type)
xml
- Reads the entire file as XML.type
public static Object unmarshal(InputStream xml, Class type)
xml
- The entire stream is read as an XML infoset.
Upon a successful completion, the stream will be closed by this method.type
public static Object unmarshal(Reader xml, Class type)
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.type
public static Object unmarshal(Source xml, Class type)
xml
- The XML infoset that the {@link Source} represents is read.type
public static Object unmarshal(String xml, Class type)
xml
- The string is first interpreted as an absolute URI.
If it's not {@link URI#isAbsolute() a valid absolute URI},
then it's interpreted as a Filetype
public static Object unmarshal(URI xml, Class type)
xml
- The URI is {@link URI#toURL() turned into URL} and then
follows the handling of URL.type
public static Object unmarshal(URL xml, Class type)
xml
- The resource pointed by the URL is read in its entirety.type
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |