Top Description Fields Constructors Methods
tools.jackson.dataformat.xml.ser

public Class ToXmlGenerator

extends GeneratorBase
Class Inheritance
Imports
java.io.*, java.math.BigDecimal, .BigInteger, java.util.*, javax.xml.XMLConstants, javax.xml.namespace.QName, javax.xml.stream.XMLStreamException, .XMLStreamWriter, org.codehaus.stax2.XMLStreamWriter2, org.codehaus.stax2.ri.Stax2WriterAdapter, tools.jackson.core.*, tools.jackson.core.base.GeneratorBase, tools.jackson.core.exc.StreamWriteException, tools.jackson.core.io.IOContext, tools.jackson.core.json.DupDetector, tools.jackson.core.util.SimpleStreamWriteContext, .JacksonFeatureSet, tools.jackson.dataformat.xml.XmlPrettyPrinter, .XmlWriteFeature, .XmlNameProcessor, .PackageVersion, tools.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter, .StaxUtil

JsonGenerator that outputs JAXB-style XML output instead of JSON content. Operation requires calling code (usually either standard Jackson serializers, or in some cases (like BeanSerializer) customized ones) to do additional configuration calls beyond regular JsonGenerator API, mostly to pass namespace information.

Field Summary

Modifier and TypeField and Description
protected LinkedList<QName>
_elementNameStack

To support proper serialization of arrays it is necessary to keep stack of element names, so that we can "revert" to earlier

protected int
_formatFeatures

Bit flag composed of bits that indicate which XmlWriteFeatures are enabled.

protected boolean
_initialized

Marker set when initGenerator() has been called or not.

protected XmlNameProcessor
_nameProcessor

Escapes names with invalid XML characters

protected XmlNameProcessor.XmlName
_nameToEncode

Reusable internal value object

protected boolean
_nextIsAttribute

Marker flag that indicates whether next name to write implies an attribute (true) or element (false)

protected boolean
_nextIsCData

Marker flag used to indicate that the next write of a (property) value should be as CData

protected boolean
_nextIsUnwrapped

Marker flag used to indicate that the next write of a (property) value should be done without using surrounding start/end elements.

protected QName
_nextName

Element or attribute name to use for next output call.

protected final XMLStreamWriter
protected final boolean
_stax2Emulation

Marker flag set if the underlying stream writer has to emulate Stax2 API: this is problematic if trying to use writeRaw calls.

protected SimpleStreamWriteContext
_streamWriteContext

Object that keeps track of the current contextual state of the generator.

protected final XmlPrettyPrinter
_xmlPrettyPrinter

We may need to use XML-specific indentation as well

protected final XMLStreamWriter2
protected static final String
DEFAULT_UNKNOWN_ELEMENT

If we support optional definition of element names, this is the element name to use...

Inherited from tools.jackson.core.base.GeneratorBase:
_closed_ioContext_objectWriteContext_streamWriteConstraints_streamWriteFeaturesDEFAULT_BINARY_WRITE_CAPABILITIESDEFAULT_TEXTUAL_WRITE_CAPABILITIESDEFAULT_WRITE_CAPABILITIESMAX_BIG_DECIMAL_SCALESURR1_FIRSTSURR1_LASTSURR2_FIRSTSURR2_LASTWRITE_BINARYWRITE_BOOLEANWRITE_NULLWRITE_NUMBERWRITE_RAWWRITE_STRING

Constructor Summary

AccessConstructor and Description
public
ToXmlGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, int streamWriteFeatures, int xmlFeatures, XMLStreamWriter sw, XmlPrettyPrinter pp, XmlNameProcessor nameProcessor)

Method Summary

Modifier and TypeMethod and Description
protected void
protected PrettyPrinter
_constructDefaultPrettyPrinter()

Overrides tools.jackson.core.base.GeneratorBase._constructDefaultPrettyPrinter.

Overridable factory method called to instantiate an appropriate PrettyPrinter for case of "just use the default one", when default pretty printer handling enabled.

public final void
public final void
protected void
_releaseBuffers()

Implements abstract tools.jackson.core.base.GeneratorBase._releaseBuffers.

Method called to release any buffers generator may be holding, once generator is being closed.

protected void
_reportUnimplementedStax2(String missingMethod)

Method called in case access to native Stax2 API implementation is required.

protected final void
_verifyValueWrite(String typeMsg)

Implements abstract tools.jackson.core.base.GeneratorBase._verifyValueWrite.

Method called before trying to write a value (scalar or structured), to verify that this is legal in current output state, as well as to output separators if and as necessary.

public final void
assignCurrentValue(Object v)

Implements abstract tools.jackson.core.JsonGenerator.assignCurrentValue.

Helper method, usually equivalent to: getOutputContext().assignCurrentValue(v); used to assign "current value" for the current context of this generator.

protected boolean
checkNextIsUnwrapped()

Method called to see if unwrapping is required; and if so, clear the flag (so further calls will return 'false' unless state is re-set)

public ToXmlGenerator
configure(XmlWriteFeature f, boolean state)

public final Object
currentValue()

Implements abstract tools.jackson.core.JsonGenerator.currentValue.

Helper method, usually equivalent to: getOutputContext().currentValue();

Note that "current value" is NOT populated (or used) by Streaming generator; it is only used by higher-level data-binding functionality.

public void
finishWrappedValue(QName wrapperName, QName wrappedName)

Method called after a structured collection output has completed

public void
flush()

Implements abstract tools.jackson.core.JsonGenerator.flush.

Implements java.io.Flushable.flush.

Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well.

public XmlPrettyPrinter
getPrettyPrinter()

Overrides tools.jackson.core.JsonGenerator.getPrettyPrinter.

Accessor for object that handles pretty-printing (usually additional white space to make results more human-readable) during output.

public XMLStreamWriter
getStaxWriter()

Method that allows application direct access to underlying Stax XMLStreamWriter.

protected void
public boolean
has(StreamWriteCapability capability)

Overrides tools.jackson.core.base.GeneratorBase.has.

Accessor for checking whether this generator has specified capability.

public void
initGenerator()

Method called before writing any other output, to optionally output XML declaration.

public boolean
public final boolean
public void
setNextIsAttribute(boolean isAttribute)

public void
setNextIsCData(boolean isCData)

public void
setNextIsUnwrapped(boolean isUnwrapped)

public final void
public final boolean
setNextNameIfMissing(QName name)

Method that does same as setNextName, unless a name has already been set.

public void
startWrappedValue(QName
Element used as wrapper around elements, if any (null if none)
wrapperName
,
QName
Element used around individual content items (can not be null)
wrappedName
)

Methdod called when a structured (collection, array, map) is being output.

public JacksonFeatureSet<StreamWriteCapability>
streamWriteCapabilities()

Implements abstract tools.jackson.core.JsonGenerator.streamWriteCapabilities.

Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly).

public final TokenStreamContext
streamWriteContext()

Implements abstract tools.jackson.core.JsonGenerator.streamWriteContext.

Accessor for context object that provides information about low-level logical position withing output token stream.

public int
streamWriteOutputBuffered()

Implements abstract tools.jackson.core.JsonGenerator.streamWriteOutputBuffered.

Stax2 does not expose buffered content amount, so we can only return -1 from here

public Object
streamWriteOutputTarget()

Implements abstract tools.jackson.core.JsonGenerator.streamWriteOutputTarget.

Method that can be used to get access to object that is used as target for generated output; this is usually either java.io.OutputStream or java.io.Writer, depending on what generator was constructed with.

private byte[]
toFullBuffer(byte[] data, int offset, int len)

private byte[]
toFullBuffer(InputStream data, final int len)

public Version
version()

Implements abstract tools.jackson.core.JsonGenerator.version.

Implements tools.jackson.core.Versioned.version.

Accessor for finding out version of the bundle that provided this generator instance.

public JsonGenerator
writeBinary(Base64Variant b64variant, byte[] data, int offset, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeBinary.

Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes).

public int
writeBinary(Base64Variant b64variant, InputStream data, int dataLength)

Overrides tools.jackson.core.base.GeneratorBase.writeBinary.

Method similar to writeBinary(Base64Variant, byte[], int, int), but where input is provided through a stream, allowing for incremental writes without holding the whole input in memory.

public JsonGenerator
writeBoolean(boolean value)

Implements abstract tools.jackson.core.JsonGenerator.writeBoolean.

Method for outputting literal JSON boolean value (one of Strings 'true' and 'false').

public JsonGenerator
writeEndArray()

Implements abstract tools.jackson.core.JsonGenerator.writeEndArray.

Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled).

public JsonGenerator
writeEndObject()

Implements abstract tools.jackson.core.JsonGenerator.writeEndObject.

Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled).

public JsonGenerator
writeName(SerializableString name)

Overrides tools.jackson.core.base.GeneratorBase.writeName.

Method similar to writeName(String), main difference being that it may perform better as some of processing (such as quoting of certain characters, or encoding into external encoding if supported by generator) can be done just once and reused for later calls.

public JsonGenerator
writeName(String name)

Implements abstract tools.jackson.core.JsonGenerator.writeName.

Method for writing an Object Property name (JSON String surrounded by double quotes: syntactically identical to a JSON String value), possibly decorated by white space if pretty-printing is enabled.

public JsonGenerator
writeNull()

Implements abstract tools.jackson.core.JsonGenerator.writeNull.

Method for outputting literal JSON null value.

public JsonGenerator
writeNumber(short v)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(int i)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(long l)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(double d)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting indicate JSON numeric value.

public JsonGenerator
writeNumber(float f)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting indicate JSON numeric value.

public JsonGenerator
writeNumber(BigDecimal dec)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting indicate JSON numeric value.

public JsonGenerator
writeNumber(BigInteger value)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(String encodedValue)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types.

public JsonGenerator
writePropertyId(long id)

Implements abstract tools.jackson.core.JsonGenerator.writePropertyId.

Alternative to writeName(String) that may be used in cases where Object Property key is of numeric type; usually where underlying format supports such notion (some binary formats do, unlike JSON).

public JsonGenerator
writeRaw(String text)

Implements abstract tools.jackson.core.JsonGenerator.writeRaw.

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public JsonGenerator
writeRaw(String text, int offset, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeRaw.

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public JsonGenerator
writeRaw(char[] text, int offset, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeRaw.

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public JsonGenerator
writeRaw(char c)

Implements abstract tools.jackson.core.JsonGenerator.writeRaw.

Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).

public JsonGenerator
writeRawUTF8String(byte[] text, int offset, int length)

Implements abstract tools.jackson.core.JsonGenerator.writeRawUTF8String.

Method similar to writeString(String) but that takes as its input a UTF-8 encoded String that is to be output as-is, without additional escaping (type of which depends on data format; backslashes for JSON).

public JsonGenerator
writeRawValue(String text)

Overrides tools.jackson.core.base.GeneratorBase.writeRawValue.

Method that will force generator to copy input text verbatim without any modifications, but assuming it must constitute a single legal JSON value (number, string, boolean, null, Array or List).

public JsonGenerator
public JsonGenerator
writeRawValue(char[] text, int offset, int len)

Overrides tools.jackson.core.base.GeneratorBase.writeRawValue.

public JsonGenerator
writeRawValue(SerializableString text)

Overrides tools.jackson.core.base.GeneratorBase.writeRawValue.

Method similar to writeRawValue(String), but potentially more efficient as it may be able to use pre-encoded content (similar to writeRaw(SerializableString).

public JsonGenerator
writeRepeatedPropertyName()

Trivial helper method called when to add a replicated wrapper name

public JsonGenerator
writeStartArray()

Implements abstract tools.jackson.core.JsonGenerator.writeStartArray.

Method for writing starting marker of a Array value (for JSON this is character '['; plus possible white space decoration if pretty-printing is enabled).

public JsonGenerator
writeStartArray(Object currValue)

Implements abstract tools.jackson.core.JsonGenerator.writeStartArray.

Method for writing start marker of an Array value, similar to writeStartArray(), but also specifying what is the Java object that the Array Object being written represents (if any); null may be passed if not known or not applicable.

public JsonGenerator
writeStartObject()

Implements abstract tools.jackson.core.JsonGenerator.writeStartObject.

Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled).

public JsonGenerator
writeStartObject(Object currValue)

Implements abstract tools.jackson.core.JsonGenerator.writeStartObject.

Method for writing starting marker of an Object value to represent the given Java Object value.

private void
writeStreamAsBinary(Base64Variant stax2base64v, InputStream data, int len)

public JsonGenerator
writeString(String text)

Implements abstract tools.jackson.core.JsonGenerator.writeString.

Method for outputting a String value.

public JsonGenerator
writeString(char[] text, int offset, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeString.

Method for outputting a String value.

public JsonGenerator
writeString(SerializableString text)

Overrides tools.jackson.core.base.GeneratorBase.writeString.

Method similar to writeString(String), but that takes SerializableString which can make this potentially more efficient to call as generator may be able to reuse quoted and/or encoded representation.

public JsonGenerator
writeUTF8String(byte[] text, int offset, int length)

Implements abstract tools.jackson.core.JsonGenerator.writeUTF8String.

Method similar to writeString(String) but that takes as its input a UTF-8 encoded String which has not been escaped using whatever escaping scheme data format requires (for JSON that is backslash-escaping for control characters and double-quotes; for other formats something else).

Inherited from tools.jackson.core.base.GeneratorBase:
_asString_checkRangeBoundsForByteArray_checkRangeBoundsForCharArray_checkRangeBoundsForString_decodeSurrogate_throwInternalcloseconfigureioContextisClosedisEnabledobjectWriteContextstreamWriteConstraintsstreamWriteFeatureswritePOJOwriteStartArraywriteStartObjectwriteStringwriteTree