public class XmlNodeJdom extends java.lang.Object implements XmlNode
XmlNode
.
So some algorithm using XmlNode can execute with a given JDOM XML Tree.
xml.CorrectHref
. There a JDOM tree is used,
and WikistyleTextToSimpleXml
is called there. The last class
WikistyleTextToSimpleXml don't know JDOM, but it works correct.Constructor and Description |
---|
XmlNodeJdom(Element jdomNode) |
Modifier and Type | Method and Description |
---|---|
XmlNode |
addContent(java.lang.String text)
Adds textual content.
|
XmlNode |
addContent(XmlNode node)
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,
java.lang.String namespaceKey)
adds and returns a new child node.
|
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.Map<java.lang.String,java.lang.String> |
getAttributes()
returns all attributes.
|
XmlNode |
getChild(java.lang.String key)
Searches the first child with given key from the given node this.
|
java.lang.String |
getName()
Returns the tagname of the 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.
|
XmlNode |
getParent() |
boolean |
isTextNode()
returns true if the node is a text, not a XML element.
|
java.util.Iterator<XmlNode> |
iterChildren()
Returns an iterator through the list of all children of the node.
|
java.util.Iterator<XmlNode> |
iterChildren(java.lang.String key)
Returns an iterator through the list of all children with the given key.
|
java.util.List<XmlNode> |
listChildren()
Returns a List of all children of the node.
|
java.util.List<XmlNode> |
listChildren(java.lang.String key)
Returns a List of all children with the given key.
|
java.lang.String |
removeAttribute(java.lang.String name)
removes the requested attribute.
|
void |
removeChildren()
removes all children, also textual content, but not attributes.
|
void |
setAttribute(java.lang.String name,
java.lang.String value)
Sets an attribute by name.
|
void |
setParent(XmlNode parent) |
java.lang.String |
text()
Returns the text of the node.
|
java.lang.String |
toString() |
public XmlNodeJdom(Element jdomNode)
public XmlNode addContent(java.lang.String text)
org.vishia.xmlSimple.XmlNode
addContent
in interface XmlNode
public XmlNode addContent(XmlNode node) throws XmlException
org.vishia.xmlSimple.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
node
- to addXmlException
public void addNamespaceDeclaration(java.lang.String name, java.lang.String value)
org.vishia.xmlSimple.XmlNode
addNamespaceDeclaration
in interface XmlNode
name
- namespace alias (key)value
- namespace uri.public XmlNode addNewNode(java.lang.String name, java.lang.String namespaceKey) throws XmlException
org.vishia.xmlSimple.XmlNode
addNewNode
in interface XmlNode
XmlException
public XmlNode createNode(java.lang.String name, java.lang.String namespaceKey) throws XmlException
org.vishia.xmlSimple.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.XmlException
public java.lang.String getAttribute(java.lang.String name)
org.vishia.xmlSimple.XmlNode
getAttribute
in interface XmlNode
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
org.vishia.xmlSimple.XmlNode
getAttributes
in interface XmlNode
public XmlNode getChild(java.lang.String key)
org.vishia.util.SortedTree
getChild
in interface SortedTree<XmlNode>
key
- The key of the demanded child. The implementation may have extra possibilities in addressing children
with strings. The sKey can be representing more as a simple string as a attribute in children.
It may be comparable with the ability of XPATH in XML.
But it will be a feature of Implementation and is not defined as a basic feature of this interface.
public java.lang.String getName()
org.vishia.xmlSimple.XmlNode
XmlNode.isTextNode()
.
public java.lang.String getNamespaceKey()
org.vishia.xmlSimple.XmlNode
getNamespaceKey
in interface XmlNode
public java.util.Map<java.lang.String,java.lang.String> getNamespaces()
org.vishia.xmlSimple.XmlNode
getNamespaces
in interface XmlNode
public XmlNode getParent()
getParent
in interface SortedTree<XmlNode>
public boolean isTextNode()
org.vishia.xmlSimple.XmlNode
isTextNode
in interface XmlNode
public java.util.Iterator<XmlNode> iterChildren()
org.vishia.util.SortedTree
iterChildren
in interface SortedTree<XmlNode>
public java.util.Iterator<XmlNode> iterChildren(java.lang.String key)
org.vishia.util.SortedTree
iterChildren
in interface SortedTree<XmlNode>
key
- The key of the demanded child. The implementation may have extra possibilities, see getChild(String).public java.util.List<XmlNode> listChildren()
org.vishia.util.SortedTree
listChildren
in interface SortedTree<XmlNode>
public java.util.List<XmlNode> listChildren(java.lang.String key)
org.vishia.util.SortedTree
listChildren
in interface SortedTree<XmlNode>
key
- The key of the demanded child. The implementation may have extra possibilities, see getChild(String).public java.lang.String removeAttribute(java.lang.String name)
org.vishia.xmlSimple.XmlNode
removeAttribute
in interface XmlNode
public void removeChildren()
org.vishia.xmlSimple.XmlNode
removeChildren
in interface XmlNode
public void setAttribute(java.lang.String name, java.lang.String value)
org.vishia.xmlSimple.XmlNode
setAttribute
in interface XmlNode
public java.lang.String text()
org.vishia.xmlSimple.XmlNode
public java.lang.String toString()
toString
in class java.lang.Object