Class JacksonFactory.Log4jXmlPrettyPrinter

java.lang.Object
com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter
org.apache.logging.log4j.core.layout.JacksonFactory.Log4jXmlPrettyPrinter
All Implemented Interfaces:
com.fasterxml.jackson.core.PrettyPrinter, com.fasterxml.jackson.core.util.Instantiatable<com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter>, com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter, Serializable
Enclosing class:
JacksonFactory

static class JacksonFactory.Log4jXmlPrettyPrinter extends com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter
When <Event>s are written into a XML file; the "Event" object is not the root element, but an element named <Events> created using XmlLayout.getHeader() and XmlLayout.getFooter() methods.

DefaultXmlPrettyPrinter is used to print the Event object into XML; hence it assumes <Event> tag as the root element, so it prints the <Event> tag without any indentation. To add an indentation to the <Event> tag; hence an additional indentation for any sub-elements, this class is written. As an additional task, to avoid the blank line printed after the ending </Event> tag, writePrologLinefeed(XMLStreamWriter2) method is also overridden.

  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter

    com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter.FixedSpaceIndenter, com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter.Indenter, com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter.Lf2SpacesIndenter, com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter.NopIndenter
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
     

    Fields inherited from class com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter

    _arrayIndenter, _justHadStartElement, _nesting, _objectIndenter, _spacesInObjectEntries

    Fields inherited from interface com.fasterxml.jackson.core.PrettyPrinter

    DEFAULT_ROOT_VALUE_SEPARATOR, DEFAULT_SEPARATORS
  • Constructor Summary

    Constructors
    Constructor
    Description
    Log4jXmlPrettyPrinter(int nesting)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter
    Sets the nesting level to 1 rather than 0, so the "Event" tag will get indentation of next level below root.
    void
    writePrologLinefeed(org.codehaus.stax2.XMLStreamWriter2 sw)
     

    Methods inherited from class com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter

    beforeArrayValues, beforeObjectEntries, indentArraysWith, indentObjectsWith, spacesInObjectEntries, writeArrayValueSeparator, writeEndArray, writeEndElement, writeEndObject, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafElement, writeLeafNullElement, writeLeafXsiNilElement, writeObjectEntrySeparator, writeObjectFieldValueSeparator, writeRootValueSeparator, writeStartArray, writeStartElement, writeStartObject

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Log4jXmlPrettyPrinter

      Log4jXmlPrettyPrinter(int nesting)
  • Method Details

    • writePrologLinefeed

      public void writePrologLinefeed(org.codehaus.stax2.XMLStreamWriter2 sw) throws XMLStreamException
      Specified by:
      writePrologLinefeed in interface com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter
      Overrides:
      writePrologLinefeed in class com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter
      Throws:
      XMLStreamException
    • createInstance

      public com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter createInstance()
      Sets the nesting level to 1 rather than 0, so the "Event" tag will get indentation of next level below root.
      Specified by:
      createInstance in interface com.fasterxml.jackson.core.util.Instantiatable<com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter>
      Overrides:
      createInstance in class com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter