public class XmlNodeSimple<UserData> extends TreeNodeBase<XmlNodeSimple<UserData>,UserData,XmlNode> implements XmlNode
XmlNodeSimple(String, Object)
and XmlNodeSimple(String, String, Object)
.
Elsewhere the TreeNodeBase.nd_data
is left empty. This is for ordinary XML data.TreeNodeBase.IteratorDerivedImpl, TreeNodeBase.IteratorDerivedNode, TreeNodeBase.IteratorImpl, TreeNodeBase.IteratorMetaNode, TreeNodeBase.IteratorOneNode, TreeNodeBase.MetaNode<DerivedNode extends TreeNodeBase<DerivedNode,Data,IfcType> & SortedTree<IfcType>,Data,IfcType extends SortedTree<IfcType>>, TreeNodeBase.TreeNode<Data>
Modifier and Type | Field and Description |
---|---|
(package private) java.lang.String |
name
The tag name of the node or the text if namespaceKey is "$".
|
(package private) java.lang.String |
namespaceKey
The namespace-key.
|
(package private) java.util.TreeMap<java.lang.String,java.lang.String> |
namespaces
List of namespace declaration, typical null because only top elements has it.
|
(package private) java.lang.String |
text
Text of an attribute or text of a text node.
|
static int |
version
Version, history and license.
|
nd_data, nd_firstChild, nd_idxChildren, nd_key, nd_lastChild, nd_leafData, nd_next, nd_nrofChildren, nd_parent, nd_prev
Modifier | Constructor and Description |
---|---|
|
XmlNodeSimple(java.lang.String name)
Creates a XML node.
|
|
XmlNodeSimple(java.lang.String name,
java.lang.String namespaceKey)
Creates a XML node.
|
protected |
XmlNodeSimple(java.lang.String key,
java.lang.String text,
boolean isText)
Creates a XML node with text.
|
|
XmlNodeSimple(java.lang.String name,
java.lang.String namespaceKey,
java.lang.String namespace)
Creates a XML node.
|
|
XmlNodeSimple(java.lang.String name,
java.lang.String namespaceKey,
UserData data)
Creates a XML node.
|
|
XmlNodeSimple(java.lang.String name,
UserData data)
Creates a XML node.
|
Modifier and Type | Method and Description |
---|---|
XmlNode |
addContent(java.lang.String text)
Adds textual content.
|
XmlNode |
addContent(XmlNode child)
Adds a child node.
|
void |
addNamespaceDeclaration(java.lang.String name,
java.lang.String value)
Adds namespace declaration on the specified node.
|
XmlNode |
addNewNode(java.lang.String name)
adds and returns a new child node.
|
XmlNode |
addNewNode(java.lang.String name,
java.lang.String namespaceKey)
adds and returns a new child node.
|
private static java.lang.String |
calcKey(java.lang.String name,
java.lang.String namespaceKey) |
static XmlNode |
createNewNode(java.lang.String name,
java.lang.String namespaceKey)
Creates an independent new XmlNode without data.
|
XmlNode |
createNode(java.lang.String name,
java.lang.String namespaceKey)
creates a XmlNode from the same implementation type as this, but without adding to the XML-tree.
|
java.lang.String |
getAttribute(java.lang.String name)
returns the requested attribute or null if it is not existing.
|
java.util.List<java.lang.String[]> |
getAttributeList()
Prepares a List for attributes from given children.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
Prepares a Map for attributes from given children.
|
java.lang.String |
getName()
Returns the text if it is a text node.
|
java.lang.String |
getNamespaceKey()
returns the alias or key of the namespace.
|
java.util.Map<java.lang.String,java.lang.String> |
getNamespaces()
Gets all namespace declaration at this node.
|
boolean |
isTextNode()
returns true if the node is a text, not a XML element.
|
protected XmlNodeSimple<UserData> |
newNode(java.lang.String key,
UserData data)
This method has to be overridden in the derived class.
|
java.lang.String |
removeAttribute(java.lang.String name)
removes the requested attribute.
|
XmlNode |
setAttribute(java.lang.String name,
java.lang.String value)
Sets an attribute by name.
|
void |
setAttribute(java.lang.String name,
java.lang.String namespaceKey,
java.lang.String value)
Sets an attribute by name.
|
java.lang.String |
text()
Returns the text of the node.
|
java.lang.String |
toString()
Returns either the simple text which is associated to the node (for attributes or simple text nodes)
or returns "
|
java.lang.String |
toString1() |
addLeaf, addNode, addNode, addNodeFirst, addSiblingNext, addSiblingPrev, childNodes, childNodes, detach, firstChild, getChild, getContainerChildren, getKey, getNode, getOrCreateNode, getParent, getParentData, hasChildren, iterator, iteratorChildren, iteratorChildren, iterChildren, iterChildren, lastChild, listChildren, listChildren, movetoFirstChild, movetoSiblingNext, movetoSiblingPrev, nextSibling, nrofChildren, parent, parentEquals, prevSibling, removeChildren, swap, walkTree
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
removeChildren
getChild, getParent, iterChildren, iterChildren, listChildren, listChildren
public static final int version
setAttribute(String, String, String)
with namespace
XmlNodeSimple(String, Object)
if given.
XmlNodeSimple(String, Object)
etc. If "namespace:name" is given as parameter name
the namespace is used.
toString()
returns the pure text if the node contains only text or it is an attribute.
It is helpful for output data.
text
and no extra child is created for that. If the node has another children and the text is dispersed between them therefore,
the text is stored as child node with "$"-key like before.
TreeNodeBase
reference.
addContent(XmlNode)
checks whether the child is an attribute node.
Then it is added as attribute. Such nodes are created from ZbnfParser
now.
and the XmlNodeSimple#attributes
may be removed.
TreeNodeBase
is used for the node structure.
Reference #node
. The algorithm to manage the node structure is deployed in the
TreeNodeBase yet.
final java.lang.String name
TreeNodeBase
. The key there is namespaceKey:name.final java.lang.String namespaceKey
java.lang.String text
java.util.TreeMap<java.lang.String,java.lang.String> namespaces
public XmlNodeSimple(java.lang.String name)
name
- The tag name. If it contains a "namespace:name", the namespace will be separated.public XmlNodeSimple(java.lang.String name, UserData data)
name
- The tag name. If it contains a "namespace:name", the namespace will be separated.data
- Additional data stored in the TreeNodeBase.nd_data
protected XmlNodeSimple(java.lang.String key, java.lang.String text, boolean isText)
key
- text
- isText
- not used. It is a marker only to select this constructor.public XmlNodeSimple(java.lang.String name, java.lang.String namespaceKey, UserData data)
name
- The tag name. If it contains a "namespace:name", the namespace will be separated.namespaceKey
- A given namespace if not contained in name. This argument wins if "namespace:name"data
- Additional data stored in the TreeNodeBase.nd_data
public XmlNodeSimple(java.lang.String name, java.lang.String namespaceKey)
name
- The tag name. If it contains a "namespace:name", the namespace will be separated.namespaceKey
- A given namespace if not contained in name. This argument wins if "namespace:name"public XmlNodeSimple(java.lang.String name, java.lang.String namespaceKey, java.lang.String namespace)
name
- The tag name. If it contains a "namespace:name", the namespace will be separated.namespaceKey
- A given namespace if not contained in name. This argument wins if "namespace:name"namespace
- the string associated to the namespaceKeyprivate static java.lang.String calcKey(java.lang.String name, java.lang.String namespaceKey)
protected XmlNodeSimple<UserData> newNode(java.lang.String key, UserData data)
TreeNodeBase
newNode
in class TreeNodeBase<XmlNodeSimple<UserData>,UserData,XmlNode>
public XmlNode createNode(java.lang.String name, java.lang.String namespaceKey)
XmlNode
XmlNode.addContent(XmlNode)
, because it may be necessary to built
a sub tree with the new node first, and than add, if there are multi threads.createNode
in interface XmlNode
namespaceKey
- The this-node should know the key, otherwise an XmlException is thrown.public static XmlNode createNewNode(java.lang.String name, java.lang.String namespaceKey)
createNode(String, String)
name
- Tag name or "namespacekey:name" if argument namespaceKey is nullnamespaceKey
- extra argument as name space key.
This is not the namespace itself, it is the key defined in xml with an attribute:
xmlns:namespaceKey="www.url/of/namespace"
createNode(String, String)
which needs an instance.public XmlNode setAttribute(java.lang.String name, java.lang.String value)
XmlNode
setAttribute
in interface XmlNode
public void setAttribute(java.lang.String name, java.lang.String namespaceKey, java.lang.String value)
XmlNode
setAttribute
in interface XmlNode
public void addNamespaceDeclaration(java.lang.String name, java.lang.String value)
XmlNode
addNamespaceDeclaration
in interface XmlNode
name
- namespace alias (key)value
- namespace uri.public XmlNode addContent(java.lang.String text)
XmlNode
addContent
in interface XmlNode
public XmlNode addNewNode(java.lang.String name, java.lang.String namespaceKey) throws XmlException
XmlNode
addNewNode
in interface XmlNode
XmlException
public XmlNode addNewNode(java.lang.String name) throws XmlException
XmlNode
addNewNode
in interface XmlNode
XmlException
public XmlNode addContent(XmlNode child) throws XmlException
XmlNode
XmlNode.getName()
starts with "@", it is added as an attribute to this with the XmlNode.text()
as attribute value. This opens the possibility to create a XmlNode independent of a parent and independent of checking
whether it should be an attribute, and convert it to an attribute later.addContent
in interface XmlNode
child
- to addXmlException
public boolean isTextNode()
XmlNode
isTextNode
in interface XmlNode
public java.lang.String text()
public java.lang.String getName()
public java.lang.String getNamespaceKey()
XmlNode
getNamespaceKey
in interface XmlNode
public java.lang.String getAttribute(java.lang.String name)
XmlNode
getAttribute
in interface XmlNode
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
TreeNodeBase.listChildren()
and checks whether the name starts with "@".getAttributes
in interface XmlNode
XmlNode.getAttributes()
public java.util.List<java.lang.String[]> getAttributeList()
TreeNodeBase.listChildren()
and checks whether the name starts with "@".getAttributeList
in interface XmlNode
XmlNode.getAttributes()
public java.util.Map<java.lang.String,java.lang.String> getNamespaces()
XmlNode
getNamespaces
in interface XmlNode
public java.lang.String removeAttribute(java.lang.String name)
XmlNode
removeAttribute
in interface XmlNode
public java.lang.String toString()
org.vishia.zbatch.ZbatchExecuter
.toString
in class TreeNodeBase<XmlNodeSimple<UserData>,UserData,XmlNode>
TreeNodeBase.toString()
public java.lang.String toString1()