|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jsxe.dom.AdapterNode
The AdapterNode class is meant to provide extensions to the W3C Node interface by wrapping around existing nodes created after a document is parsed. It provides some extra event functionality and some methods for editing nodes in a DOM tree.
Because AdapterNodes are part of an XMLDocument they must be created by their owning XMLDocument object via the newAdapterNode methods
XMLDocument
,
XMLDocument#addAdapterNode(AdapterNode, String, String, short)
Field Summary | |
static short |
ATTRIBUTE_NODE
|
static short |
CDATA_SECTION_NODE
|
static short |
COMMENT_NODE
|
static short |
DOCUMENT_FRAGMENT_NODE
|
static short |
DOCUMENT_NODE
|
static short |
DOCUMENT_TYPE_NODE
|
static short |
ELEMENT_NODE
|
static short |
ENTITY_NODE
|
static short |
ENTITY_REFERENCE_NODE
|
static short |
NOTATION_NODE
|
static short |
PROCESSING_INSTRUCTION_NODE
|
static short |
TEXT_NODE
|
Method Summary | |
AdapterNode |
addAdapterNode(AdapterNode node)
Adds an already existing AdapterNode to this node as a child. |
AdapterNode |
addAdapterNode(String name,
String value,
short type,
int index)
Adds a new child to this node given the node name, value, and type. |
AdapterNode |
addAdapterNodeAt(AdapterNode node,
int location)
Adds an already existing AdapterNode to this node at a specified location. |
void |
addAdapterNodeListener(AdapterNodeListener listener)
Adds an AdapterNodeListener to be notified when this node changes |
AdapterNode |
child(int index)
Gets the child node at the given index. |
int |
childCount()
Gets the number of children that this node has. |
AdapterNode |
copy(boolean deep)
Copies this node into a new AdapterNode. |
boolean |
equals(Object node)
Compares this AdapterNode with another. |
void |
fireStructureChanged()
|
List |
getAllowedElements()
Gets a sorted list of all the elements (ElementDecl objects) allowed as children of this node as defined in the DTD or Schema. |
String |
getAttribute(String name)
Gets the value of an attribute associated with this node. |
String |
getAttributeAt(int index)
Gets the value of an attribute at the given index |
String |
getAttributeNameAt(int index)
Gets the qualified name of an attribute at the given index |
NamedNodeMap |
getAttributes()
Gets the attributes associated with this node. |
ElementDecl |
getElementDecl()
Gets the Element declaration that defines this element |
String |
getLocalName()
Gets the local name of this node. |
String |
getNodeName()
Gets the full qualified name for this node including the local name and namespace prefix. |
short |
getNodeType()
Gets the type of the node specified in the W3C Node interface. |
String |
getNodeValue()
Gets the current value if this node. |
String |
getNSPrefix()
Gets the namespace prefix for this node. |
XMLDocument |
getOwnerDocument()
Gets the XMLDocument that owns this AdapterNode |
AdapterNode |
getParentNode()
Gets the parent AdapterNode object. |
String |
getProperty(String key)
Gets a property for the key given. |
String |
getProperty(String key,
String defaultValue)
Gets a property for the key given or returns the default value if there is no property for the given key. |
int |
index(AdapterNode child)
Returns the index of the given AdapterNode if it is a child. |
void |
remove(AdapterNode child)
Removes a child from this node. |
void |
removeAdapterNodeListener(AdapterNodeListener listener)
Removes a listener from this node if it exists |
void |
removeAttribute(String attr)
Removes an attribute by name. |
void |
removeAttributeAt(int index)
Removes an attribute at the given index. |
String |
serializeToString()
Serializes this Node to a string based on the last owning XMLDocument's properties. |
void |
setAttribute(String name,
String value)
Sets an attribute of this node. |
void |
setLocalName(String localName)
Sets the local name of the node. |
void |
setNodeName(String qualifiedName)
Sets the full qualified name of this node. |
void |
setNodeValue(String str)
Sets the value of the node. |
void |
setNSPrefix(String prefix)
Sets the namespace prefix for this node. |
String |
setProperty(String key,
String value)
Sets a property of the AdapterNode |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final short ATTRIBUTE_NODE
public static final short CDATA_SECTION_NODE
public static final short COMMENT_NODE
public static final short DOCUMENT_FRAGMENT_NODE
public static final short DOCUMENT_NODE
public static final short DOCUMENT_TYPE_NODE
public static final short ELEMENT_NODE
public static final short ENTITY_NODE
public static final short ENTITY_REFERENCE_NODE
public static final short NOTATION_NODE
public static final short PROCESSING_INSTRUCTION_NODE
public static final short TEXT_NODE
Method Detail |
public XMLDocument getOwnerDocument()
public String getProperty(String key)
key
- the key to the properties list
public String getProperty(String key, String defaultValue)
key
- the key to the properties listdefaultValue
- the default value for the property requested
public String setProperty(String key, String value)
key
- the key to the propertyvalue
- the value of the property
public int index(AdapterNode child)
Returns the index of the given AdapterNode if it is a child.
child
- the child node of this node
public AdapterNode copy(boolean deep)
deep
- if true then the subtree is copied as well.public AdapterNode child(int index)
Gets the child node at the given index.
index
- the index of the requested node
public int childCount()
Gets the number of children that this node has.
public String getNSPrefix()
public void setNSPrefix(String prefix) throws DOMException
prefix
- The new prefix for this node
DOMException
- if this namespace prefix is not valid.
INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character, per the XML 1.0 specification .
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the specified prefix is malformed per the Namespaces in XML specification, if the namespaceURI of this node is null, if the specified prefix is "xml" and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from " http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of this node is "xmlns" .public String getNodeName()
public void setNodeName(String qualifiedName) throws DOMException
qualifiedName
- the new qualified name
DOMException
public String getLocalName()
Gets the local name of this node.
public void setLocalName(String localName) throws DOMException
Sets the local name of the node.
DOMException
- INVALID_CHARACTER_ERR: Raised if the specified name
contains an illegal character.public String getNodeValue()
Gets the current value if this node.
public void setNodeValue(String str) throws DOMException
Sets the value of the node.
str
- the new value of the node
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is
readonly.
DOMException
- DOMSTRING_SIZE_ERR: Raised when it would return
more characters than fit in a DOMString variable on
the implementation platform.public short getNodeType()
Gets the type of the node specified in the W3C Node interface.
public AdapterNode getParentNode()
Gets the parent AdapterNode object.
public NamedNodeMap getAttributes()
Gets the attributes associated with this node.
null
if this is not an element nodepublic AdapterNode addAdapterNode(String name, String value, short type, int index) throws DOMException
Adds a new child to this node given the node name, value, and type.
name
- the name of the new child nodevalue
- the value of the new child nodetype
- the type of the new child node as specified by the W3C Node
interface
DOMException
- INVALID_CHARACTER_ERR: Raised if the specified name
or value contains an illegal character.
DOMException
- NOT_SUPPORTED_ERR: Raised if the node type is not
supported.
DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a
type that does not allow children of the type of the
newChild node, or if the node to append is one of this
node's ancestors or this node itself.
DOMException
- WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created
this node.
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonly or if the previous parent of the node being
inserted is readonly.public AdapterNode addAdapterNode(AdapterNode node) throws DOMException
node
- the node to be added.
DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a
type that does not allow children of the type of the
newChild node, or if the node to append is one of this
node's ancestors or this node itself.
DOMException
- WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created
this node.
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonly or if the previous parent of the node being
inserted is readonly.public AdapterNode addAdapterNodeAt(AdapterNode node, int location) throws DOMException
(location == childCount())
then the
node is added at the end.
node
- the node to add to this parent node.location
- the location to add it at.
DOMException
- if the addition of the node is not allowed or the
location is invalid.public void remove(AdapterNode child) throws DOMException
Removes a child from this node.
child
- the child node to remove from this node
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonly.
DOMException
- NOT_FOUND_ERR: Raised if oldChild is not
a child of this node.public void setAttribute(String name, String value) throws DOMException
Sets an attribute of this node. If the specified attribute does not exist it is created.
name
- the qualified name of the attributevalue
- the new value of the attribute
DOMException
- NOT_SUPPORTED_ERR: if this is not an element node
DOMException
- INVALID_CHARACTER_ERR: Raised if the specified
qualified name contains an illegal character, per
the XML 1.0 specification
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonlypublic String getAttribute(String name) throws DOMException
Gets the value of an attribute associated with this node.
name
- the qualified name of the attribute
DOMException
- NOT_SUPPORTED_ERR: if this is not an element nodepublic void removeAttributeAt(int index) throws DOMException
Removes an attribute at the given index.
Note: Attributes are sorted alphabetically.
index
- the index of the node to remove
DOMException
- NOT_SUPPORTED_ERR: if this is not an element node
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonlypublic void removeAttribute(String attr) throws DOMException
Removes an attribute by name.
attr
- the qualified name of the attribute to remove
DOMException
- NOT_SUPPORTED_ERR: if this is not an element node
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonlypublic String getAttributeNameAt(int index) throws DOMException
Gets the qualified name of an attribute at the given index
Note: Attributes are sorted alphabetically.
index
- the index of the attribute to get
DOMException
- NOT_SUPPORTED_ERR: if this is not an element nodepublic String getAttributeAt(int index) throws DOMException
Gets the value of an attribute at the given index
Note: Attributes are sorted alphabetically.
index
- the index of the attribute to get
DOMException
- NOT_SUPPORTED_ERR: if this is not an element nodepublic List getAllowedElements()
public ElementDecl getElementDecl()
public boolean equals(Object node)
Compares this AdapterNode with another.
node
- the AdapterNode to compare to
public void addAdapterNodeListener(AdapterNodeListener listener)
Adds an AdapterNodeListener to be notified when this node changes
listener
- the listener to addpublic void removeAdapterNodeListener(AdapterNodeListener listener)
Removes a listener from this node if it exists
listener
- the listener to removepublic String serializeToString()
public String toString()
public void fireStructureChanged()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |