Class DefaultXmlPrettyPrinter
- All Implemented Interfaces:
PrettyPrinter,Instantiatable<DefaultXmlPrettyPrinter>,XmlPrettyPrinter,Serializable
Note that only a subset of methods of PrettyPrinter actually
get called by ToXmlGenerator; because of this, implementation
is bit briefer (and uglier...).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface that defines objects that can produce indentation used to separate object entries and array values. -
Field Summary
Fields inherited from interface com.fasterxml.jackson.core.PrettyPrinter
DEFAULT_ROOT_VALUE_SEPARATOR, DEFAULT_SEPARATORS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMethod called after array start marker has been output, and right before the first value is to be output.voidMethod called after object start marker has been output, and right before the field name of the first entry is to be output.Method called to ensure that we have a non-blueprint object to use; it is either this object (if stateless), or a newly created object with separate state.voidvoidwithCustomNewLine(String newLine) Sets custom new-line.voidMethod called after an array value has been completely output, and before another value is to be output.voidwriteEndArray(JsonGenerator gen, int nrOfValues) Method called after an Array value has been completely output (minus closing bracket).voidwriteEndElement(org.codehaus.stax2.XMLStreamWriter2 sw, int nrOfEntries) Method for forcibly writing an end element, without going through Jackson generator (and thus, without updating currently active element stack)voidwriteEndObject(JsonGenerator gen, int nrOfEntries) Method called after an Object value has been completely output (minus closing curly bracket).voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, boolean value) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, char[] buffer, int offset, int len, boolean isCData) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, double value) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, float value) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, int value) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, long value) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, String text, boolean isCData) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, BigDecimal value) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, BigInteger value) voidwriteLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, org.codehaus.stax2.typed.Base64Variant base64variant, byte[] data, int offset, int len) voidwriteLeafNullElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName) voidwriteLeafXsiNilElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName) voidMethod called after an Object entry (field:value) has been completely output, and before another value is to be output.voidMethod called after an object field has been output, but before the value is output.voidwritePrologLinefeed(org.codehaus.stax2.XMLStreamWriter2 sw) Method for trying to write a linefeed to separate entities outside of the root element (that is, in prolog or epilog), most often called to separate XML declaration from the root element.voidMethod called after a root-level value has been completely output, and before another value is to be output.voidMethod called when an Array value is to be output, before any member/child values are output.voidwriteStartElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName) Method for forcibly writing a start element, without going through Jackson generator (and thus, without updating currently active element stack)voidMethod called when an Object value is to be output, before any fields are output.
-
Constructor Details
-
DefaultXmlPrettyPrinter
public DefaultXmlPrettyPrinter()
-
-
Method Details
-
indentArraysWith
-
indentObjectsWith
-
withCustomNewLine
Sets custom new-line.- Since:
- 2.15
-
createInstance
Description copied from interface:InstantiatableMethod called to ensure that we have a non-blueprint object to use; it is either this object (if stateless), or a newly created object with separate state.- Specified by:
createInstancein interfaceInstantiatable<DefaultXmlPrettyPrinter>- Returns:
- Actual instance to use
-
writeRootValueSeparator
Description copied from interface:PrettyPrinterMethod called after a root-level value has been completely output, and before another value is to be output.Default handling (without pretty-printing) will output a space, to allow values to be parsed correctly. Pretty-printer is to output some other suitable and nice-looking separator (tab(s), space(s), linefeed(s) or any combination thereof).
- Specified by:
writeRootValueSeparatorin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
beforeArrayValues
Description copied from interface:PrettyPrinterMethod called after array start marker has been output, and right before the first value is to be output. It is not called for arrays with no values.Default handling does not output anything, but pretty-printer is free to add any white space decoration.
- Specified by:
beforeArrayValuesin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
writeStartArray
Description copied from interface:PrettyPrinterMethod called when an Array value is to be output, before any member/child values are output.Default handling (without pretty-printing) will output the opening bracket. Pretty-printer is to output a bracket as well, but can surround that with other (white-space) decoration.
- Specified by:
writeStartArrayin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
writeArrayValueSeparator
Description copied from interface:PrettyPrinterMethod called after an array value has been completely output, and before another value is to be output.Default handling (without pretty-printing) will output a single comma to separate the two. Pretty-printer is to output a comma as well, but can surround that with other (white-space) decoration.
- Specified by:
writeArrayValueSeparatorin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
writeEndArray
Description copied from interface:PrettyPrinterMethod called after an Array value has been completely output (minus closing bracket).Default handling (without pretty-printing) will output the closing bracket. Pretty-printer is to output a bracket as well, but can surround that with other (white-space) decoration.
- Specified by:
writeEndArrayin interfacePrettyPrinter- Parameters:
gen- Generator used for outputnrOfValues- Number of direct members of the array that have been output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
beforeObjectEntries
Description copied from interface:PrettyPrinterMethod called after object start marker has been output, and right before the field name of the first entry is to be output. It is not called for objects without entries.Default handling does not output anything, but pretty-printer is free to add any white space decoration.
- Specified by:
beforeObjectEntriesin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layerJsonGenerationException
-
writeStartObject
Description copied from interface:PrettyPrinterMethod called when an Object value is to be output, before any fields are output.Default handling (without pretty-printing) will output the opening curly bracket. Pretty-printer is to output a curly bracket as well, but can surround that with other (white-space) decoration.
- Specified by:
writeStartObjectin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
writeObjectEntrySeparator
Description copied from interface:PrettyPrinterMethod called after an Object entry (field:value) has been completely output, and before another value is to be output.Default handling (without pretty-printing) will output a single comma to separate the two. Pretty-printer is to output a comma as well, but can surround that with other (white-space) decoration.
- Specified by:
writeObjectEntrySeparatorin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
writeObjectFieldValueSeparator
Description copied from interface:PrettyPrinterMethod called after an object field has been output, but before the value is output.Default handling (without pretty-printing) will output a single colon to separate the two. Pretty-printer is to output a colon as well, but can surround that with other (white-space) decoration.
- Specified by:
writeObjectFieldValueSeparatorin interfacePrettyPrinter- Parameters:
gen- Generator used for output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
writeEndObject
Description copied from interface:PrettyPrinterMethod called after an Object value has been completely output (minus closing curly bracket).Default handling (without pretty-printing) will output the closing curly bracket. Pretty-printer is to output a curly bracket as well, but can surround that with other (white-space) decoration.
- Specified by:
writeEndObjectin interfacePrettyPrinter- Parameters:
gen- Generator used for outputnrOfEntries- Number of direct members of the Object that have been output- Throws:
IOException- if there is either an underlying I/O problem or encoding issue at format layer
-
writeStartElement
public void writeStartElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName) throws XMLStreamException Description copied from interface:XmlPrettyPrinterMethod for forcibly writing a start element, without going through Jackson generator (and thus, without updating currently active element stack)- Specified by:
writeStartElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeEndElement
public void writeEndElement(org.codehaus.stax2.XMLStreamWriter2 sw, int nrOfEntries) throws XMLStreamException Description copied from interface:XmlPrettyPrinterMethod for forcibly writing an end element, without going through Jackson generator (and thus, without updating currently active element stack)- Specified by:
writeEndElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, String text, boolean isCData) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, char[] buffer, int offset, int len, boolean isCData) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, boolean value) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, int value) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, long value) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, double value) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, float value) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, BigInteger value) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, BigDecimal value) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafElement
public void writeLeafElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName, org.codehaus.stax2.typed.Base64Variant base64variant, byte[] data, int offset, int len) throws XMLStreamException - Specified by:
writeLeafElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafNullElement
public void writeLeafNullElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName) throws XMLStreamException - Specified by:
writeLeafNullElementin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-
writeLeafXsiNilElement
public void writeLeafXsiNilElement(org.codehaus.stax2.XMLStreamWriter2 sw, String nsURI, String localName) throws XMLStreamException - Throws:
XMLStreamException
-
writePrologLinefeed
Description copied from interface:XmlPrettyPrinterMethod for trying to write a linefeed to separate entities outside of the root element (that is, in prolog or epilog), most often called to separate XML declaration from the root element.- Specified by:
writePrologLinefeedin interfaceXmlPrettyPrinter- Throws:
XMLStreamException
-