Class XMLWriter

java.lang.Object
org.apache.camel.xml.io.XMLWriter

public class XMLWriter extends Object
XML writer which emits nicely formatted documents.
  • Constructor Details

    • XMLWriter

      public XMLWriter(Writer writer) throws IOException
      Parameters:
      writer - not null
      Throws:
      IOException
    • XMLWriter

      public XMLWriter(Writer writer, String lineIndenter) throws IOException
      Parameters:
      writer - not null
      lineIndenter - could be null, but the normal way is some spaces.
      Throws:
      IOException
    • XMLWriter

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

      public XMLWriter(Writer writer, String lineIndenter, String encoding, String doctype) throws IOException
      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.
      Throws:
      IOException
    • XMLWriter

      public XMLWriter(Writer writer, String lineIndenter, String lineSeparator, String encoding, String doctype) throws IOException
      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.
      Throws:
      IOException
  • Method Details

    • startElement

      public void startElement(String name) throws IOException
      Throws:
      IOException
    • writeText

      public void writeText(String text) throws IOException
      Throws:
      IOException
    • writeMarkup

      public void writeMarkup(String text) throws IOException
      Throws:
      IOException
    • addAttribute

      public void addAttribute(String key, String value) throws IOException
      Throws:
      IOException
    • endElement

      public void endElement(String name) throws IOException
      Throws:
      IOException
    • getLineIndenter

      protected String getLineIndenter()
      Get the string used as line indenter
      Returns:
      the line indenter
    • getLineSeparator

      protected String getLineSeparator()
      Get the string used as line separator or LS if not set.
      Returns:
      the line separator
      See Also:
    • endOfLine

      protected void endOfLine() throws IOException
      Write the end of line character (using specified line separator) and start new line with indentation
      Throws:
      IOException
      See Also:
    • getWriter

      protected Writer getWriter()
      Get the underlying writer
      Returns:
      the underlying writer
    • getDepth

      protected int getDepth()
      Get the current depth in the xml indentation
      Returns:
      the current depth
    • getEncoding

      protected String getEncoding()
      Get the current encoding in the xml
      Returns:
      the current encoding
    • getDocType

      public String getDocType()
      Get the docType in the xml
      Returns:
      the current docType
    • getElements

      public Deque<String> getElements()
      Returns:
      the current elementStack;