Class XmlNewAbstractElement

java.lang.Object
com.aquima.interactions.foundation.xml.generation.XmlNewAbstractElement
All Implemented Interfaces:
IXmlElement, Serializable
Direct Known Subclasses:
XmlNewAbstractSpecialElt, XmlNewElement

public abstract class XmlNewAbstractElement extends Object implements IXmlElement
This class is a shared parent of the XmlNew* classes which use this functionality.
Since:
6.0
Author:
I. de Jong.
See Also:
  • Constructor Details

    • XmlNewAbstractElement

      public XmlNewAbstractElement()
  • Method Details

    • findAncestor

      public IXmlElement findAncestor(String name)
      Find the XMLNewElement that is an ancestor of the current XMLNewElement, with the specified name. Throws exception if the ancestor is not found.
      Specified by:
      findAncestor in interface IXmlElement
      Parameters:
      name - The tag name of the ancestor that is requested.
      Returns:
      The ancestor with the specified tag name.
      Throws:
      XmlException - when no ancestor is found.
    • getParentSafe

      public IXmlElement getParentSafe()
      Description copied from interface: IXmlElement
      returns the parent node, or null if there is no parent.
      Specified by:
      getParentSafe in interface IXmlElement
      Returns:
      The XML element of the parent node.
    • getParent

      public IXmlElement getParent()
      Description copied from interface: IXmlElement
      returns the parent node, raises XmlException if there is no parent.
      Specified by:
      getParent in interface IXmlElement
      Returns:
      The XML element of the parent node.
    • setParent

      public void setParent(IXmlElement parent)
      Description copied from interface: IXmlElement
      internal: set the parent of this node.
      Specified by:
      setParent in interface IXmlElement
      Parameters:
      parent - The new parent of the element.
    • clearParent

      protected void clearParent()
    • setName

      public void setName(String name)
      Description copied from interface: IXmlElement
      Change the tag name of an element.
      • Name can contain letters, numbers, and other characters
      • Name cannot start with a number or punctuation character
      • Name cannot start with the letters xml (or XML, or Xml, etc)
      • Name cannot contain spaces, <, >, ", ' or &
      Specified by:
      setName in interface IXmlElement
      Parameters:
      name - the name of the element.
    • hasInvalidCharacters

      protected boolean hasInvalidCharacters(char[] invalidChars, String name)
    • hasChildren

      protected abstract boolean hasChildren()
    • setValue

      public void setValue(String stringValue)
      Description copied from interface: IXmlElement
      Change the text value of an element. Be careful if your node has already been added to a tree.
      Specified by:
      setValue in interface IXmlElement
      Parameters:
      stringValue - The new value for the element.
    • setValue

      public void setValue(byte[] rawValue, String encoding)
      Description copied from interface: IXmlElement
      Change the value. Only useful if the element has not yet been added as a child.
      Specified by:
      setValue in interface IXmlElement
      Parameters:
      rawValue - the raw byte array of the new value
      encoding - the character encoding used for the byte array
    • getName

      public String getName()
      Description copied from interface: IXmlElement
      The name of the element (usually the XML tag).
      Specified by:
      getName in interface IXmlElement
      Returns:
      The name of the xml element.
    • getValue

      public String getValue()
      Description copied from interface: IXmlElement
      The text 'value' of the element -- easy shortcut to get tag values.
      Specified by:
      getValue in interface IXmlElement
      Returns:
      The text value of the element.
    • toXmlFragment

      public String toXmlFragment()
      Description copied from interface: IXmlElement
      Easy way to create an XML string for this element and the children. Indent starts at 0. The toXMLfragment method operating on a StringBuffer is faster and better suited when creating only a part of a larger document. This method returns a string and was designed to get the "final" representation. It uses whitespace indentation for pretty printing.
      Specified by:
      toXmlFragment in interface IXmlElement
      Returns:
      String containing the XML of this element and children.
    • toXmlFragment

      public String toXmlFragment(boolean useIndentation)
      Description copied from interface: IXmlElement
      Easy way to create an XML string for this element and the children. Indent starts at 0. The toXMLfragment method operating on a StringBuffer is faster and better suited when creating only a part of a larger document. This method returns a string and was designed to get the "final" representation.
      Specified by:
      toXmlFragment in interface IXmlElement
      Parameters:
      useIndentation - true to use whitespace indentation for pretty printing, false to avoid any whitespace between XML elements
      Returns:
      String containing the XML of this element and children.
    • toXmlFragment

      public void toXmlFragment(int level, StringBuffer str)
      Description copied from interface: IXmlElement
      Recursive conversion to an XML document. XML problem chars will be escaped (",<,>, etc). The XML code is appended to a stringbuffer. It uses indentation for pretty printing.
      Specified by:
      toXmlFragment in interface IXmlElement
      Parameters:
      level - indentation level (tabs), start with 0
      str - existing StringBuffer to append into
    • toXmlFragment

      public abstract void toXmlFragment(boolean useIndentation, boolean sortAttributes, int level, StringBuffer str)
      Description copied from interface: IXmlElement
      Recursive conversion to an XML document. XML problem chars will be escaped (",<,>, etc). The XML code is appended to a stringbuffer. It uses indentation for pretty printing. Indentation starts at 0.
      Specified by:
      toXmlFragment in interface IXmlElement
      Parameters:
      useIndentation - true to use whitespace indentation for pretty printing, false to avoid any whitespace between XML elements
      sortAttributes - true to use sort the attributes by name in alphabetic order.
      level - indentation level (tabs), start with 0 (unused if useIndentation is false)
      str - existing StringBuffer to append into