public abstract class AbstractNode extends java.lang.Object implements Node
| Modifier | Constructor and Description |
|---|---|
|
AbstractNode(java.lang.String nodeName)
Constructs a node.
|
protected |
AbstractNode(java.lang.String nodeName,
Node parent)
Constructs a node.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAttributeChangeListener(AttributeChangeListener l)
Adds an listener that is notified when an attribute was changed.
|
void |
addElements(java.util.Collection<?> elements)
Adds some NodeElements to this FormattingObject.
|
void |
addElements(java.lang.Object[] elements)
Adds some NodeElements to this FormattingObject.
|
void |
clearEqualAttributes(Node node,
boolean deep)
Clears all attributes of this node, that are defined in the given node
with equal values.
|
boolean |
clearInheratedAttribute(java.lang.String name)
Clears an attributed that was defined by a parent node and
has same value.
|
void |
clearInheratedAttributes()
Clears all attributes that were defined by a parent node and
have same value.
|
void |
clearValue(java.lang.String name)
Clears an attribute, this means they value becomes NULL.
|
java.lang.Object |
clone()
Clones this element.
|
boolean |
contains(Node child)
Tests if this node contains the given node directly.
|
boolean |
contains(Node child,
boolean deep)
Tests if this node contains the given node.
|
void |
copyAttributes(Node node)
Copies all attributes of given node to this node.
|
protected static long |
createID()
Creates a unique ID for a node.
|
protected abstract java.lang.Object |
doGetAttribute(java.lang.String name)
Do implement this Method.
|
protected abstract boolean |
doSetAttribute(java.lang.String name,
java.lang.Object value)
Do implement this Method.
|
Node |
findFirstNodeWithText(java.lang.String text,
boolean deep) |
Node |
findNode(java.lang.String nodeName,
java.lang.String attrName,
java.lang.String attrValue)
Searches for a node with a specific attribute in this node.
|
java.util.List<Node> |
findNodesWithText(java.lang.String text,
boolean deep)
Finds all elements that contains a specific text.
|
protected void |
fire(ValueChangeEvent evt)
Fire a ValueChangeEvent.
|
void |
fireSaxEvents(org.xml.sax.ContentHandler handler)
Fires SAX events to a SAX content handler.
|
java.lang.Object |
firstElement()
Gets the first element of this node.
|
boolean |
getAttrAsBoolean(java.lang.String name,
boolean inherit,
boolean defValue)
Gets an boolean attribute.
|
int |
getAttrAsInteger(java.lang.String name,
boolean inherit,
int defaultValue) |
java.lang.String |
getAttrAsString(java.lang.String name)
Gets an attribute as String.
|
java.lang.String |
getAttrAsString(java.lang.String name,
boolean inherit)
Gets the value of an attribute as String.
|
java.lang.Object |
getAttribute(java.lang.String name)
Gets an attribute.
|
java.lang.Object |
getAttribute(java.lang.String name,
boolean inherit)
Gets the value of an attribute.
|
abstract java.util.Map<java.lang.String,java.lang.Object> |
getAttributeMap()
Gets a map of all defined attributes.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributeMap(java.lang.String[] attributes)
Gets a map of a specific set of attributes.
|
java.lang.String |
getContentText(boolean deep)
Gets only the text of this node.
|
java.lang.String |
getContentText(boolean deep,
int maxLength)
Gets only the text of this node.
|
java.util.Set<java.lang.String> |
getDefinedAttributes(boolean deep)
Gets a Set of all defined attributes.
|
abstract java.util.List<java.lang.Object> |
getElements()
Gets childreen of this node.
|
java.util.List<java.lang.Object> |
getElements(java.lang.Class<?> type)
Gets all direct elements of this node that are instances of
class
type. |
java.util.List<java.lang.Object> |
getElements(java.lang.Class<?> type,
boolean deep)
Finds all sub nodes of this node that are instance of
class
type. |
java.util.List<Node> |
getElements(java.lang.String name,
boolean deep)
Finds all sub nodes of this node that have the given name.
|
java.lang.Object |
getFirstElement(java.lang.Class<?> type)
Get the first direct element which is instance of
class
type |
int |
getIndex() |
java.lang.String |
getLocalName()
Gets the local name of this node.
|
java.lang.String |
getNamespacePrefix()
Gets the namespace prefix of this node.
|
java.util.Set<java.lang.String> |
getNamespacePrefixes(boolean inherated)
Gets a set of all defined namespace prefixes.
|
java.lang.String |
getNamespaceURI(java.lang.String prefix,
boolean inherated)
Gets the URI of a namespace prefix.
|
Node |
getParent()
Gets the parent of this node.
|
Node |
getParent(java.lang.Class<?> clazz)
Gets the nearest parent node that is an instance of class
clazz. |
Node |
getParent(java.lang.String qName)
Gets the nearest parent node with a specific name.
|
Node |
getParentOrThis(java.lang.Class<?> clazz)
Equal to
getParent(Class) but returns this node if this
is already an instance of class clazz. |
java.lang.String |
getQName()
Gets the full qualified name of this node.
|
Node |
getRoot()
Gets the root node of this node.
|
boolean |
hasEqualAttrs(Node node)
Tests if this and given node have equal attributes (with same values).
|
int |
indexOf(java.lang.Object child)
Gets the index of a child.
|
boolean |
isEmpty()
Determinates if this node has no elements.
|
java.lang.Object |
lastElement()
Gets the last element of this node.
|
void |
liftInheritedAttribute(java.lang.String name)
Copies inherited value of attribute name to
this node if attribute name is unset on this node and
name is inherited by any parent node.
|
void |
removeAttributeChangeListener(AttributeChangeListener l)
Removes a listener that was listener for attribute changes.
|
boolean |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the value of an attribute.
|
void |
setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributeMap)
Sets all attributes that are contained in the map.
|
boolean |
setAttrIfNotNull(java.lang.String name,
java.lang.Object value)
Sets the value of an attribute, but only if the given value is not NULL.
|
void |
setEnableAttributeChangeEvent(boolean enabled)
Sets, if value change events are fired, when setAttribute is called.
|
void |
setNamespace(java.lang.String prefix,
java.lang.String uri)
Sets a namespace.
|
void |
setParent(Node parent)
Sets the parent of this node.
|
protected void |
setQName(java.lang.String name)
Sets a new qualified node name.
|
void |
setUndefinedAttributes(java.util.Map<java.lang.String,?> attributeMap)
Sets all attributes that are contained in the given map and that are
not already defined by this node.
|
void |
writeTo(java.io.File file)
Writes full XML-tree of this node into given file.
|
void |
writeTo(java.io.OutputStream os)
Writes full XML-tree into give OutputStream as XML.
|
void |
writeTo(java.lang.String file)
Writes full XML-tree of this node into given file.
|
void |
writeTo(XMLWriter writer)
Writes this node through an XML-Writer.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddElement, addElement, removeElement, removeElement, replaceElement, setElementpublic AbstractNode(java.lang.String nodeName)
nodeName - XML-tag.protected AbstractNode(java.lang.String nodeName,
Node parent)
nodeName - XML-tag.parent - Parent node.public abstract java.util.List<java.lang.Object> getElements()
NodeElement or String.getElements in interface Nodepublic void addElements(java.util.Collection<?> elements)
elements - Collection of elements.public void addElements(java.lang.Object[] elements)
elements - Collection of elements.public abstract java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()
getAttributeMap in interface Nodepublic java.util.Map<java.lang.String,java.lang.Object> getAttributeMap(java.lang.String[] attributes)
attributes - Attributes.public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
NodeElementclone in interface NodeElementclone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic Node getParent()
getParent in interface NodeElementpublic Node getRoot()
public void setParent(Node parent)
setParent in interface NodeElementparent - Parent of this node.public void writeTo(XMLWriter writer)
writeTo in interface NodeElementwriter - Writer.public void addAttributeChangeListener(AttributeChangeListener l)
addAttributeChangeListener in interface Nodel - Listener.public void removeAttributeChangeListener(AttributeChangeListener l)
removeAttributeChangeListener in interface Nodel - Listener.public java.lang.String getQName()
public java.lang.String getLocalName()
getLocalName in interface Nodepublic Node getParent(java.lang.String qName)
qName - Qualified name of parent node.public Node getParent(java.lang.Class<?> clazz)
clazz.clazz - Classpublic Node getParentOrThis(java.lang.Class<?> clazz)
getParent(Class) but returns this node if this
is already an instance of class clazz.clazz - Classclazz or null.public int indexOf(java.lang.Object child)
public boolean hasEqualAttrs(Node node)
node - Nodetrue if this and given node have equal values.public java.lang.Object lastElement()
lastElement in interface Nodepublic java.lang.Object firstElement()
firstElement in interface Nodepublic final java.lang.Object getAttribute(java.lang.String name)
getAttribute in interface Nodename - Attribute name.public final java.lang.String getAttrAsString(java.lang.String name)
getAttrAsString in interface Nodename - Attribute name.public final java.lang.String getAttrAsString(java.lang.String name,
boolean inherit)
getAttrAsString in interface Nodename - Name of attribute.inherit - True if attribute can be defined by a parent node.public final boolean getAttrAsBoolean(java.lang.String name,
boolean inherit,
boolean defValue)
name - Name of attribute.inherit - Inherit attribute.defValue - Default value if attribute is unset.public final int getAttrAsInteger(java.lang.String name,
boolean inherit,
int defaultValue)
public final java.lang.Object getAttribute(java.lang.String name,
boolean inherit)
getAttribute in interface Nodename - Name of attribute.inherit - True if attribute can be defined by a parent node.public java.util.Set<java.lang.String> getDefinedAttributes(boolean deep)
getDefinedAttributes in interface Nodedeep - true, if defined of parent nodes are included.public final void liftInheritedAttribute(java.lang.String name)
name - Stringpublic java.lang.String getContentText(boolean deep)
getContentText in interface Nodedeep - true to include text of sub-nodes.public java.lang.String getContentText(boolean deep,
int maxLength)
deep - true to include text of sub-nodes.maxLength - Max length of text.public java.util.Set<java.lang.String> getNamespacePrefixes(boolean inherated)
getNamespacePrefixes in interface Nodeinherated - Get also defined namespaces of parent nodes.public void setNamespace(java.lang.String prefix,
java.lang.String uri)
setNamespace in interface Nodeprefix - Prefix of namespace.uri - URI of namespace.public java.lang.String getNamespacePrefix()
getNamespacePrefix in interface Nodepublic boolean isEmpty()
public void clearInheratedAttributes()
clearInheratedAttributes in interface Nodepublic boolean clearInheratedAttribute(java.lang.String name)
clearInheratedAttribute in interface Nodename - Name of attribute.true if attribute was cleared.public void clearEqualAttributes(Node node, boolean deep)
node - Node.deep - true search deep in node for attributes.public boolean contains(Node child)
child - Node.true if this node contains child.public boolean contains(Node child, boolean deep)
public void clearValue(java.lang.String name)
clearValue in interface Nodename - Name of the attribute.public final boolean setAttribute(java.lang.String name,
java.lang.Object value)
setAttribute in interface Nodename - Name of the attribute.value - New value.public final boolean setAttrIfNotNull(java.lang.String name,
java.lang.Object value)
name - Name of the attribute.value - New value.public void copyAttributes(Node node)
node - Node.public void setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributeMap)
setAttributes in interface NodeattributeMap - Map of attributes to values.public void setUndefinedAttributes(java.util.Map<java.lang.String,?> attributeMap)
attributeMap - Map of attributes to values.public void writeTo(java.io.OutputStream os)
throws java.io.IOException
os - OutputStreamjava.io.IOExceptionpublic void writeTo(java.io.File file)
throws java.io.IOException
file - File.java.io.IOExceptionpublic void writeTo(java.lang.String file)
throws java.io.IOException
file - File.java.io.IOExceptionpublic void setEnableAttributeChangeEvent(boolean enabled)
enabled - true, if ValueChangeEvents are fired.public Node findNode(java.lang.String nodeName, java.lang.String attrName, java.lang.String attrValue)
nodeName - Name of node.attrName - Name of attribute.attrValue - Value of attribute.public java.util.List<java.lang.Object> getElements(java.lang.Class<?> type)
type.type - Type.public java.util.List<java.lang.Object> getElements(java.lang.Class<?> type,
boolean deep)
type.type - Type.deep - true, if deep search.public java.lang.Object getFirstElement(java.lang.Class<?> type)
typetype - Type.public java.util.List<Node> getElements(java.lang.String name, boolean deep)
getElements in interface Nodename - Tag of sub-node.deep - true, if deep search.public void fireSaxEvents(org.xml.sax.ContentHandler handler)
throws org.xml.sax.SAXException
fireSaxEvents in interface Nodehandler - Content handler.org.xml.sax.SAXExceptionpublic java.util.List<Node> findNodesWithText(java.lang.String text, boolean deep)
text - Text to search.deep - Deep search.public Node findFirstNodeWithText(java.lang.String text, boolean deep)
public int getIndex()
protected abstract boolean doSetAttribute(java.lang.String name,
java.lang.Object value)
name - Name of attribute, always lower case.value - New value.protected abstract java.lang.Object doGetAttribute(java.lang.String name)
name - Name of attribute, always lower case.protected void fire(ValueChangeEvent evt)
evt - ValueChangeEvent.protected static final long createID()
protected final void setQName(java.lang.String name)
name - New name of node.public java.lang.String getNamespaceURI(java.lang.String prefix,
boolean inherated)
getNamespaceURI in interface Nodeprefix - Prefix of namespace.inherated - Regard also namespace definitions of parent nodes.© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.