Class XMLOutputterWriter

java.lang.Object
com.highdeal.hci.XMLOutputterWriter
All Implemented Interfaces:
XMLOutputter

public class XMLOutputterWriter extends Object implements XMLOutputter
Implementation of an XMLOutputter using a writer.
  • Constructor Details

    • XMLOutputterWriter

      public XMLOutputterWriter(Writer w)
      Constructs an XML outputter from a writer.
      Parameters:
      w - The writer to write XML in
    • XMLOutputterWriter

      public XMLOutputterWriter(Writer w, boolean withXMLDeclaration)
      Constructs an XML outputter from a writer.
      Parameters:
      w - The writer to write XML in
      withXMLDeclaration - Specifies if the XML header must be written
    • XMLOutputterWriter

      public XMLOutputterWriter(Writer w, boolean withXMLDeclaration, String encoding)
      Constructs an XML outputter from a writer.
      Parameters:
      w - The writer to write XML in
      withXMLDeclaration - Specifies if the XML header must be written
      encoding - The encoding to set in the XML header
  • Method Details

    • setIndent

      public void setIndent(boolean indent)
      Sets to false if the result cannot be indented, otherwise sets to true.
      Parameters:
      indent - Sets to false if the result cannot be indented otherwise sets to true
    • setIndentLevel

      public void setIndentLevel(int indentLevel)
      Sets the indent level of the XML writer.
      Parameters:
      indentLevel - the indent level of the XML writer
    • marshal

      public void marshal(String tagName, IXMLMarshallable child)
      Description copied from interface: XMLOutputter
      Marshals a node into this writer.

      The sequence is:

      1. Writing the start XML tag
      2. Writing the attributes IXMLMarshallable.marshalAttributes(XMLOutputter)
      3. Calling recursively IXMLMarshallable.marshalChildren(XMLOutputter)
      4. Writing the end XML tag

      Note

      This method is taking care of handling a null child.

      Specified by:
      marshal in interface XMLOutputter
      Parameters:
      tagName - The name of child XML tag
      child - The child itself, that must be marshalled
    • startTag

      public void startTag(String tag)
      Description copied from interface: XMLOutputter
      Starts a XML tag.
      Specified by:
      startTag in interface XMLOutputter
      Parameters:
      tag - The name of the XML tag to start with
    • addAttribute

      public void addAttribute(String name, String value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type string to the current XML tag.
      Specified by:
      addAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The text value of the attribute
    • addDecimalAttribute

      public void addDecimalAttribute(String name, BigDecimal value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type decimal to the current XML tag.
      Specified by:
      addDecimalAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The numerical value of the attribute
    • addDateTimeAttribute

      public void addDateTimeAttribute(String name, Date value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type date and time to the current XML tag; Date and times are encoded using ISO 8601 format, that is: 'YYYY-MM-DDTHH:MM:SS.mmm'.
      Specified by:
      addDateTimeAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The value of the attribute
    • addDateAttribute

      public void addDateAttribute(String name, Date value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type date to the current XML tag; Dates are encoded using ISO 8601 format, that is: 'YYYY-MM-DD'.
      Specified by:
      addDateAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The date value of the attribute
    • addBooleanAttribute

      public void addBooleanAttribute(String name, boolean value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type boolean to the current XML tag.
      Specified by:
      addBooleanAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The value of the attribute
    • addCharacterData

      public void addCharacterData(String data)
      Description copied from interface: XMLOutputter
      Adds character data for the current XML tag.
      Specified by:
      addCharacterData in interface XMLOutputter
      Parameters:
      data - The character data to add for the current tag
    • addCharacterData

      public void addCharacterData(Reader readerData)
      Description copied from interface: XMLOutputter
      Adds character data for the current XML tag.
      Specified by:
      addCharacterData in interface XMLOutputter
      Parameters:
      readerData - The character data to add for the current tag as a Reader
    • addEscapedCharacterData

      public void addEscapedCharacterData(String data)
    • addText

      public void addText(String data, boolean asCData)
      Adds text for the current XML element.
      Parameters:
      data - The text to add for the current XML element
      asCData - Specifies if the text must be marked as character data (CDATA)
    • addComment

      public void addComment(String... lines)
      Adds a comment.
      Parameters:
      lines - The line(s) of the comment to add
    • endTag

      public void endTag(String tag)
      Description copied from interface: XMLOutputter
      Ends the XML tag.
      Specified by:
      endTag in interface XMLOutputter
      Parameters:
      tag - The name of the XML tag to close
    • addIntegerAttribute

      public void addIntegerAttribute(String name, Integer value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type integer to the current XML tag.
      Specified by:
      addIntegerAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The integer value of the attribute
    • addLongAttribute

      public void addLongAttribute(String name, Long value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type long to the current XML tag.
      Specified by:
      addLongAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The value of the attribute
    • addBigIntegerAttribute

      public void addBigIntegerAttribute(String name, BigInteger value)
      Description copied from interface: XMLOutputter
      Adds an attribute of type big integer to the current XML tag.
      Specified by:
      addBigIntegerAttribute in interface XMLOutputter
      Parameters:
      name - The name of the attribute
      value - The value of the attribute