Use this type of MarshalRecord when the marshal target is a Writer and the JSON should be formatted with carriage returns and indenting.
XMLContext xmlContext = new XMLContext("session-name");
XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
JSONFormattedWriterRecord jsonFormattedRecord = new JSONFormattedWriterRecord();
jsonFormattedWriterRecord.setWriter(myWriter);
xmlMarshaller.marshal(myObject, jsonFormattedWriterRecord);
If the marshal(Writer) and setMediaType(MediaType.APPLICATION_JSON) and setFormattedOutput(true) method is called on XMLMarshaller, then the Writer is automatically wrapped in a JSONFormattedWriterRecord.
XMLContext xmlContext = new XMLContext("session-name");
XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
xmlMarshaller.setMediaType(MediaType.APPLICATION_JSON);
xmlMarshaller.setFormattedOutput(true);
xmlMarshaller.marshal(myObject, myWriter);
org.eclipse.persistence.oxm.XMLMarshaller
| Modifier and Type | Class and Description |
|---|---|
| private class | JSONFormattedWriterRecord.JSONFormattedWriterRecordContentHandler
This class will typically be used in conjunction with an XMLFragmentReader. |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private int | |
| private String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | characters(String
This is the entire value of the text node. value)Overrides org. Implements org. |
| protected void | |
| public void | element(XPathFragment<XML_FIELD extends Field>
The XPathFragment of the element frag)Overrides org. |
| public void | endCollection()
Overrides org. Implements 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. |
| protected void | |
| 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)Overrides org. Implements 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. |
| public void | startCollection()
Overrides org. Implements org. |
| 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 String | |
| protected void | writeKey(XPathFragment<XML_FIELD extends Field> xPathFragment)
Overrides org. |
| protected void | |
| protected void |
| isLastEventText | back to summary |
|---|---|
| private boolean isLastEventText | |
| numberOfTabs | back to summary |
|---|---|
| private int numberOfTabs | |
| tab | back to summary |
|---|---|
| private String tab | |
| JSONFormattedWriterRecord | back to summary |
|---|---|
| public JSONFormattedWriterRecord() | |
| JSONFormattedWriterRecord | back to summary |
|---|---|
| public JSONFormattedWriterRecord(OutputStream outputStream) | |
| JSONFormattedWriterRecord | back to summary |
|---|---|
| public JSONFormattedWriterRecord(OutputStream outputStream, String callbackName) | |
| JSONFormattedWriterRecord | back to summary |
|---|---|
| public JSONFormattedWriterRecord(Writer writer) | |
| JSONFormattedWriterRecord | back to summary |
|---|---|
| public JSONFormattedWriterRecord(Writer writer, String callbackName) | |
| characters | back to summary |
|---|---|
| public void characters(String value) Overrides org. Implements org. INTERNAL:
| |
| closeComplex | back to summary |
|---|---|
| protected void closeComplex() throws IOException Overrides org.
| |
| element | back to summary |
|---|---|
| public void element(XPathFragment<XML_FIELD extends Field> frag) Overrides org. INTERNAL:
| |
| endCollection | back to summary |
|---|---|
| public void endCollection() Overrides org. Implements org. Doc from org. This method is used to inform the MarshalRecord that it is done receiving element events that are part of a collection.
| |
| 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:
| |
| endEmptyCollection | back to summary |
|---|---|
| protected void endEmptyCollection() Overrides org.
| |
| node | back to summary |
|---|---|
| public void node(Node node, NamespaceResolver namespaceResolver) Overrides org. Implements 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:
| |
| startCollection | back to summary |
|---|---|
| public void startCollection() Overrides org. Implements org. Doc from org. This method is used to inform the MarshalRecord that the element events it is about to receive are part of a collection.
| |
| startDocument | back to summary |
|---|---|
| public void startDocument(String encoding, String version) Overrides org. Doc from org. INTERNAL:
| |
| tab | back to summary |
|---|---|
| private String tab() | |
| writeKey | back to summary |
|---|---|
| protected void writeKey(XPathFragment<XML_FIELD extends Field> xPathFragment) throws IOException Overrides org.
| |
| writeListSeparator | back to summary |
|---|---|
| protected void writeListSeparator() throws IOException Overrides org.
| |
| writeSeparator | back to summary |
|---|---|
| protected void writeSeparator() throws IOException Overrides org.
| |
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 | 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. |
| JSONFormattedWriterRecordContentHandler | back to summary |
|---|---|
| private JSONFormattedWriterRecordContentHandler() | |
| 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.
| |