Top Description Inners Fields Constructors Methods
org.eclipse.persistence.oxm.record

public Class JSONFormattedWriterRecord

extends JSONWriterRecord
Class Inheritance
Imports
java.io.IOException, .OutputStream, .Writer, org.eclipse.persistence.exceptions.XMLMarshalException, org.eclipse.persistence.internal.oxm.Constants, .NamespaceResolver, .XPathFragment, org.eclipse.persistence.internal.oxm.record.XMLFragmentReader, org.w3c.dom.Attr, .Node, org.xml.sax.SAXException

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);

See Also
org.eclipse.persistence.oxm.XMLMarshaller

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
JSONFormattedWriterRecord.JSONFormattedWriterRecordContentHandler

This class will typically be used in conjunction with an XMLFragmentReader.

Field Summary

Modifier and TypeField and Description
private boolean
private int
private String
Inherited from org.eclipse.persistence.oxm.record.JSONWriterRecord:
attributePrefixcallbackNamecharacterEscapeHandlercharactersAllowedencoderisProcessingCDatalevelNULLwriter

Constructor Summary

AccessConstructor and Description
public
public
public
JSONFormattedWriterRecord(OutputStream outputStream, String callbackName)

public
public
JSONFormattedWriterRecord(Writer writer, String callbackName)

Method Summary

Modifier and TypeMethod and Description
public void
protected void
public void
element(XPathFragment<XML_FIELD extends Field>
The XPathFragment of the element
frag
)

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.element.

INTERNAL:
public void
endCollection()

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.endCollection.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.endCollection.

This method is used to inform the MarshalRecord that it is done receiving element events that are part of a collection.
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.eclipse.persistence.oxm.record.JSONWriterRecord.endElement.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.endElement.

INTERNAL:
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.eclipse.persistence.oxm.record.MarshalRecord.node.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.node.

Receive notification of a node.
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.eclipse.persistence.oxm.record.JSONWriterRecord.openStartElement.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.openStartElement.

INTERNAL:
public void
startCollection()

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.startCollection.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.startCollection.

This method is used to inform the MarshalRecord that the element events it is about to receive are part of a collection.
public void
startDocument(String
The XML document will be encoded using this encoding.
encoding
,
String
This specifies the version of XML.
version
)

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.startDocument.

INTERNAL:
private String
tab()

protected void
protected void
protected void
Inherited from org.eclipse.persistence.oxm.record.JSONWriterRecord:
attributeattributeattributecdatacharacterscharacterscharacterscloseStartElementdefaultNamespaceDeclarationemptyAttributeemptyCollectionemptyComplexemptySimpleendCallbackendPrefixMappingsflushforceValueWrappergetNamespaceSeparatorgetStringForQNamegetTextWrapperFragmentgetWriterisWrapperAsCollectionNamemarshalWithoutRootElementnamespaceDeclarationnamespaceDeclarationsnilComplexnilSimplenodesetCallbackNamesetMarshallersetWriterstartCallbackstartPrefixMappingswriteValue

Field Detail

isLastEventTextback to summary
private boolean isLastEventText
numberOfTabsback to summary
private int numberOfTabs
tabback to summary
private String tab

Constructor Detail

JSONFormattedWriterRecordback to summary
public JSONFormattedWriterRecord()
JSONFormattedWriterRecordback to summary
public JSONFormattedWriterRecord(OutputStream outputStream)
JSONFormattedWriterRecordback to summary
public JSONFormattedWriterRecord(OutputStream outputStream, String callbackName)
JSONFormattedWriterRecordback to summary
public JSONFormattedWriterRecord(Writer writer)
JSONFormattedWriterRecordback to summary
public JSONFormattedWriterRecord(Writer writer, String callbackName)

Method Detail

charactersback to summary
public void characters(String value)

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.characters.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.characters.

INTERNAL:

Parameters
value:String

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.characters.

This is the entire value of the text node.

Annotations
@Override
closeComplexback to summary
protected void closeComplex() throws IOException

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.closeComplex.

Annotations
@Override
elementback to summary
public void element(XPathFragment<XML_FIELD extends Field> frag)

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.element.

INTERNAL:

Parameters
frag:XPathFragment<XML_FIELD extends Field>

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.element.

The XPathFragment of the element

Annotations
@Override
endCollectionback to summary
public void endCollection()

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.endCollection.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.endCollection.

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.endCollection.

This method is used to inform the MarshalRecord that it is done receiving element events that are part of a collection.

Annotations
@Override
endDocumentback to summary
public void endDocument()

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.endDocument.

INTERNAL:

Annotations
@Override
endElementback to summary
public void endElement(XPathFragment<XML_FIELD extends Field> xPathFragment, NamespaceResolver namespaceResolver)

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.endElement.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.endElement.

INTERNAL:

Parameters
xPathFragment:XPathFragment<XML_FIELD extends Field>

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.endElement.

The XPathFragment contains the name and prefix information about the XML element being ended.

namespaceResolver:NamespaceResolver

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.endElement.

The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).

Annotations
@Override
endEmptyCollectionback to summary
protected void endEmptyCollection()

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.endEmptyCollection.

Annotations
@Override
nodeback to summary
public void node(Node node, NamespaceResolver namespaceResolver)

Overrides org.eclipse.persistence.oxm.record.MarshalRecord.node.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.node.

Receive notification of a node.

Parameters
node:Node

The Node to be added to the document

namespaceResolver:NamespaceResolver

The NamespaceResolver can be used to resolve the namespace URI/prefix of the node

Annotations
@Override
openStartElementback to summary
public void openStartElement(XPathFragment<XML_FIELD extends Field> xPathFragment, NamespaceResolver namespaceResolver)

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.openStartElement.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.openStartElement.

INTERNAL:

Parameters
xPathFragment:XPathFragment<XML_FIELD extends Field>

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.openStartElement.

The XPathFragment contains the name and prefix information about the XML element being ended.

namespaceResolver:NamespaceResolver

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.openStartElement.

The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).

Annotations
@Override
startCollectionback to summary
public void startCollection()

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.startCollection.

Implements org.eclipse.persistence.internal.oxm.record.MarshalRecord.startCollection.

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.startCollection.

This method is used to inform the MarshalRecord that the element events it is about to receive are part of a collection.

Annotations
@Override
startDocumentback to summary
public void startDocument(String encoding, String version)

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.startDocument.

Doc from org.eclipse.persistence.oxm.record.JSONWriterRecord.startDocument.

INTERNAL:

Parameters
encoding:String

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.startDocument.

The XML document will be encoded using this encoding.

version:String

Doc from org.eclipse.persistence.oxm.record.MarshalRecord.startDocument.

This specifies the version of XML.

Annotations
@Override
tabback to summary
private String tab()
writeKeyback to summary
protected void writeKey(XPathFragment<XML_FIELD extends Field> xPathFragment) throws IOException

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.writeKey.

Annotations
@Override
writeListSeparatorback to summary
protected void writeListSeparator() throws IOException

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.writeListSeparator.

Annotations
@Override
writeSeparatorback to summary
protected void writeSeparator() throws IOException

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.writeSeparator.

Annotations
@Override
org.eclipse.persistence.oxm.record back to summary

private Class JSONFormattedWriterRecord.JSONFormattedWriterRecordContentHandler

extends JSONWriterRecordContentHandler
Class Inheritance

This class will typically be used in conjunction with an XMLFragmentReader. The XMLFragmentReader will walk a given XMLFragment node and report events to this class - the event's data is then written to the enclosing class' writer.
See Also
org.eclipse.persistence.internal.oxm.record.XMLFragmentReader, org.eclipse.persistence.oxm.record.WriterRecord.WriterRecordContentHandler

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod 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.eclipse.persistence.oxm.record.JSONWriterRecord.JSONWriterRecordContentHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.
Inherited from org.eclipse.persistence.oxm.record.JSONWriterRecord.JSONWriterRecordContentHandler:
characterscharacterscommentendCDATAendDocumentendDTDendEntityendPrefixMappinghandleAttributesignorableWhitespaceprocessingInstructionsetDocumentLocatorsetNilskippedEntitystartCDATAstartDocumentstartDTDstartElementstartEntitystartPrefixMappingwriteCharacterswriteComment

Constructor Detail

JSONFormattedWriterRecordContentHandlerback to summary
private JSONFormattedWriterRecordContentHandler()

Method Detail

endElementback to summary
public void endElement(String namespaceURI, String localName, String qName) throws SAXException

Overrides org.eclipse.persistence.oxm.record.JSONWriterRecord.JSONWriterRecordContentHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Doc from org.xml.sax.ContentHandler.endElement.

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 startElement event for every endElement event (even when the element is empty).

For information on the names, see startElement.

Parameters
namespaceURI:String

the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed

localName:String

the local name (without prefix), or the empty string if Namespace processing is not being performed

qName:String

the qualified XML name (with prefix), or the empty string if qualified names are not available

Annotations
@Override
Exceptions
SAXException:
any SAX exception, possibly wrapping another exception