Class XmlBuilder


  • public final class XmlBuilder
    extends java.lang.Object
    Simple XML content generator.

    This class contains simple methods to create XML content.

    Note: no XML validation is made.

    Since:
    7.1
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlBuilder​(java.lang.String rootName)
      Constructs a new XmlBuilder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void setAttribute​(java.lang.String fullName, java.lang.String value)
      Defines an XML attribute and its value.
      void tag​(java.lang.String fullName, java.lang.String value)
      Defines an XML tag and its content (without CDATA block).
      void tag​(java.lang.String fullName, java.lang.String value, boolean cdata)
      Defines an XML tag and its content.
      java.lang.String toString()
      Returns the XML content as String.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • XmlBuilder

        public XmlBuilder​(java.lang.String rootName)
        Constructs a new XmlBuilder.
        Parameters:
        rootName - name of the root node
    • Method Detail

      • setAttribute

        public void setAttribute​(java.lang.String fullName,
                                 java.lang.String value)
        Defines an XML attribute and its value.

        The fullName parameter must comply the following syntax:

         <code>
         <root node>@<child node 1>@<child node 2>@<child node N>#<new attribute>
         </code>
         
        Parameters:
        fullName - the complete path from the root node until the attribute name
        value - the attribute's value
      • tag

        public void tag​(java.lang.String fullName,
                        java.lang.String value)
        Defines an XML tag and its content (without CDATA block).
        Parameters:
        fullName - the complete path from the root node until the tag name
        value - the tag's content
        See Also:
        tag(String, String, boolean)
      • tag

        public void tag​(java.lang.String fullName,
                        java.lang.String value,
                        boolean cdata)
        Defines an XML tag and its content.

        The fullName parameter must comply the following syntax:

         <code>
         <root node>@<child node 1>@<child node 2>@<child node N>@<new tag>
         </code>
         
        Parameters:
        fullName - the complete path from the root node until the tag name
        value - the tag's content
        cdata - true if value must be enclosed by a CDATA block, otherwise false
      • toString

        public java.lang.String toString()
        Returns the XML content as String.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the XML content as String