Class DefaultXmlPrettyPrinter

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  DefaultXmlPrettyPrinter.Indenter
      Interface that defines objects that can produce indentation used to separate object entries and array values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beforeArrayValues​(JsonGenerator gen)
      Method called after array start marker has been output, and right before the first value is to be output.
      void beforeObjectEntries​(JsonGenerator gen)
      Method called after object start marker has been output, and right before the field name of the first entry is to be output.
      DefaultXmlPrettyPrinter createInstance()
      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.
      void indentArraysWith​(DefaultXmlPrettyPrinter.Indenter i)  
      void indentObjectsWith​(DefaultXmlPrettyPrinter.Indenter i)  
      DefaultXmlPrettyPrinter withCustomNewLine​(java.lang.String newLine)
      Sets custom new-line.
      void writeArrayValueSeparator​(JsonGenerator gen)
      Method called after an array value has been completely output, and before another value is to be output.
      void writeEndArray​(JsonGenerator gen, int nrOfValues)
      Method called after an Array value has been completely output (minus closing bracket).
      void writeEndElement​(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)
      void writeEndObject​(JsonGenerator gen, int nrOfEntries)
      Method called after an Object value has been completely output (minus closing curly bracket).
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, boolean value)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, char[] buffer, int offset, int len, boolean isCData)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, double value)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, float value)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, int value)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, long value)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, java.lang.String text, boolean isCData)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, java.math.BigDecimal value)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, java.math.BigInteger value)  
      void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName, org.codehaus.stax2.typed.Base64Variant base64variant, byte[] data, int offset, int len)  
      void writeLeafNullElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName)  
      void writeLeafXsiNilElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName)  
      void writeObjectEntrySeparator​(JsonGenerator gen)
      Method called after an Object entry (field:value) has been completely output, and before another value is to be output.
      void writeObjectFieldValueSeparator​(JsonGenerator gen)
      Method called after an object field has been output, but before the value is output.
      void writePrologLinefeed​(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.
      void writeRootValueSeparator​(JsonGenerator gen)
      Method called after a root-level value has been completely output, and before another value is to be output.
      void writeStartArray​(JsonGenerator gen)
      Method called when an Array value is to be output, before any member/child values are output.
      void writeStartElement​(org.codehaus.stax2.XMLStreamWriter2 sw, java.lang.String nsURI, java.lang.String localName)
      Method for forcibly writing a start element, without going through Jackson generator (and thus, without updating currently active element stack)
      void writeStartObject​(JsonGenerator gen)
      Method called when an Object value is to be output, before any fields are output.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultXmlPrettyPrinter

        public DefaultXmlPrettyPrinter()
    • Method Detail

      • withCustomNewLine

        public DefaultXmlPrettyPrinter withCustomNewLine​(java.lang.String newLine)
        Sets custom new-line.
        Since:
        2.15
      • writeRootValueSeparator

        public void writeRootValueSeparator​(JsonGenerator gen)
                                     throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeRootValueSeparator in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • beforeArrayValues

        public void beforeArrayValues​(JsonGenerator gen)
                               throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        beforeArrayValues in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • writeStartArray

        public void writeStartArray​(JsonGenerator gen)
                             throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeStartArray in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • writeArrayValueSeparator

        public void writeArrayValueSeparator​(JsonGenerator gen)
                                      throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeArrayValueSeparator in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • writeEndArray

        public void writeEndArray​(JsonGenerator gen,
                                  int nrOfValues)
                           throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeEndArray in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        nrOfValues - Number of direct members of the array that have been output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • beforeObjectEntries

        public void beforeObjectEntries​(JsonGenerator gen)
                                 throws java.io.IOException,
                                        JsonGenerationException
        Description copied from interface: PrettyPrinter
        Method 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:
        beforeObjectEntries in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
        JsonGenerationException
      • writeStartObject

        public void writeStartObject​(JsonGenerator gen)
                              throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeStartObject in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • writeObjectEntrySeparator

        public void writeObjectEntrySeparator​(JsonGenerator gen)
                                       throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeObjectEntrySeparator in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • writeObjectFieldValueSeparator

        public void writeObjectFieldValueSeparator​(JsonGenerator gen)
                                            throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeObjectFieldValueSeparator in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        Throws:
        java.io.IOException - if there is either an underlying I/O problem or encoding issue at format layer
      • writeEndObject

        public void writeEndObject​(JsonGenerator gen,
                                   int nrOfEntries)
                            throws java.io.IOException
        Description copied from interface: PrettyPrinter
        Method 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:
        writeEndObject in interface PrettyPrinter
        Parameters:
        gen - Generator used for output
        nrOfEntries - Number of direct members of the Object that have been output
        Throws:
        java.io.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,
                                      java.lang.String nsURI,
                                      java.lang.String localName)
                               throws javax.xml.stream.XMLStreamException
        Description copied from interface: XmlPrettyPrinter
        Method for forcibly writing a start element, without going through Jackson generator (and thus, without updating currently active element stack)
        Specified by:
        writeStartElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEndElement

        public void writeEndElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                    int nrOfEntries)
                             throws javax.xml.stream.XMLStreamException
        Description copied from interface: XmlPrettyPrinter
        Method for forcibly writing an end element, without going through Jackson generator (and thus, without updating currently active element stack)
        Specified by:
        writeEndElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     java.lang.String text,
                                     boolean isCData)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     char[] buffer,
                                     int offset,
                                     int len,
                                     boolean isCData)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     boolean value)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     int value)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     long value)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     double value)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     float value)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     java.math.BigInteger value)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     java.math.BigDecimal value)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafElement

        public void writeLeafElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                     java.lang.String nsURI,
                                     java.lang.String localName,
                                     org.codehaus.stax2.typed.Base64Variant base64variant,
                                     byte[] data,
                                     int offset,
                                     int len)
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafNullElement

        public void writeLeafNullElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                         java.lang.String nsURI,
                                         java.lang.String localName)
                                  throws javax.xml.stream.XMLStreamException
        Specified by:
        writeLeafNullElement in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeLeafXsiNilElement

        public void writeLeafXsiNilElement​(org.codehaus.stax2.XMLStreamWriter2 sw,
                                           java.lang.String nsURI,
                                           java.lang.String localName)
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • writePrologLinefeed

        public void writePrologLinefeed​(org.codehaus.stax2.XMLStreamWriter2 sw)
                                 throws javax.xml.stream.XMLStreamException
        Description copied from interface: XmlPrettyPrinter
        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.
        Specified by:
        writePrologLinefeed in interface XmlPrettyPrinter
        Throws:
        javax.xml.stream.XMLStreamException