java.lang.Object
jakarta.xml.bind.JAXB
Class that defines convenience methods for common, simple use of Jakarta XML Binding.
 
 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 preferred methods for developers new to Jakarta XML Binding. They have
 the following characteristics:
 
- Generally speaking, the performance is not necessarily optimal. It is expected that people who need to write performance critical code will use the rest of the Jakarta XML Binding API directly.
- Errors that happen during the processing is wrapped into
      DataBindingException(which will haveJAXBExceptionas itscause. 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:
 
- Schema validation is not performed on the input XML.
      The processing will try to continue even if there
      are errors in the XML, as much as possible. Only as
      the last resort, this method fails with DataBindingException.
 Similarly, the marshal methods have the following characteristic:
 
- The processing will try to continue even if the Java object tree
      does not meet the validity requirement. Only as
      the last resort, this method fails with 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.
- Author:
- Kohsuke Kawaguchi
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidWrites a Java object tree to XML and store it to the specified location.static voidmarshal(Object jaxbObject, OutputStream xml) Writes a Java object tree to XML and store it to the specified location.static voidWrites a Java object tree to XML and store it to the specified location.static voidWrites a Java object tree to XML and store it to the specified location.static voidWrites a Java object tree to XML and store it to the specified location.static voidWrites a Java object tree to XML and store it to the specified location.static voidWrites a Java object tree to XML and store it to the specified location.static <T> TReads in a Java object tree from the given XML input.static <T> Tunmarshal(InputStream xml, Class<T> type) Reads in a Java object tree from the given XML input.static <T> TReads in a Java object tree from the given XML input.static <T> TReads in a Java object tree from the given XML input.static <T> TReads in a Java object tree from the given XML input.static <T> TReads in a Java object tree from the given XML input.static <T> TReads in a Java object tree from the given XML input.
- 
Method Details- 
unmarshalReads in a Java object tree from the given XML input.- Parameters:
- xml- Reads the entire file as XML.
 
- 
unmarshalReads in a Java object tree from the given XML input.- Parameters:
- xml- The resource pointed by the URL is read in its entirety.
 
- 
unmarshalReads in a Java object tree from the given XML input.- Parameters:
- xml- The URI is- turned into URLand then follows the handling of- URL.
 
- 
unmarshalReads in a Java object tree from the given XML input.- Parameters:
- xml- The string is first interpreted as an absolute- URI. If it's not- a valid absolute URI, then it's interpreted as a- File
 
- 
unmarshalReads in a Java object tree from the given XML input.- Parameters:
- xml- The entire stream is read as an XML infoset. Upon a successful completion, the stream will be closed by this method.
 
- 
unmarshalReads in a Java object tree from the given XML input.- Parameters:
- 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.
 
- 
unmarshalReads in a Java object tree from the given XML input.- Parameters:
- xml- The XML infoset that the- Sourcerepresents is read.
 
- 
marshalWrites a Java object tree to XML and store it to the specified location.- Parameters:
- jaxbObject- The Java object to be marshalled into XML. If this object is a- JAXBElement, it will provide the root tag name and the body. If this object has- XmlRootElementon 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- XML will be written to this file. If it already exists, it will be overwritten.
- Throws:
- DataBindingException- If the operation fails, such as due to I/O error, unbindable classes.
 
- 
marshalWrites a Java object tree to XML and store it to the specified location.- Parameters:
- jaxbObject- The Java object to be marshalled into XML. If this object is a- JAXBElement, it will provide the root tag name and the body. If this object has- XmlRootElementon 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- The XML will be- sentto the resource pointed by this URL. Note that not all- URLs support such operation, and exact semantics depends on the- URLimplementations. In case of- HTTP URLs, this will perform HTTP POST.
- Throws:
- DataBindingException- If the operation fails, such as due to I/O error, unbindable classes.
 
- 
marshalWrites a Java object tree to XML and store it to the specified location.- Parameters:
- jaxbObject- The Java object to be marshalled into XML. If this object is a- JAXBElement, it will provide the root tag name and the body. If this object has- XmlRootElementon 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- The URI is- turned into URLand then follows the handling of- URL. See above.
- Throws:
- DataBindingException- If the operation fails, such as due to I/O error, unbindable classes.
 
- 
marshalWrites a Java object tree to XML and store it to the specified location.- Parameters:
- jaxbObject- The Java object to be marshalled into XML. If this object is a- JAXBElement, it will provide the root tag name and the body. If this object has- XmlRootElementon 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- The string is first interpreted as an absolute- URI. If it's not- a valid absolute URI, then it's interpreted as a- File
- Throws:
- DataBindingException- If the operation fails, such as due to I/O error, unbindable classes.
 
- 
marshalWrites a Java object tree to XML and store it to the specified location.- Parameters:
- jaxbObject- The Java object to be marshalled into XML. If this object is a- JAXBElement, it will provide the root tag name and the body. If this object has- XmlRootElementon 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- The XML will be sent to the given- OutputStream. Upon a successful completion, the stream will be closed by this method.
- Throws:
- DataBindingException- If the operation fails, such as due to I/O error, unbindable classes.
 
- 
marshalWrites a Java object tree to XML and store it to the specified location.- Parameters:
- jaxbObject- The Java object to be marshalled into XML. If this object is a- JAXBElement, it will provide the root tag name and the body. If this object has- XmlRootElementon 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- The XML will be sent as a character stream to the given- Writer. Upon a successful completion, the stream will be closed by this method.
- Throws:
- DataBindingException- If the operation fails, such as due to I/O error, unbindable classes.
 
- 
marshalWrites a Java object tree to XML and store it to the specified location.- Parameters:
- jaxbObject- The Java object to be marshalled into XML. If this object is a- JAXBElement, it will provide the root tag name and the body. If this object has- XmlRootElementon 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- The XML will be sent to the- Resultobject.
- Throws:
- DataBindingException- If the operation fails, such as due to I/O error, unbindable classes.
 
 
-