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,
Serialized FormMarshalRecord.CycleDetectionStack<E>AbstractRecord.NoEntrynoEntry| Constructor and Description |
|---|
JSONFormattedWriterRecord() |
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, getNamespaceSeparator, getTextWrapperFragment, getWriter, isWrapperAsCollectionName, marshalWithoutRootElement, namespaceDeclaration, namespaceDeclarations, nilComplex, nilSimple, node, setCallbackName, setMarshaller, setWriter, startPrefixMappingsadd, addGroupingElement, afterContainmentMarshal, beforeContainmentMarshal, clear, closeStartGroupingElements, endPrefixMapping, getCycleDetectionStack, getDocument, getDOM, getGroupingElements, getLocalName, getNamespaceURI, getPositionalNodes, getValueToWrite, openStartGroupingElements, predicateAttribute, put, removeGroupingElement, setGroupingElement, setSession, startPrefixMapping, transformToXML, writeHeaderattributeWithoutQName, contains, get, get, getCurrentObject, getDocPresPolicy, getIndicatingNoEntry, getLeafElementType, getMarshaller, getNamespaceResolver, getOwningObject, getSession, getUnmarshaller, hasCustomNamespaceMapper, hasEqualNamespaceResolvers, isNamespaceAware, isXOPPackage, put, resolveNamespacePrefix, setCurrentObject, setCustomNamespaceMapper, setDocPresPolicy, setEqualNamespaceResolvers, setLeafElementType, setLeafElementType, setNamespaceResolver, setOwningObject, setUnmarshaller, setXOPPackageclone, containsKey, containsKey, containsKey, containsValue, elements, entrySet, get, getField, getFields, getIndicatingNoEntry, getValues, getValues, getValues, hasNullValueInFields, isEmpty, keys, keySet, mergeFrom, put, putAll, remove, remove, remove, replaceAt, setNullValueInFields, size, toString, valuespublic JSONFormattedWriterRecord()
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)
JSONWriterRecordstartDocument in class JSONWriterRecordencoding - The XML document will be encoded using this encoding.version - This specifies the version of XML.public void endDocument()
endDocument in class JSONWriterRecordpublic void openStartElement(XPathFragment xPathFragment, NamespaceResolver namespaceResolver)
openStartElement in class JSONWriterRecordxPathFragment - 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 JSONWriterRecordfrag - The XPathFragment of the elementpublic void endElement(XPathFragment xPathFragment, NamespaceResolver namespaceResolver)
endElement in class JSONWriterRecordxPathFragment - 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()
MarshalRecordstartCollection in class JSONWriterRecordendCollectionpublic void endCollection()
MarshalRecordendCollection in class JSONWriterRecordstartCollectionpublic void characters(java.lang.String value)
characters in class JSONWriterRecordvalue - This is the entire value of the text node.public void node(org.w3c.dom.Node node,
NamespaceResolver namespaceResolver)
node in class MarshalRecordnode - The Node to be added to the documentnamespaceResolver - The NamespaceResolver can be used to resolve the
namespace URI/prefix of the nodeEclipseLink 2.4.2, "build v20130514-5956486" API Reference