Class FormattedWriterRecord

  • All Implemented Interfaces:
    org.eclipse.persistence.internal.oxm.record.AbstractMarshalRecord<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession,​org.eclipse.persistence.internal.core.helper.CoreField,​org.eclipse.persistence.internal.oxm.XMLMarshaller,​org.eclipse.persistence.internal.oxm.NamespaceResolver>, org.eclipse.persistence.internal.oxm.record.MarshalRecord<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession,​org.eclipse.persistence.internal.core.helper.CoreField,​org.eclipse.persistence.internal.oxm.XMLMarshaller,​org.eclipse.persistence.internal.oxm.NamespaceResolver>, org.eclipse.persistence.internal.oxm.record.XMLRecord<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession>

    public class FormattedWriterRecord
    extends WriterRecord

    Use this type of MarshalRecord when the marshal target is a Writer and the XML should be formatted with carriage returns and indenting.

    XMLContext xmlContext = new XMLContext("session-name");
    XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
    FormattedWriterRecord formattedWriterRecord = new FormattedWriterRecord();
    formattedWriterRecord.setWriter(myWriter);
    xmlMarshaller.marshal(myObject, formattedWriterRecord);

    If the marshal(Writer) and setFormattedOutput(true) method is called on XMLMarshaller, then the Writer is automatically wrapped in a FormattedWriterRecord.

    XMLContext xmlContext = new XMLContext("session-name");
    XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
    xmlMarshaller xmlMarshaller.setFormattedOutput(true);
    xmlMarshaller.marshal(myObject, myWriter);

    See Also:
    XMLMarshaller
    • Constructor Detail

      • FormattedWriterRecord

        public FormattedWriterRecord()
    • Method Detail

      • startDocument

        public void startDocument​(java.lang.String encoding,
                                  java.lang.String version)
        Description copied from class: WriterRecord
        INTERNAL:
        Overrides:
        startDocument in class WriterRecord
        Parameters:
        encoding - The XML document will be encoded using this encoding.
        version - This specifies the version of XML.
      • openStartElement

        public void openStartElement​(org.eclipse.persistence.internal.oxm.XPathFragment xPathFragment,
                                     org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver)
        INTERNAL:
        Specified by:
        openStartElement in interface org.eclipse.persistence.internal.oxm.record.MarshalRecord<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession,​org.eclipse.persistence.internal.core.helper.CoreField,​org.eclipse.persistence.internal.oxm.XMLMarshaller,​org.eclipse.persistence.internal.oxm.NamespaceResolver>
        Overrides:
        openStartElement in class WriterRecord
        Parameters:
        xPathFragment - The XPathFragment contains the name and prefix information about the XML element being ended.
        namespaceResolver - The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).
      • element

        public void element​(org.eclipse.persistence.internal.oxm.XPathFragment frag)
        INTERNAL:
        Overrides:
        element in class WriterRecord
        Parameters:
        frag - The XPathFragment of the element
      • endElement

        public void endElement​(org.eclipse.persistence.internal.oxm.XPathFragment xPathFragment,
                               org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver)
        INTERNAL:
        Specified by:
        endElement in interface org.eclipse.persistence.internal.oxm.record.MarshalRecord<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession,​org.eclipse.persistence.internal.core.helper.CoreField,​org.eclipse.persistence.internal.oxm.XMLMarshaller,​org.eclipse.persistence.internal.oxm.NamespaceResolver>
        Overrides:
        endElement in class WriterRecord
        Parameters:
        xPathFragment - The XPathFragment contains the name and prefix information about the XML element being ended.
        namespaceResolver - The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).
      • characters

        public void characters​(java.lang.String value)
        INTERNAL:
        Specified by:
        characters in interface org.eclipse.persistence.internal.oxm.record.MarshalRecord<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession,​org.eclipse.persistence.internal.core.helper.CoreField,​org.eclipse.persistence.internal.oxm.XMLMarshaller,​org.eclipse.persistence.internal.oxm.NamespaceResolver>
        Overrides:
        characters in class WriterRecord
        Parameters:
        value - This is the entire value of the text node.
      • cdata

        public void cdata​(java.lang.String value)
        INTERNAL:
        Specified by:
        cdata in interface org.eclipse.persistence.internal.oxm.record.MarshalRecord<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession,​org.eclipse.persistence.internal.core.helper.CoreField,​org.eclipse.persistence.internal.oxm.XMLMarshaller,​org.eclipse.persistence.internal.oxm.NamespaceResolver>
        Overrides:
        cdata in class WriterRecord
        Parameters:
        value - This is the value of the text to be wrapped
      • node

        public void node​(org.w3c.dom.Node node,
                         org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver,
                         java.lang.String newNamespace,
                         java.lang.String newName)
        Receive notification of a node.
        Overrides:
        node in class WriterRecord
        Parameters:
        node - The Node to be added to the document
        namespaceResolver - The NamespaceResolver can be used to resolve the namespace URI/prefix of the node
        newNamespace - replacement root name for the node
        newName - replacement root namespace for the node namespace URI/prefix of the node