A class representing a node in a meta-data tree, which implements
the
interface and additionally allows
for the storage of non-textual objects via the
This class is not intended to be used for general XML
processing. In particular, Element
nodes created
within the Image I/O API are not compatible with those created by
Sun's standard implementation of the org.w3.dom
API.
In particular, the implementation is tuned for simple uses and may
not perform well for intensive processing.
Namespaces are ignored in this implementation. The terms "tag
name" and "node name" are always considered to be synonymous.
Note:
The DOM Level 3 specification added a number of new methods to the
{@code Node}, {@code Element} and {@code Attr} interfaces that are not
of value to the {@code IIOMetadataNode} implementation or specification.
Calling such methods on an {@code IIOMetadataNode}, or an {@code Attr}
instance returned from an {@code IIOMetadataNode} will result in a
{@code DOMException} being thrown.
Method from javax.imageio.metadata.IIOMetadataNode Detail: |
public Node appendChild(Node newChild) {
if (newChild == null) {
throw new IllegalArgumentException("newChild == null!");
}
checkNode(newChild);
// insertBefore will increment numChildren
return insertBefore(newChild, null);
}
Adds the node newChild to the end of the list of
children of this node. |
public Node cloneNode(boolean deep) {
IIOMetadataNode newNode = new IIOMetadataNode(this.nodeName);
newNode.setUserObject(getUserObject());
// Attributes
if (deep) {
for (IIOMetadataNode child = firstChild;
child != null;
child = child.nextSibling) {
newNode.appendChild(child.cloneNode(true));
}
}
return newNode;
}
Returns a duplicate of this node. The duplicate node has no
parent (getParentNode returns null ).
If a shallow clone is being performed (deep is
false ), the new node will not have any children or
siblings. If a deep clone is being performed, the new node
will form the root of a complete cloned subtree. |
public short compareDocumentPosition(Node other) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public String getAttribute(String name) {
Attr attr = getAttributeNode(name);
if (attr == null) {
return "";
}
return attr.getValue();
}
Retrieves an attribute value by name. |
public String getAttributeNS(String namespaceURI,
String localName) {
return getAttribute(localName);
}
Equivalent to getAttribute(localName) . |
public Attr getAttributeNode(String name) {
Node node = getAttributes().getNamedItem(name);
return (Attr)node;
}
|
public Attr getAttributeNodeNS(String namespaceURI,
String localName) {
return getAttributeNode(localName);
}
Equivalent to getAttributeNode(localName) . |
public NamedNodeMap getAttributes() {
return new IIONamedNodeMap(attributes);
}
Returns a NamedNodeMap containing the attributes of
this node. |
public String getBaseURI() throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public NodeList getChildNodes() {
return this;
}
Returns a NodeList that contains all children of this node.
If there are no children, this is a NodeList containing
no nodes. |
public NodeList getElementsByTagName(String name) {
List l = new ArrayList();
getElementsByTagName(name, l);
return new IIONodeList(l);
}
|
public NodeList getElementsByTagNameNS(String namespaceURI,
String localName) {
return getElementsByTagName(localName);
}
Equivalent to getElementsByTagName(localName) . |
public Object getFeature(String feature,
String version) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public Node getFirstChild() {
return firstChild;
}
Returns the first child of this node, or null if
the node has no children. |
public Node getLastChild() {
return lastChild;
}
Returns the last child of this node, or null if
the node has no children. |
public int getLength() {
return numChildren;
}
|
public String getLocalName() {
return nodeName;
}
Equivalent to getNodeName . |
public String getNamespaceURI() throws DOMException {
return null;
}
Returns null , since namespaces are not supported. |
public Node getNextSibling() {
return nextSibling;
}
Returns the next sibling of this node, or null if
the node has no next sibling. |
public String getNodeName() {
return nodeName;
}
Returns the node name associated with this node. |
public short getNodeType() {
return ELEMENT_NODE;
}
Returns the node type, which is always
ELEMENT_NODE . |
public String getNodeValue() {
return nodeValue;
}
Returns the value associated with this node. |
public Document getOwnerDocument() {
return null;
}
Returns null , since IIOMetadataNode s
do not belong to any Document . |
public Node getParentNode() {
return parent;
}
Returns the parent of this node. A null value
indicates that the node is the root of its own tree. To add a
node to an existing tree, use one of the
insertBefore , replaceChild , or
appendChild methods. |
public String getPrefix() {
return null;
}
Returns null , since namespaces are not supported. |
public Node getPreviousSibling() {
return previousSibling;
}
Returns the previous sibling of this node, or null
if this node has no previous sibling. |
public TypeInfo getSchemaTypeInfo() throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public String getTagName() {
return nodeName;
}
Equivalent to getNodeName . |
public String getTextContent() throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public Object getUserData(String key) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public Object getUserObject() {
return userObject;
}
Returns the Object value associated with this node. |
public boolean hasAttribute(String name) {
return getAttributeNode(name) != null;
}
|
public boolean hasAttributeNS(String namespaceURI,
String localName) {
return hasAttribute(localName);
}
Equivalent to hasAttribute(localName) . |
public boolean hasAttributes() {
return attributes.size() > 0;
}
|
public boolean hasChildNodes() {
return numChildren > 0;
}
Returns true if this node has child nodes. |
public Node insertBefore(Node newChild,
Node refChild) {
if (newChild == null) {
throw new IllegalArgumentException("newChild == null!");
}
checkNode(newChild);
checkNode(refChild);
IIOMetadataNode newChildNode = (IIOMetadataNode)newChild;
IIOMetadataNode refChildNode = (IIOMetadataNode)refChild;
// Siblings, can be null.
IIOMetadataNode previous = null;
IIOMetadataNode next = null;
if (refChild == null) {
previous = this.lastChild;
next = null;
this.lastChild = newChildNode;
} else {
previous = refChildNode.previousSibling;
next = refChildNode;
}
if (previous != null) {
previous.nextSibling = newChildNode;
}
if (next != null) {
next.previousSibling = newChildNode;
}
newChildNode.parent = this;
newChildNode.previousSibling = previous;
newChildNode.nextSibling = next;
// N.B.: O.K. if refChild == null
if (this.firstChild == refChildNode) {
this.firstChild = newChildNode;
}
++numChildren;
return newChildNode;
}
Inserts the node newChild before the existing
child node refChild . If refChild is
null , insert newChild at the end of
the list of children. |
public boolean isDefaultNamespace(String namespaceURI) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public boolean isEqualNode(Node node) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public boolean isSameNode(Node node) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public boolean isSupported(String feature,
String version) {
return false;
}
Returns false since DOM features are not
supported. |
public Node item(int index) {
if (index < 0) {
return null;
}
Node child = getFirstChild();
while (child != null && index-- > 0) {
child = child.getNextSibling();
}
return child;
}
|
public String lookupNamespaceURI(String prefix) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public String lookupPrefix(String namespaceURI) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public void normalize() {
}
Does nothing, since IIOMetadataNode s do not
contain Text children. |
public void removeAttribute(String name) {
removeAttribute(name, true);
}
|
public void removeAttributeNS(String namespaceURI,
String localName) {
removeAttribute(localName);
}
Equivalent to removeAttribute(localName) . |
public Attr removeAttributeNode(Attr oldAttr) {
removeAttribute(oldAttr.getName());
return oldAttr;
}
|
public Node removeChild(Node oldChild) {
if (oldChild == null) {
throw new IllegalArgumentException("oldChild == null!");
}
checkNode(oldChild);
IIOMetadataNode oldChildNode = (IIOMetadataNode)oldChild;
IIOMetadataNode previous = oldChildNode.previousSibling;
IIOMetadataNode next = oldChildNode.nextSibling;
if (previous != null) {
previous.nextSibling = next;
}
if (next != null) {
next.previousSibling = previous;
}
if (this.firstChild == oldChildNode) {
this.firstChild = next;
}
if (this.lastChild == oldChildNode) {
this.lastChild = previous;
}
oldChildNode.parent = null;
oldChildNode.previousSibling = null;
oldChildNode.nextSibling = null;
--numChildren;
return oldChildNode;
}
Removes the child node indicated by oldChild from
the list of children, and returns it. |
public Node replaceChild(Node newChild,
Node oldChild) {
if (newChild == null) {
throw new IllegalArgumentException("newChild == null!");
}
checkNode(newChild);
checkNode(oldChild);
IIOMetadataNode newChildNode = (IIOMetadataNode)newChild;
IIOMetadataNode oldChildNode = (IIOMetadataNode)oldChild;
IIOMetadataNode previous = oldChildNode.previousSibling;
IIOMetadataNode next = oldChildNode.nextSibling;
if (previous != null) {
previous.nextSibling = newChildNode;
}
if (next != null) {
next.previousSibling = newChildNode;
}
newChildNode.parent = this;
newChildNode.previousSibling = previous;
newChildNode.nextSibling = next;
if (firstChild == oldChildNode) {
firstChild = newChildNode;
}
if (lastChild == oldChildNode) {
lastChild = newChildNode;
}
oldChildNode.parent = null;
oldChildNode.previousSibling = null;
oldChildNode.nextSibling = null;
return oldChildNode;
}
Replaces the child node oldChild with
newChild in the list of children, and returns the
oldChild node. |
public void setAttribute(String name,
String value) {
// Name must be valid unicode chars
boolean valid = true;
char[] chs = name.toCharArray();
for (int i=0;i< chs.length;i++) {
if (chs[i] >= 0xfffe) {
valid = false;
break;
}
}
if (!valid) {
throw new IIODOMException(DOMException.INVALID_CHARACTER_ERR,
"Attribute name is illegal!");
}
removeAttribute(name, false);
attributes.add(new IIOAttr(this, name, value));
}
|
public void setAttributeNS(String namespaceURI,
String qualifiedName,
String value) {
setAttribute(qualifiedName, value);
}
Equivalent to setAttribute(qualifiedName, value) . |
public Attr setAttributeNode(Attr newAttr) throws DOMException {
Element owner = newAttr.getOwnerElement();
if (owner != null) {
if (owner == this) {
return null;
} else {
throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
"Attribute is already in use");
}
}
IIOAttr attr;
if (newAttr instanceof IIOAttr) {
attr = (IIOAttr)newAttr;
attr.setOwnerElement(this);
} else {
attr = new IIOAttr(this,
newAttr.getName(),
newAttr.getValue());
}
Attr oldAttr = getAttributeNode(attr.getName());
if (oldAttr != null) {
removeAttributeNode(oldAttr);
}
attributes.add(attr);
return oldAttr;
}
|
public Attr setAttributeNodeNS(Attr newAttr) {
return setAttributeNode(newAttr);
}
Equivalent to setAttributeNode(newAttr) . |
public void setIdAttribute(String name,
boolean isId) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public void setIdAttributeNS(String namespaceURI,
String localName,
boolean isId) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public void setIdAttributeNode(Attr idAttr,
boolean isId) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public void setNodeValue(String nodeValue) {
this.nodeValue = nodeValue;
}
Sets the String value associated with this node. |
public void setPrefix(String prefix) {
}
Does nothing, since namespaces are not supported. |
public void setTextContent(String textContent) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public Object setUserData(String key,
Object data,
UserDataHandler handler) throws DOMException {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
"Method not supported");
}
This DOM Level 3 method is not supported for {@code IIOMetadataNode}
and will throw a {@code DOMException}. |
public void setUserObject(Object userObject) {
this.userObject = userObject;
}
Sets the value associated with this node. |