Class XmlNewAbstractElement
java.lang.Object
com.aquima.interactions.foundation.xml.generation.XmlNewAbstractElement
- All Implemented Interfaces:
IXmlElement
,Serializable
- Direct Known Subclasses:
XmlNewAbstractSpecialElt
,XmlNewElement
This class is a shared parent of the XmlNew* classes which use this functionality.
- Since:
- 6.0
- Author:
- I. de Jong.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
findAncestor
(String name) Find the XMLNewElement that is an ancestor of the current XMLNewElement, with the specified name.getName()
The name of the element (usually the XML tag).returns the parent node, raises XmlException if there is no parent.returns the parent node, or null if there is no parent.getValue()
The text 'value' of the element -- easy shortcut to get tag values.protected abstract boolean
protected boolean
hasInvalidCharacters
(char[] invalidChars, String name) void
Change the tag name of an element.void
setParent
(IXmlElement parent) internal: set the parent of this node.void
Change the value.void
Change the text value of an element.Easy way to create an XML string for this element and the children.toXmlFragment
(boolean useIndentation) Easy way to create an XML string for this element and the children.abstract void
toXmlFragment
(boolean useIndentation, boolean sortAttributes, int level, StringBuffer str) Recursive conversion to an XML document.void
toXmlFragment
(int level, StringBuffer str) Recursive conversion to an XML document.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aquima.interactions.foundation.xml.generation.IXmlElement
addChild, addChildCopy, addChildren, addSibling, containsNode, findChildren, findFirstChild, findTag, findTags, getAttribute, getAttributes, getAttributeSafe, getAttributesMap, getChildren, getFirstChild, getFirstElement, getNextSibling, hasAttributes, isCData, removeAllChildren, removeAttribute, removeChild, replaceChild, setAttribute, setCData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue
-
Constructor Details
-
XmlNewAbstractElement
public XmlNewAbstractElement()
-
-
Method Details
-
findAncestor
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 interfaceIXmlElement
- 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
Description copied from interface:IXmlElement
returns the parent node, or null if there is no parent.- Specified by:
getParentSafe
in interfaceIXmlElement
- Returns:
- The XML element of the parent node.
-
getParent
Description copied from interface:IXmlElement
returns the parent node, raises XmlException if there is no parent.- Specified by:
getParent
in interfaceIXmlElement
- Returns:
- The XML element of the parent node.
-
setParent
Description copied from interface:IXmlElement
internal: set the parent of this node.- Specified by:
setParent
in interfaceIXmlElement
- Parameters:
parent
- The new parent of the element.
-
clearParent
protected void clearParent() -
setName
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 interfaceIXmlElement
- Parameters:
name
- the name of the element.
-
hasInvalidCharacters
-
hasChildren
protected abstract boolean hasChildren() -
setValue
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 interfaceIXmlElement
- Parameters:
stringValue
- The new value for the element.
-
setValue
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 interfaceIXmlElement
- Parameters:
rawValue
- the raw byte array of the new valueencoding
- the character encoding used for the byte array
-
getName
Description copied from interface:IXmlElement
The name of the element (usually the XML tag).- Specified by:
getName
in interfaceIXmlElement
- Returns:
- The name of the xml element.
-
getValue
Description copied from interface:IXmlElement
The text 'value' of the element -- easy shortcut to get tag values.- Specified by:
getValue
in interfaceIXmlElement
- Returns:
- The text value of the element.
-
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 interfaceIXmlElement
- Returns:
- String containing the XML of this element and children.
-
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.- Specified by:
toXmlFragment
in interfaceIXmlElement
- 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
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 interfaceIXmlElement
- Parameters:
level
- indentation level (tabs), start with 0str
- 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 interfaceIXmlElement
- Parameters:
useIndentation
- true to use whitespace indentation for pretty printing, false to avoid any whitespace between XML elementssortAttributes
- 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
-