org.eclipse.persistence.oxm

Class XMLMarshaller

    • Constructor Summary

      Constructors 
      Constructor and Description
      XMLMarshaller(XMLContext xmlContext)
      Create a new XMLMarshaller based on the specified session
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      XMLMarshaller clone() 
      XMLAttachmentMarshaller getAttachmentMarshaller() 
      java.lang.String getAttributePrefix()
      Value that will be used to prefix attributes.
      CharacterEscapeHandler getCharacterEscapeHandler()
      Return this Marshaller's CharacterEscapeHandler.
      java.lang.String getEncoding()
      Get the encoding set on this XMLMarshaller If the encoding has not been set the default UTF-8 will be used
      org.xml.sax.ErrorHandler getErrorHandler() 
      java.lang.String getIndentString()
      Return the String that will be used to perform indenting in marshalled documents.
      XMLMarshalListener getMarshalListener() 
      MediaType getMediaType()
      Get the MediaType for this xmlMarshaller.
      NamespacePrefixMapper getNamespacePrefixMapper()
      NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)
      char getNamespaceSeparator()
      Get the namespace separator used during marshal operations.
      java.lang.String getNoNamespaceSchemaLocation()
      Get the no namespace schema location set on this XMLMarshaller
      java.util.Properties getProperties()
      Return a properties object for a given instance of the XMLMarshaller.
      java.lang.Object getProperty(java.lang.Object key)
      Return the property for a given key, if one exists.
      javax.xml.validation.Schema getSchema() 
      java.lang.String getSchemaLocation()
      Get the schema location set on this XMLMarshaller
      XMLTransformer getTransformer()
      INTERNAL
      java.lang.String getValueWrapper()
      Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.
      XMLContext getXMLContext()
      Return the instance of XMLContext that was used to create this instance of XMLMarshaller.
      java.lang.String getXmlHeader()
      Get this Marshaller's XML Header.
      boolean isEqualUsingIdenity()
      INTERNAL
      boolean isFormattedOutput()
      Returns if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
      boolean isFragment()
      PUBLIC: Returns if this should marshal to a fragment.
      boolean isIncludeRoot()
      Determine if the @XMLRootElement should be marshalled when present.
      boolean isMarshalEmptyCollections()
      Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.
      boolean isReduceAnyArrays()
      Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.
      boolean isWrapperAsCollectionName() 
      void marshal(java.lang.Object object, org.xml.sax.ContentHandler contentHandler)
      PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Document
      void marshal(java.lang.Object object, org.xml.sax.ContentHandler contentHandler, org.xml.sax.ext.LexicalHandler lexicalHandler)
      PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Document
      void marshal(java.lang.Object object, MarshalRecord marshalRecord)
      Convert the given object to XML and update the given marshal record with that XML Document.
      void marshal(java.lang.Object object, org.w3c.dom.Node node)
      PUBLIC: Convert the given object to XML and update the given node with that XML Document
      void marshal(java.lang.Object object, java.io.OutputStream outputStream)
      PUBLIC: Convert the given object to XML and update the given outputStream with that XML Document
      void marshal(java.lang.Object object, javax.xml.transform.Result result)
      PUBLIC: Convert the given object to XML and update the given result with that XML Document
      void marshal(java.lang.Object object, java.io.Writer writer)
      PUBLIC: Convert the given object to XML and update the given writer with that XML Document
      org.w3c.dom.Document objectToXML(java.lang.Object object)
      PUBLIC: Convert the given object to an XML Document
      org.w3c.dom.Document objectToXML(java.lang.Object object, org.w3c.dom.Node parent)
      Deprecated.  
      org.w3c.dom.Document objectToXML(java.lang.Object object, org.w3c.dom.Node parent, DocumentPreservationPolicy docPresPolicy) 
      org.w3c.dom.Document objectToXML(java.lang.Object object, org.w3c.dom.Node rootNode, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy) 
      org.w3c.dom.Document objectToXML(java.lang.Object object, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy)
      INTERNAL: Convert the given object to an XML Document
      void setAttachmentMarshaller(XMLAttachmentMarshaller atm) 
      void setAttributePrefix(java.lang.String attributePrefix)
      Value that will be used to prefix attributes.
      void setCharacterEscapeHandler(CharacterEscapeHandler c)
      Set this Marshaller's CharacterEscapeHandler.
      void setEncoding(java.lang.String newEncoding)
      Set the encoding on this XMLMarshaller If the encoding is not set the default UTF-8 will be used
      void setEqualUsingIdenity(boolean equalUsingIdenity)
      INTERNAL
      void setErrorHandler(org.xml.sax.ErrorHandler errorHandler) 
      void setFormattedOutput(boolean shouldFormat)
      Set if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
      void setFragment(boolean fragment)
      PUBLIC: Set if this should marshal to a fragment.
      void setIncludeRoot(boolean includeRoot)
      Determine if the @XMLRootElement should be marshalled when present.
      void setIndentString(java.lang.String s)
      Set the String that will be used to perform indenting in marshalled documents.
      void setMarshalEmptyCollections(java.lang.Boolean marshalEmptyCollections)
      Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.
      void setMarshalListener(XMLMarshalListener listener) 
      void setMediaType(MediaType mediaType)
      Set the MediaType for this xmlMarshaller.
      void setNamespacePrefixMapper(NamespacePrefixMapper mapper)
      NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)
      void setNamespaceSeparator(char namespaceSeparator)
      Set the namespace separator used during marshal operations.
      void setNoNamespaceSchemaLocation(java.lang.String newNoNamespaceSchemaLocation)
      Set the no namespace schema location on this XMLMarshaller
      void setReduceAnyArrays(boolean reduceAnyArrays)
      Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.
      void setSchema(javax.xml.validation.Schema schema) 
      void setSchemaLocation(java.lang.String newSchemaLocation)
      Set the schema location on this XMLMarshaller
      void setValueWrapper(java.lang.String valueWrapper)
      Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.
      void setWrapperAsCollectionName(boolean wrapperAsCollectionName) 
      void setXMLContext(XMLContext value)
      Set the XMLContext used by this instance of XMLMarshaller.
      void setXmlHeader(java.lang.String xmlHeader)
      Set this Marshaller's XML Header.
      void setXMLMarshalHandler(XMLMarshalListener marshalListener) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XMLMarshaller

        public XMLMarshaller(XMLContext xmlContext)
        Create a new XMLMarshaller based on the specified session
        Parameters:
        session - A single session
    • Method Detail

      • getXMLContext

        public XMLContext getXMLContext()
        Return the instance of XMLContext that was used to create this instance of XMLMarshaller.
      • setXMLContext

        public void setXMLContext(XMLContext value)
        Set the XMLContext used by this instance of XMLMarshaller.
      • getErrorHandler

        public org.xml.sax.ErrorHandler getErrorHandler()
      • setErrorHandler

        public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
      • isFormattedOutput

        public boolean isFormattedOutput()
        Returns if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
        Returns:
        if this XMLMarshaller should format the XML
      • setFormattedOutput

        public void setFormattedOutput(boolean shouldFormat)
        Set if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.
        Parameters:
        shouldFormat - if this XMLMarshaller should format the XML
      • getEncoding

        public java.lang.String getEncoding()
        Get the encoding set on this XMLMarshaller If the encoding has not been set the default UTF-8 will be used
        Returns:
        the encoding set on this XMLMarshaller
      • setEncoding

        public void setEncoding(java.lang.String newEncoding)
        Set the encoding on this XMLMarshaller If the encoding is not set the default UTF-8 will be used
        Parameters:
        newEncoding - the encoding to set on this XMLMarshaller
      • setMediaType

        public void setMediaType(MediaType mediaType)
        Set the MediaType for this xmlMarshaller. See org.eclipse.persistence.oxm.MediaType for the media types supported by EclipseLink MOXy
        Parameters:
        mediaType -
      • getMediaType

        public MediaType getMediaType()
        Get the MediaType for this xmlMarshaller. See org.eclipse.persistence.oxm.MediaType for the media types supported by EclipseLink MOXy If not set the default is MediaType.APPLICATION_XML
        Returns:
        MediaType
      • getSchemaLocation

        public java.lang.String getSchemaLocation()
        Get the schema location set on this XMLMarshaller
        Returns:
        the schema location specified on this XMLMarshaller
      • setSchemaLocation

        public void setSchemaLocation(java.lang.String newSchemaLocation)
        Set the schema location on this XMLMarshaller
        Parameters:
        newSchemaLocation - the schema location to be seton this XMLMarshaller
      • getNoNamespaceSchemaLocation

        public java.lang.String getNoNamespaceSchemaLocation()
        Get the no namespace schema location set on this XMLMarshaller
        Returns:
        the no namespace schema location specified on this XMLMarshaller
      • getProperties

        public java.util.Properties getProperties()
        Return a properties object for a given instance of the XMLMarshaller.
        Returns:
      • getProperty

        public java.lang.Object getProperty(java.lang.Object key)
        Return the property for a given key, if one exists.
        Returns:
      • setNoNamespaceSchemaLocation

        public void setNoNamespaceSchemaLocation(java.lang.String newNoNamespaceSchemaLocation)
        Set the no namespace schema location on this XMLMarshaller
        Parameters:
        newNoNamespaceSchemaLocation - no namespace schema location to be seton this XMLMarshaller
      • setXMLMarshalHandler

        public void setXMLMarshalHandler(XMLMarshalListener marshalListener)
      • marshal

        public void marshal(java.lang.Object object,
                   javax.xml.transform.Result result)
                     throws XMLMarshalException
        PUBLIC: Convert the given object to XML and update the given result with that XML Document
        Parameters:
        object - the object to marshal
        result - the result to marshal the object to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • marshal

        public void marshal(java.lang.Object object,
                   java.io.OutputStream outputStream)
                     throws XMLMarshalException
        PUBLIC: Convert the given object to XML and update the given outputStream with that XML Document
        Parameters:
        object - the object to marshal
        outputStream - the outputStream to marshal the object to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • marshal

        public void marshal(java.lang.Object object,
                   java.io.Writer writer)
                     throws XMLMarshalException
        PUBLIC: Convert the given object to XML and update the given writer with that XML Document
        Parameters:
        object - the object to marshal
        writer - the writer to marshal the object to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • marshal

        public void marshal(java.lang.Object object,
                   org.xml.sax.ContentHandler contentHandler)
                     throws XMLMarshalException
        PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Document
        Parameters:
        object - the object to marshal
        contentHandler - the contentHandler which the specified object should be marshalled to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • marshal

        public void marshal(java.lang.Object object,
                   org.xml.sax.ContentHandler contentHandler,
                   org.xml.sax.ext.LexicalHandler lexicalHandler)
                     throws XMLMarshalException
        PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Document
        Parameters:
        object - the object to marshal
        contentHandler - the contentHandler which the specified object should be marshalled to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • marshal

        public void marshal(java.lang.Object object,
                   org.w3c.dom.Node node)
                     throws XMLMarshalException
        PUBLIC: Convert the given object to XML and update the given node with that XML Document
        Parameters:
        object - the object to marshal
        node - the node which the specified object should be marshalled to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • marshal

        public void marshal(java.lang.Object object,
                   MarshalRecord marshalRecord)
        Convert the given object to XML and update the given marshal record with that XML Document.
        Parameters:
        object - the object to marshal
        marshalRecord - the marshalRecord to marshal the object to
      • objectToXML

        public org.w3c.dom.Document objectToXML(java.lang.Object object)
                                         throws XMLMarshalException
        PUBLIC: Convert the given object to an XML Document
        Parameters:
        object - the object to marshal
        Returns:
        the document which the specified object has been marshalled to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • objectToXML

        public org.w3c.dom.Document objectToXML(java.lang.Object object,
                                       org.w3c.dom.Node parent)
                                         throws XMLMarshalException
        Deprecated. 
        PUBLIC: Convert the given object to descendants of the parent element
        Parameters:
        object - the object to marshal
        parent - the node to marshal the object to
        Returns:
        the document which the specified object has been marshalled to
        Throws:
        XMLMarshalException - if an error occurred during marshalling
      • objectToXML

        public org.w3c.dom.Document objectToXML(java.lang.Object object,
                                       org.w3c.dom.Node parent,
                                       DocumentPreservationPolicy docPresPolicy)
      • objectToXML

        public org.w3c.dom.Document objectToXML(java.lang.Object object,
                                       XMLDescriptor descriptor,
                                       XMLRecord xmlRow,
                                       boolean isXMLRoot,
                                       DocumentPreservationPolicy docPresPolicy)
        INTERNAL: Convert the given object to an XML Document
      • setFragment

        public void setFragment(boolean fragment)
        PUBLIC: Set if this should marshal to a fragment. If true an XML header string is not written out.
        Parameters:
        fragment - if this should marshal to a fragment or not
      • isFragment

        public boolean isFragment()
        PUBLIC: Returns if this should marshal to a fragment. If true an XML header string is not written out.
        Returns:
        if this should marshal to a fragment or not
      • getTransformer

        public XMLTransformer getTransformer()
        INTERNAL
        Returns:
        the transformer instance for this marshaller
      • getSchema

        public javax.xml.validation.Schema getSchema()
      • setSchema

        public void setSchema(javax.xml.validation.Schema schema)
      • clone

        public XMLMarshaller clone()
        Overrides:
        clone in class java.lang.Object
      • getAttributePrefix

        public java.lang.String getAttributePrefix()
        Value that will be used to prefix attributes. Ignored marshalling XML.
        Returns:
        Since:
        2.4
      • setAttributePrefix

        public void setAttributePrefix(java.lang.String attributePrefix)
        Value that will be used to prefix attributes. Ignored marshalling XML.
        Since:
        2.4
      • getValueWrapper

        public java.lang.String getValueWrapper()
        Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.
        Since:
        2.4
      • setValueWrapper

        public void setValueWrapper(java.lang.String valueWrapper)
        Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.
        Since:
        2.4
      • isWrapperAsCollectionName

        public boolean isWrapperAsCollectionName()
        Since:
        2.4.2
      • setWrapperAsCollectionName

        public void setWrapperAsCollectionName(boolean wrapperAsCollectionName)
        Since:
        2.4.2
      • isMarshalEmptyCollections

        public boolean isMarshalEmptyCollections()
        Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.
        Since:
        2.4
      • setMarshalEmptyCollections

        public void setMarshalEmptyCollections(java.lang.Boolean marshalEmptyCollections)
        Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.
        Since:
        2.4
      • isReduceAnyArrays

        public boolean isReduceAnyArrays()
        Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.
      • setReduceAnyArrays

        public void setReduceAnyArrays(boolean reduceAnyArrays)
        Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.
      • isIncludeRoot

        public boolean isIncludeRoot()
        Determine if the @XMLRootElement should be marshalled when present. Ignored marshalling XML.
        Returns:
        Since:
        2.4
      • setIncludeRoot

        public void setIncludeRoot(boolean includeRoot)
        Determine if the @XMLRootElement should be marshalled when present. Ignored marshalling XML.
        Since:
        2.4
      • getNamespaceSeparator

        public char getNamespaceSeparator()
        Get the namespace separator used during marshal operations. If mediaType is application/json '.' is the default Ignored marshalling XML.
        Since:
        2.4
      • setNamespaceSeparator

        public void setNamespaceSeparator(char namespaceSeparator)
        Set the namespace separator used during marshal operations. If mediaType is application/json '.' is the default Ignored marshalling XML.
        Since:
        2.4
      • setNamespacePrefixMapper

        public void setNamespacePrefixMapper(NamespacePrefixMapper mapper)
        NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)
        Since:
        2.3.3
      • getNamespacePrefixMapper

        public NamespacePrefixMapper getNamespacePrefixMapper()
        NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)
        Returns:
        Since:
        2.3.3
      • getIndentString

        public java.lang.String getIndentString()
        Return the String that will be used to perform indenting in marshalled documents. Default is " " (three spaces).
        Since:
        2.3.3
      • setIndentString

        public void setIndentString(java.lang.String s)
        Set the String that will be used to perform indenting in marshalled documents.
        Since:
        2.3.3
      • getCharacterEscapeHandler

        public CharacterEscapeHandler getCharacterEscapeHandler()
        Return this Marshaller's CharacterEscapeHandler.
        Since:
        2.3.3
      • setCharacterEscapeHandler

        public void setCharacterEscapeHandler(CharacterEscapeHandler c)
        Set this Marshaller's CharacterEscapeHandler.
        Since:
        2.3.3
      • getXmlHeader

        public java.lang.String getXmlHeader()
        Get this Marshaller's XML Header.
        Since:
        2.4
      • setXmlHeader

        public void setXmlHeader(java.lang.String xmlHeader)

        Set this Marshaller's XML Header. This header string will appear after the XML processing instruction (<?xml ...>), but before the start of the document's data.

        This feature is only supported when marshalling to Stream, Writer, or StreamResult.

        Since:
        2.4
      • isEqualUsingIdenity

        public boolean isEqualUsingIdenity()
        INTERNAL
      • setEqualUsingIdenity

        public void setEqualUsingIdenity(boolean equalUsingIdenity)
        INTERNAL

EclipseLink 2.4.2, "build v20130514-5956486" API Reference