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);
org.eclipse.persistence.oxm.XMLMarshaller
| Modifier and Type | Class and Description |
|---|---|
| private class | FormattedOutputStreamRecord.FormattedOutputStreamRecordContentHandler
This class will typically be used in conjunction with an XMLFragmentReader. |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private byte[] | |
| private boolean | |
| private int | |
| private byte[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | cdata(String
This is the value of the text to be wrapped value)Overrides org. Implements org. |
| public void | characters(String
This is the entire value of the text node. value)Overrides org. Implements org. |
| public void | element(XPathFragment<XML_FIELD extends Field>
The XPathFragment of the element frag)Overrides org. |
| public void | |
| public void | endElement(XPathFragment<XML_FIELD extends Field>
The XPathFragment contains the name and prefix
information about the XML element being ended. xPathFragment, NamespaceResolver The NamespaceResolver can be used to resolve the
namespace URI for the namespace prefix held by the XPathFragment (if
required). namespaceResolver)Overrides org. Implements org. |
| public void | node(Node
The Node to be added to the document node, NamespaceResolver The NamespaceResolver can be used to resolve the
namespace URI/prefix of the node namespaceResolver, String replacement root name for the node newNamespace, String replacement root namespace for the node
namespace URI/prefix of the node newName)Overrides org. |
| public void | openStartElement(XPathFragment<XML_FIELD extends Field>
The XPathFragment contains the name and prefix
information about the XML element being ended. xPathFragment, NamespaceResolver The NamespaceResolver can be used to resolve the
namespace URI for the namespace prefix held by the XPathFragment (if
required). namespaceResolver)Overrides org. Implements org. |
| private void | |
| public void | startDocument(String
The XML document will be encoded using this encoding. encoding, String This specifies the version of XML. version)Overrides org. |
| private byte[] | |
| public void |
| complexType | back to summary |
|---|---|
| private boolean complexType | |
| cr | back to summary |
|---|---|
| private byte[] cr | |
| isLastEventText | back to summary |
|---|---|
| private boolean isLastEventText | |
| numberOfTabs | back to summary |
|---|---|
| private int numberOfTabs | |
| tab | back to summary |
|---|---|
| private byte[] tab | |
| FormattedOutputStreamRecord | back to summary |
|---|---|
| public FormattedOutputStreamRecord() | |
| cdata | back to summary |
|---|---|
| public void cdata(String value) Overrides org. Implements org. INTERNAL:
| |
| characters | back to summary |
|---|---|
| public void characters(String value) Overrides org. Implements org. INTERNAL:
| |
| element | back to summary |
|---|---|
| public void element(XPathFragment<XML_FIELD extends Field> frag) Overrides org. INTERNAL:
| |
| endDocument | back to summary |
|---|---|
| public void endDocument() Overrides org. INTERNAL:
| |
| endElement | back to summary |
|---|---|
| public void endElement(XPathFragment<XML_FIELD extends Field> xPathFragment, NamespaceResolver namespaceResolver) Overrides org. Implements org. INTERNAL:
| |
| node | back to summary |
|---|---|
| public void node(Node node, NamespaceResolver namespaceResolver, String newNamespace, String newName) Overrides org. Receive notification of a node.
| |
| openStartElement | back to summary |
|---|---|
| public void openStartElement(XPathFragment<XML_FIELD extends Field> xPathFragment, NamespaceResolver namespaceResolver) Overrides org. Implements org. INTERNAL:
| |
| outputStreamWriteTab | back to summary |
|---|---|
| private void outputStreamWriteTab() | |
| startDocument | back to summary |
|---|---|
| public void startDocument(String encoding, String version) Overrides org. INTERNAL:
| |
| tab | back to summary |
|---|---|
| private byte[] tab() | |
| writeHeader | back to summary |
|---|---|
| public void writeHeader() Overrides org. INTERNAL
| |
org.eclipse.persistence.internal.oxm.record.XMLFragmentReader , org.eclipse.persistence.oxm.record.WriterRecord.WriterRecordContentHandler
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | characters(char[]
the characters from the XML document ch, int the start position in the array start, int the number of characters to read from the array length)Overrides org. Implements org. |
| public void | comment(char[]
An array holding the characters in the comment. ch, int The starting position in the array. start, int The number of characters to use from the array. length)Overrides org. Implements org. |
| public void | endElement(String
the Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed namespaceURI, String the local name (without prefix), or the
empty string if Namespace processing is not being
performed localName, String the qualified XML name (with prefix), or the
empty string if qualified names are not available qName)Overrides org. Implements org. |
| public void | startElement(String
the Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed namespaceURI, String the local name (without prefix), or the
empty string if Namespace processing is not being
performed localName, String the qualified name (with prefix), or the
empty string if qualified names are not available qName, Attributes the attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object. The value of this object after
startElement returns is undefined atts)Overrides org. Implements org. |
| FormattedOutputStreamRecordContentHandler | back to summary |
|---|---|
| private FormattedOutputStreamRecordContentHandler() | |
| characters | back to summary |
|---|---|
| public void characters(char[] ch, int start, int length) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of character data. The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information. The application must not attempt to read from the array outside of the specified range. Individual characters may consist of more than one Java
Your code should not assume that algorithms using
Note that some parsers will report whitespace in element
content using the
| |
| comment | back to summary |
|---|---|
| public void comment(char[] ch, int start, int length) throws SAXException Overrides org. Implements org. Doc from org. Report an XML comment anywhere in the document. This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read). Comments in the DTD must be properly nested inside start/endDTD and start/endEntity events (if used).
| |
| endElement | back to summary |
|---|---|
| public void endElement(String namespaceURI, String localName, String qName) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the end of an element. The SAX parser will invoke this method at the end of every
element in the XML document; there will be a corresponding
For information on the names, see startElement.
| |
| startElement | back to summary |
|---|---|
| public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the beginning of an element. The Parser will invoke this method at the beginning of every
element in the XML document; there will be a corresponding
This event allows up to three name components for each element:
Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes properties:
Note that the attribute list provided will contain only
attributes with explicit values (specified or defaulted):
#IMPLIED attributes will be omitted. The attribute list
will contain attributes used for Namespace declarations
(xmlns* attributes) only if the
Like
| |