public class JSONFormattedWriterRecord extends JSONWriterRecord
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);
XMLMarshaller
MarshalRecord.CycleDetectionStack<E>
XMLRecord.Nil
DEFAULT_ATTRIBUTE_GROUP, NIL
Constructor and Description |
---|
JSONFormattedWriterRecord() |
JSONFormattedWriterRecord(java.io.OutputStream outputStream) |
JSONFormattedWriterRecord(java.io.OutputStream outputStream,
java.lang.String callbackName) |
JSONFormattedWriterRecord(java.io.Writer writer) |
JSONFormattedWriterRecord(java.io.Writer writer,
java.lang.String callbackName) |
Modifier and Type | Method and Description |
---|---|
void |
characters(java.lang.String value)
INTERNAL:
|
void |
element(XPathFragment frag)
INTERNAL:
|
void |
endCollection()
This method is used to inform the MarshalRecord that it is done receiving
element events that are part of a collection.
|
void |
endDocument()
INTERNAL:
|
void |
endElement(XPathFragment xPathFragment,
NamespaceResolver namespaceResolver)
INTERNAL:
|
void |
node(org.w3c.dom.Node node,
NamespaceResolver namespaceResolver)
Receive notification of a node.
|
void |
openStartElement(XPathFragment xPathFragment,
NamespaceResolver namespaceResolver)
INTERNAL:
|
void |
startCollection()
This method is used to inform the MarshalRecord that the element events
it is about to receive are part of a collection.
|
void |
startDocument(java.lang.String encoding,
java.lang.String version)
INTERNAL:
|
attribute, attribute, attribute, cdata, characters, characters, characters, closeStartElement, defaultNamespaceDeclaration, emptyAttribute, emptyCollection, emptyComplex, emptySimple, endPrefixMappings, flush, forceValueWrapper, getNamespaceSeparator, getTextWrapperFragment, getWriter, isWrapperAsCollectionName, marshalWithoutRootElement, namespaceDeclaration, namespaceDeclarations, nilComplex, nilSimple, node, setCallbackName, setMarshaller, setWriter, startPrefixMappings
add, addGroupingElement, afterContainmentMarshal, beforeContainmentMarshal, clear, closeStartGroupingElements, endPrefixMapping, getCurrentAttributeGroup, getCycleDetectionStack, getDocument, getDOM, getGroupingElements, getLocalName, getNamespaceURI, getPositionalNodes, getValueToWrite, openStartGroupingElements, popAttributeGroup, predicateAttribute, pushAttributeGroup, put, removeGroupingElement, setGroupingElement, setSession, startPrefixMapping, transformToXML, writeHeader
addExtraNamespacesToNamespaceResolver, addXsiTypeAndClassIndicatorIfRequired, addXsiTypeAndClassIndicatorIfRequired, attributeWithoutQName, getConversionManager, getLeafElementType, getMarshaller, getNamespaceResolver, getOwningObject, getSession, hasCustomNamespaceMapper, hasEqualNamespaceResolvers, isNamespaceAware, isXOPPackage, removeExtraNamespacesFromNamespaceResolver, resolveNamespacePrefix, setCustomNamespaceMapper, setEqualNamespaceResolvers, setLeafElementType, setLeafElementType, setNamespaceResolver, setOwningObject, setXOPPackage, writeXsiTypeAttribute, writeXsiTypeAttribute
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
attributeWithoutQName, hasCustomNamespaceMapper, isXOPPackage, removeExtraNamespacesFromNamespaceResolver, setLeafElementType
addExtraNamespacesToNamespaceResolver, addXsiTypeAndClassIndicatorIfRequired, addXsiTypeAndClassIndicatorIfRequired, getLeafElementType, getMarshaller, getNamespaceResolver, getOwningObject, hasEqualNamespaceResolvers, isNamespaceAware, resolveNamespacePrefix, setCustomNamespaceMapper, setEqualNamespaceResolvers, setLeafElementType, setNamespaceResolver, setOwningObject, setXOPPackage, writeXsiTypeAttribute, writeXsiTypeAttribute
getConversionManager, getSession
public JSONFormattedWriterRecord()
public JSONFormattedWriterRecord(java.io.OutputStream outputStream)
public JSONFormattedWriterRecord(java.io.OutputStream outputStream, java.lang.String callbackName)
public JSONFormattedWriterRecord(java.io.Writer writer)
public JSONFormattedWriterRecord(java.io.Writer writer, java.lang.String callbackName)
public void startDocument(java.lang.String encoding, java.lang.String version)
JSONWriterRecord
startDocument
in class JSONWriterRecord
encoding
- The XML document will be encoded using this encoding.version
- This specifies the version of XML.public void endDocument()
endDocument
in class JSONWriterRecord
public void openStartElement(XPathFragment xPathFragment, NamespaceResolver namespaceResolver)
openStartElement
in interface MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>
openStartElement
in class JSONWriterRecord
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).public void element(XPathFragment frag)
element
in class JSONWriterRecord
frag
- The XPathFragment of the elementpublic void endElement(XPathFragment xPathFragment, NamespaceResolver namespaceResolver)
endElement
in interface MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>
endElement
in class JSONWriterRecord
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).public void startCollection()
MarshalRecord
startCollection
in interface MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>
startCollection
in class JSONWriterRecord
MarshalRecord.endCollection()
public void endCollection()
MarshalRecord
endCollection
in interface MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>
endCollection
in class JSONWriterRecord
MarshalRecord.startCollection()
public void characters(java.lang.String value)
characters
in interface MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>
characters
in class JSONWriterRecord
value
- This is the entire value of the text node.public void node(org.w3c.dom.Node node, NamespaceResolver namespaceResolver)
node
in interface MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>
node
in class MarshalRecord<XMLMarshaller>
node
- The Node to be added to the documentnamespaceResolver
- The NamespaceResolver can be used to resolve the
namespace URI/prefix of the nodeEclipseLink 2.6.3, "build v20160428-59c81c5" API Reference