Class FormattedOutputStreamRecord

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.OutputStreamRecord
org.eclipse.persistence.oxm.record.FormattedOutputStreamRecord
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 FormattedOutputStreamRecord extends OutputStreamRecord

Use this type of MarshalRecord when the marshal target is an OutputStream and the XML should be formatted with carriage returns and indenting. This type is only used if the encoding of the OutputStream is UTF-8

XMLContext xmlContext = new XMLContext("session-name");
XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
FormattedOutputStreamRecord record = new FormattedOutputStreamRecord();
record.setOutputStream(myOutputStream);
xmlMarshaller.marshal(myObject, record);

If the marshal(OutputStream) and setFormattedOutput(true) method is called on XMLMarshaller and the encoding is UTF-8, then the OutputStream is automatically wrapped in a FormattedOutputStreamRecord.

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

See Also:
  • Constructor Details

    • FormattedOutputStreamRecord

      public FormattedOutputStreamRecord()
  • Method Details

    • endDocument

      public void endDocument()
      INTERNAL:
      Overrides:
      endDocument in class OutputStreamRecord
    • startDocument

      public void startDocument(String encoding, String version)
      INTERNAL:
      Overrides:
      startDocument in class OutputStreamRecord
      Parameters:
      encoding - The XML document will be encoded using this encoding.
      version - This specifies the version of XML.
    • writeHeader

      public void writeHeader()
      INTERNAL
      Overrides:
      writeHeader in class OutputStreamRecord
    • 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 OutputStreamRecord
      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 OutputStreamRecord
      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 OutputStreamRecord
      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 OutputStreamRecord
      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 OutputStreamRecord
      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 OutputStreamRecord
      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