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.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | ToXmlGenerator.
Enumeration that defines all togglable extra XML-specific features |
| Modifier and Type | Field and Description |
|---|---|
| protected LinkedList | _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
|
| protected boolean | _initialized
Marker set when |
| protected XmlNameProcessor | _nameProcessor
Escapes names with invalid XML characters |
| protected XmlNameProcessor. | _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 |
| protected final StreamWriteConstraints | |
| protected 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... |
| Access | Constructor and Description |
|---|---|
| public | ToXmlGenerator(IOContext ctxt, int stdFeatures, int xmlFeatures, ObjectCodec codec, XMLStreamWriter sw, XmlNameProcessor nameProcessor)
|
| Modifier and Type | Method and Description |
|---|---|
| protected PrettyPrinter | _constructDefaultPrettyPrinter()
Overrides com. Overridable factory method called to instantiate an appropriate |
| public final void | |
| public final void | |
| protected void | _releaseBuffers()
Implements abstract com. 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
Additional message used for generating exception message
if value output is NOT legal in current generator output state. typeMsg)Implements abstract com. 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 boolean | canWriteFormattedNumbers()
Overrides com. Introspection method to call to check whether it is possible
to write numbers using |
| 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 void | close()
Overrides com. Implements java. Method called to close this generator, so that no more content can be written. |
| public ToXmlGenerator | |
| public ToXmlGenerator | |
| public ToXmlGenerator | |
| public void | finishWrappedValue(QName wrapperName, QName wrappedName)
Method called after a structured collection output has completed |
| public void | flush()
Implements abstract com. Implements java. Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well. |
| public int | getFormatFeatures()
Overrides com. Bulk access method for getting state of all |
| public int | getOutputBuffered()
Overrides com. Stax2 does not expose buffered content amount, so we can only return
|
| public Object | getOutputTarget()
Overrides com. Method that can be used to get access to object that is used
as target for generated output; this is usually either
|
| public XMLStreamWriter | |
| public JacksonFeatureSet | getWriteCapabilities()
Overrides com. Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly). |
| protected void | |
| public void | |
| public boolean | |
| public final boolean | |
| public JsonGenerator | overrideFormatFeatures(int
Bit mask of set/clear state for features to change values, int Bit mask of features to change mask)Overrides com. Bulk set method for (re)setting states of |
| public void | |
| public void | |
| public void | |
| public final void | |
| public final boolean | setNextNameIfMissing(QName name)
Method that does same as |
| public JsonGenerator | setPrettyPrinter(PrettyPrinter
PrettyPrinter to assign, if any; null if noneOverrides com. Method for setting a custom pretty printer, which is usually used to add indentation for improved human readability. |
| 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 StreamWriteConstraints | streamWriteConstraints()
Overrides com. Get the constraints to apply when performing streaming writes. |
| private byte[] | |
| private byte[] | |
| public void | writeBinary(Base64Variant
Base64 variant to use: defines details such as
whether padding is used (and if so, using which character);
what is the maximum line length before adding linefeed,
and also the underlying alphabet to use. b64variant, byte[] Buffer that contains binary data to write data, int Offset in offset, int data of the first byte of data to writeLength of data to write len)Implements abstract com. 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
Base64 variant to use b64variant, InputStream InputStream to use for reading binary data to write.
Will not be closed after successful write operation data, int (optional) number of bytes that will be available;
or -1 to be indicate it is not known.
If a positive length is given, dataLength)data MUST provide at least
that many bytes: if not, an exception will be thrown.
Note that implementations
need not support cases where length is not known in advance; this
depends on underlying data format: JSON output does NOT require length,
other formats may.Overrides com. Method similar to |
| public void | writeBoolean(boolean
Boolean value to write value)Implements abstract com. Method for outputting literal JSON boolean value (one of Strings 'true' and 'false'). |
| public final void | writeEndArray()
Implements abstract com. Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled). |
| public final void | writeEndObject()
Implements abstract com. Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled). |
| public void | writeFieldName(SerializableString
Field name to write name)Overrides com. Method similar to |
| public final void | writeFieldName(String
Field name to write name)Implements abstract com. Method for writing a field 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 void | writeNull()
Implements abstract com. Method for outputting literal JSON null value. |
| public void | writeNumber(int
Number value to write i)Implements abstract com. Method for outputting given value as JSON number. |
| public void | writeNumber(long
Number value to write l)Implements abstract com. Method for outputting given value as JSON number. |
| public void | writeNumber(double
Number value to write d)Implements abstract com. Method for outputting indicate JSON numeric value. |
| public void | writeNumber(float
Number value to write f)Implements abstract com. Method for outputting indicate JSON numeric value. |
| public void | writeNumber(BigDecimal
Number value to write dec)Implements abstract com. Method for outputting indicate JSON numeric value. |
| public void | writeNumber(BigInteger
Number value to write value)Implements abstract com. Method for outputting given value as JSON number. |
| public void | writeNumber(String
Textual (possibly formatted) number representation to write encodedValue)Implements abstract com. Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types. |
| public void | writeRaw(String
Textual contents to include as-is in output. text)Implements abstract com. 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 void | writeRaw(String
String that has contents to include as-is in output text, int Offset within offset, int text of the first character to outputLength of content (from len)text, starting at offset offset) to outputImplements abstract com. 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 void | writeRaw(char[]
Buffer that has contents to include as-is in output text, int Offset within offset, int text of the first character to outputLength of content (from len)text, starting at offset offset) to outputImplements abstract com. 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 void | writeRaw(char
Character to included in output c)Implements abstract com. 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 void | writeRawUTF8String(byte[]
Buffer that contains String value to write text, int Offset in offset, int buffer of the first byte of String value to writeLength of the String value (in characters) to write length)Implements abstract com. Method similar to |
| public void | writeRawValue(String
Textual contents to included in output text)Overrides com. 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 void | writeRawValue(String text, int offset, int len)
Overrides com.
|
| public void | writeRawValue(char[] text, int offset, int len)
Overrides com.
|
| public void | writeRawValue(SerializableString
Pre-encoded textual contents to included in output text)Overrides com. Method similar to |
| public void | |
| public final void | writeStartArray()
Implements abstract com. 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 final void | writeStartObject()
Implements abstract com. Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled). |
| private void | |
| public void | writeString(String
Text value to write text)Implements abstract com. Method for outputting a String value. |
| public void | writeString(char[]
Buffer that contains String value to write text, int Offset in offset, int buffer of the first character of String value to writeLength of the String value (in characters) to write len)Implements abstract com. Method for outputting a String value. |
| public void | writeString(SerializableString
Pre-encoded String value to write text)Overrides com. Method similar to |
| public final void | writeStringField(String
Name of the field to write fieldName, String String value of the field to write value)Overrides com. Convenience method for outputting a field entry ("member") that has a String value. |
| public void | writeUTF8String(byte[]
Buffer that contains String value to write text, int Offset in offset, int buffer of the first byte of String value to writeLength of the String value (in characters) to write length)Implements abstract com. Method similar to |