Class FormattedWriterRecord

java.lang.Object
org.eclipse.persistence.internal.core.sessions.CoreAbstractRecord
org.eclipse.persistence.internal.oxm.record.AbstractMarshalRecordImpl<org.eclipse.persistence.internal.core.sessions.CoreAbstractSession,org.eclipse.persistence.internal.core.helper.CoreField,MARSHALLER,org.eclipse.persistence.internal.oxm.NamespaceResolver>
org.eclipse.persistence.oxm.record.MarshalRecord<org.eclipse.persistence.internal.oxm.XMLMarshaller>
org.eclipse.persistence.oxm.record.WriterRecord
org.eclipse.persistence.oxm.record.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:
  • Constructor Details

    • FormattedWriterRecord

      public FormattedWriterRecord()
  • Method Details

    • startDocument

      public void startDocument(String encoding, 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.
    • endDocument

      public void endDocument()
      INTERNAL:
      Overrides:
      endDocument in class WriterRecord
    • writeHeader

      public void writeHeader()
      INTERNAL
      Overrides:
      writeHeader in class WriterRecord
    • 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(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(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(Node node, org.eclipse.persistence.internal.oxm.NamespaceResolver namespaceResolver, String newNamespace, 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