Class JAXBOMDataSource

java.lang.Object
org.apache.axiom.om.ds.AbstractOMDataSource
org.apache.axiom.om.ds.AbstractPushOMDataSource
org.apache.axiom.om.ds.jaxb.JAXBOMDataSource
All Implemented Interfaces:
org.apache.axiom.om.OMDataSource, org.apache.axiom.om.OMDataSourceExt, org.apache.axiom.om.QNameAwareOMDataSource

public class JAXBOMDataSource extends org.apache.axiom.om.ds.AbstractPushOMDataSource implements org.apache.axiom.om.QNameAwareOMDataSource
OMDataSource backed by a JAXB object. This class can be used both for plain JAXB objects and for JAXBElement instances. It implements QNameAwareOMDataSource so that it can be used with OMFactory.createOMElement(OMDataSource), i.e. it is not necessary to supply the QName during construction of the OMSourcedElement. It also has full support for XOP/MTOM. It is implemented as a push-style OMDataSource so that an OMSourcedElement backed by an instance of this class can be expanded in an efficient way (including the case where the JAXB object contains base64 binary data represented as DataHandler instances or byte arrays).

The JAXB object encapsulated by an instance of this class can be retrieved using OMDataSourceExt.getObject(). Note that modifying the JAXB object after passing it to the constructor may result in unexpected behavior and should be avoided.

Instances of this class are non destructive, in the sense defined by OMDataSourceExt.isDestructiveWrite().

  • Constructor Details

    • JAXBOMDataSource

      public JAXBOMDataSource(jakarta.xml.bind.JAXBContext context, Object object)
      Constructor.
      Parameters:
      context - the JAXB context to which the object is known
      object - the JAXB object; this may be a plain Java bean or a JAXBElement
  • Method Details

    • isDestructiveWrite

      public boolean isDestructiveWrite()
      Specified by:
      isDestructiveWrite in interface org.apache.axiom.om.OMDataSourceExt
    • serialize

      public void serialize(XMLStreamWriter writer) throws XMLStreamException
      Specified by:
      serialize in interface org.apache.axiom.om.OMDataSource
      Throws:
      XMLStreamException
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface org.apache.axiom.om.QNameAwareOMDataSource
    • getNamespaceURI

      public String getNamespaceURI()
      Specified by:
      getNamespaceURI in interface org.apache.axiom.om.QNameAwareOMDataSource
    • getPrefix

      public String getPrefix()
      Specified by:
      getPrefix in interface org.apache.axiom.om.QNameAwareOMDataSource
    • getObject

      public Object getObject()
      Specified by:
      getObject in interface org.apache.axiom.om.OMDataSourceExt
      Overrides:
      getObject in class org.apache.axiom.om.ds.AbstractOMDataSource
    • copy

      public org.apache.axiom.om.OMDataSourceExt copy()
      Specified by:
      copy in interface org.apache.axiom.om.OMDataSourceExt
      Overrides:
      copy in class org.apache.axiom.om.ds.AbstractOMDataSource