org.codehaus.plexus.util.xml

## Class PrettyPrintXMLWriter

- java.lang.Object
- - org.codehaus.plexus.util.xml.PrettyPrintXMLWriter

- All Implemented Interfaces:
    XMLWriter
  Direct Known Subclasses:
    CompactXMLWriter

      public class PrettyPrintXMLWriter
      extends java.lang.Object
      implements XMLWriter

  Implementation of XMLWriter which emits nicely formatted documents.
  Version:
    $Id: PrettyPrintXMLWriter.java 8046 2009-01-12 23:39:16Z vsiveton $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `LS` Line separator ("\n" on UNIX)

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PrettyPrintXMLWriter(java.io.PrintWriter writer)`
    `PrettyPrintXMLWriter(java.io.PrintWriter writer, java.lang.String lineIndenter)`
    `PrettyPrintXMLWriter(java.io.PrintWriter writer, java.lang.String encoding, java.lang.String doctype)`
    `PrettyPrintXMLWriter(java.io.PrintWriter writer, java.lang.String lineIndenter, java.lang.String encoding, java.lang.String doctype)`
    `PrettyPrintXMLWriter(java.io.PrintWriter writer, java.lang.String lineIndenter, java.lang.String lineSeparator, java.lang.String encoding, java.lang.String doctype)`
    `PrettyPrintXMLWriter(java.io.Writer writer)`
    `PrettyPrintXMLWriter(java.io.Writer writer, java.lang.String lineIndenter)`
    `PrettyPrintXMLWriter(java.io.Writer writer, java.lang.String encoding, java.lang.String doctype)`
    `PrettyPrintXMLWriter(java.io.Writer writer, java.lang.String lineIndenter, java.lang.String encoding, java.lang.String doctype)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAttribute(java.lang.String key, java.lang.String value)`
    `void` | `endElement()`
    `protected void` | `endOfLine()` Write the end of line character (using specified line separator) and start new line with indentation
    `protected int` | `getDepth()` Get the current depth in the xml indentation
    `protected java.lang.String` | `getDocType()` Get the docType in the xml
    `protected java.util.LinkedList` | `getElementStack()`
    `protected java.lang.String` | `getEncoding()` Get the current encoding in the xml
    `protected java.lang.String` | `getLineIndenter()` Get the string used as line indenter
    `protected java.lang.String` | `getLineSeparator()` Get the string used as line separator or LS if not set.
    `protected java.io.PrintWriter` | `getWriter()` Get the underlying writer
    `protected void` | `setDepth(int depth)` Set the depth in the xml indentation
    `protected void` | `setDocType(java.lang.String docType)` Set the docType in the xml
    `protected void` | `setEncoding(java.lang.String encoding)` Set the encoding in the xml
    `protected void` | `setLineIndenter(java.lang.String lineIndenter)` Set the string used as line indenter
    `protected void` | `setLineSeparator(java.lang.String lineSeparator)` Set the string used as line separator
    `protected void` | `setWriter(java.io.PrintWriter writer)` Set the underlying writer
    `void` | `startElement(java.lang.String name)`
    `void` | `writeMarkup(java.lang.String text)`
    `void` | `writeText(java.lang.String text)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LS

          protected static final java.lang.String LS

      Line separator ("\n" on UNIX)

  - ### Constructor Detail

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.PrintWriter writer,
                                      java.lang.String lineIndenter)

      Parameters:
        `writer` - not null
        `lineIndenter` - could be null, but the normal way is some spaces.

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.Writer writer,
                                      java.lang.String lineIndenter)

      Parameters:
        `writer` - not null
        `lineIndenter` - could be null, but the normal way is some spaces.

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.PrintWriter writer)

      Parameters:
        `writer` - not null

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.Writer writer)

      Parameters:
        `writer` - not null

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.PrintWriter writer,
                                      java.lang.String lineIndenter,
                                      java.lang.String encoding,
                                      java.lang.String doctype)

      Parameters:
        `writer` - not null
        `lineIndenter` - could be null, but the normal way is some spaces.
        `encoding` - could be null or invalid.
        `doctype` - could be null.

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.Writer writer,
                                      java.lang.String lineIndenter,
                                      java.lang.String encoding,
                                      java.lang.String doctype)

      Parameters:
        `writer` - not null
        `lineIndenter` - could be null, but the normal way is some spaces.
        `encoding` - could be null or invalid.
        `doctype` - could be null.

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.PrintWriter writer,
                                      java.lang.String encoding,
                                      java.lang.String doctype)

      Parameters:
        `writer` - not null
        `encoding` - could be null or invalid.
        `doctype` - could be null.

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.Writer writer,
                                      java.lang.String encoding,
                                      java.lang.String doctype)

      Parameters:
        `writer` - not null
        `encoding` - could be null or invalid.
        `doctype` - could be null.

    - #### PrettyPrintXMLWriter

          public PrettyPrintXMLWriter(java.io.PrintWriter writer,
                                      java.lang.String lineIndenter,
                                      java.lang.String lineSeparator,
                                      java.lang.String encoding,
                                      java.lang.String doctype)

      Parameters:
        `writer` - not null
        `lineIndenter` - could be null, but the normal way is some spaces.
        `lineSeparator` - could be null, but the normal way is valid line separator ("\n" on UNIX).
        `encoding` - could be null or invalid.
        `doctype` - could be null.

  - ### Method Detail

    - #### startElement

          public void startElement(java.lang.String name)

      Specified by:
        `startElement` in interface `XMLWriter`

    - #### writeText

          public void writeText(java.lang.String text)

      Specified by:
        `writeText` in interface `XMLWriter`

    - #### writeMarkup

          public void writeMarkup(java.lang.String text)

      Specified by:
        `writeMarkup` in interface `XMLWriter`

    - #### addAttribute

          public void addAttribute(java.lang.String key,
                                   java.lang.String value)

      Specified by:
        `addAttribute` in interface `XMLWriter`

    - #### endElement

          public void endElement()

      Specified by:
        `endElement` in interface `XMLWriter`

    - #### getLineIndenter

          protected java.lang.String getLineIndenter()

      Get the string used as line indenter
      Returns:
        the line indenter

    - #### setLineIndenter

          protected void setLineIndenter(java.lang.String lineIndenter)

      Set the string used as line indenter
      Parameters:
        `lineIndenter` - new line indenter, could be null, but the normal way is some spaces.

    - #### getLineSeparator

          protected java.lang.String getLineSeparator()

      Get the string used as line separator or LS if not set.
      Returns:
        the line separator
      See Also:
        `LS`

    - #### setLineSeparator

          protected void setLineSeparator(java.lang.String lineSeparator)

      Set the string used as line separator
      Parameters:
        `lineSeparator` - new line separator, could be null but the normal way is valid line separator ("\n" on UNIX).

    - #### endOfLine

          protected void endOfLine()

      Write the end of line character (using specified line separator) and start new line with indentation
      See Also:
        `getLineIndenter()`, `getLineSeparator()`

    - #### setWriter

          protected void setWriter(java.io.PrintWriter writer)

      Set the underlying writer
      Parameters:
        `writer` - not null writer

    - #### getWriter

          protected java.io.PrintWriter getWriter()

      Get the underlying writer
      Returns:
        the underlying writer

    - #### setDepth

          protected void setDepth(int depth)

      Set the depth in the xml indentation
      Parameters:
        `depth` - new depth

    - #### getDepth

          protected int getDepth()

      Get the current depth in the xml indentation
      Returns:
        the current depth

    - #### setEncoding

          protected void setEncoding(java.lang.String encoding)

      Set the encoding in the xml
      Parameters:
        `encoding` - new encoding

    - #### getEncoding

          protected java.lang.String getEncoding()

      Get the current encoding in the xml
      Returns:
        the current encoding

    - #### setDocType

          protected void setDocType(java.lang.String docType)

      Set the docType in the xml
      Parameters:
        `docType` - new docType

    - #### getDocType

          protected java.lang.String getDocType()

      Get the docType in the xml
      Returns:
        the current docType

    - #### getElementStack

          protected java.util.LinkedList getElementStack()

      Returns:
        the current elementStack;