Class PrettyPrintXMLWriter

java.lang.Object
org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter
All Implemented Interfaces:
XMLWriter

public class PrettyPrintXMLWriter extends Object implements XMLWriter
XMLWriter with nice indentation.
Author:
kama
  • Constructor Details

    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(PrintWriter writer, String lineIndent)
      Parameters:
      writer - not null
      lineIndent - could be null, but the normal way is some spaces.
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(Writer writer, String lineIndent)
      Parameters:
      writer - not null
      lineIndent - could be null, but the normal way is some spaces.
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(PrintWriter writer)
      Parameters:
      writer - not null
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(Writer writer)
      Parameters:
      writer - not null
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(PrintWriter writer, String lineIndent, String encoding, String doctype)
      Parameters:
      writer - not null
      lineIndent - could be null, but the normal way is some spaces.
      encoding - could be null or invalid.
      doctype - could be null.
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(Writer writer, String lineIndent, String encoding, String doctype)
      Parameters:
      writer - not null
      lineIndent - could be null, but the normal way is some spaces.
      encoding - could be null or invalid.
      doctype - could be null.
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(PrintWriter writer, String encoding, String doctype)
      Parameters:
      writer - not null
      encoding - could be null or invalid.
      doctype - could be null.
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(Writer writer, String encoding, String doctype)
      Parameters:
      writer - not null
      encoding - could be null or invalid.
      doctype - could be null.
    • PrettyPrintXMLWriter

      public PrettyPrintXMLWriter(PrintWriter writer, String lineIndent, String lineSeparator, String encoding, String doctype)
      Parameters:
      writer - not null
      lineIndent - could be null, but the normal way is some spaces.
      lineSeparator - could be null, but the normal way is valid line separator
      encoding - could be null or the encoding to use.
      doctype - could be null.
  • Method Details

    • addAttribute

      public void addAttribute(String key, String value) throws IOException
      Add a XML attribute to the current XML Element. This method must get called immediately after XMLWriter.startElement(String)
      Specified by:
      addAttribute in interface XMLWriter
      Parameters:
      key - The key of the attribute.
      value - The value of the attribute.
      Throws:
      IOException - if adding the attribute fails.
    • setEncoding

      public void setEncoding(String encoding)
      Sets the encoding of the document. If not set, UTF-8 is being used
      Specified by:
      setEncoding in interface XMLWriter
      Parameters:
      encoding - the encoding
    • setDocType

      public void setDocType(String docType)
      Sets the docType of the document.
      Specified by:
      setDocType in interface XMLWriter
      Parameters:
      docType - the docType
    • setLineSeparator

      public void setLineSeparator(String lineSeparator)
      Parameters:
      lineSeparator - The line separator to be used.
    • setLineIndenter

      public void setLineIndenter(String lineIndentParameter)
      Parameters:
      lineIndentParameter - The line indent parameter.
    • startElement

      public void startElement(String elementName) throws IOException
      Start an XML Element tag.
      Specified by:
      startElement in interface XMLWriter
      Parameters:
      elementName - The name of the tag.
      Throws:
      IOException - if starting the element fails.
    • writeText

      public void writeText(String text) throws IOException
      Add a value text to the current element tag This will perform XML escaping to guarantee valid content
      Specified by:
      writeText in interface XMLWriter
      Parameters:
      text - The text which should be written.
      Throws:
      IOException - if writing the text fails.
    • writeMarkup

      public void writeMarkup(String markup) throws IOException
      Add a preformatted markup to the current element tag
      Specified by:
      writeMarkup in interface XMLWriter
      Parameters:
      markup - The text which should be written.
      Throws:
      IOException - if writing the markup fails.
    • endElement

      public void endElement() throws IOException
      End the previously opened element.
      Specified by:
      endElement in interface XMLWriter
      Throws:
      IOException - if ending the element fails.
      See Also: