org.geotools.xml.impl
Class NodeImpl

java.lang.Object
  extended by org.geotools.xml.impl.NodeImpl
All Implemented Interfaces:
Node

public class NodeImpl
extends java.lang.Object
implements Node


Constructor Summary
NodeImpl(InstanceComponent component)
           
NodeImpl(InstanceComponent component, java.lang.Object value)
           
 
Method Summary
 void addAttribute(Node attribute)
           
 void addChild(Node child)
           
 Node getAttribute(java.lang.Class clazz)
          Returns the node corresponding to the attribute which has a parsed value which is an instance of clazz.
 Node getAttribute(java.lang.String name)
          Returns the node corresonding to the attribute with the specified name.
 java.util.List getAttributes()
          Returns all nodes corresponding to attributes.
 java.util.List getAttributes(java.lang.Class clazz)
          Returns all nodes corresponding to attributes which has a parsed values which are instances of clazz.
 java.lang.Object getAttributeValue(java.lang.Class clazz)
          Helper method for access to the parsed value of the attribute whose parsed value is an instance of clazz.
 java.lang.Object getAttributeValue(java.lang.Class clazz, java.lang.Object defaultValue)
          Helper method for access to the parsed value of the attribute whose parsed value is an instance of clazz, returning a defaultValue when no such attribute is present.
 java.lang.Object getAttributeValue(java.lang.String name)
          Helper method for access to the parsed value of the attribute with the specified name.
 java.lang.Object getAttributeValue(java.lang.String name, java.lang.Object defaultValue)
          Helper method for access to the parsed value of the attribute with the specified name, returning a defaultValue when no such attribute is present
 java.util.List getAttributeValues(java.lang.Class clazz)
          Helper method for access ot the parsed values of attribute nodes whose parsed values are instances of clazz.
 Node getChild(java.lang.Class clazz)
          Returns a node corresponding to a child element which has a parsed value which is an instance of clazz.
 Node getChild(java.lang.String name)
          Returns a node corresponding to a child element.
 java.util.List getChildren()
          Contents of this node.
 java.util.List getChildren(java.lang.Class clazz)
          Returns all nodes corresponding to child elements with the parsed values that are instances of clazz
 java.util.List getChildren(java.lang.String name)
          Returns all nodes corresponding child elements with the specified name.
 java.lang.Object getChildValue(java.lang.Class clazz)
          Helper method for access to child's parsed contents by class.
 java.lang.Object getChildValue(java.lang.Class clazz, java.lang.Object defaultValue)
          Helper method for access to child's parsed contents by class, returning a defaultValue when no such value is present
 java.lang.Object getChildValue(int index)
          Helper method for access to child's parsed contents.
 java.lang.Object getChildValue(java.lang.String name)
          Helper method for access to child's parsed contents by element name.
 java.lang.Object getChildValue(java.lang.String name, java.lang.Object defaultValue)
          Helper method for access to child's parsed contents by element name.returning a defaultValue when no such value is present
 java.util.List getChildValues(java.lang.Class clazz)
          Helper method for access to the set of parsed child values which are instances of the specified class.
 java.util.List getChildValues(java.lang.String name)
          Helper method for access to the set of parse child values with the specified name.
 InstanceComponent getComponent()
           
 int getNAttributes()
           
 int getNChildren()
           
 java.lang.Object getValue()
           
 boolean hasAttribute(java.lang.Class clazz)
          Determines if the node has an attribute whose value is of the specified class.
 boolean hasAttribute(java.lang.String name)
          Determines if the node has an attribute with the specified name.
 boolean hasChild(java.lang.Class clazz)
          Determines if the node has a child whose value is of the specified class.
 boolean hasChild(java.lang.String name)
          Determines if the node has a child with the specified name.
 Node removeAttribute(java.lang.String name)
           
 void removeChild(Node child)
           
 Node removeChild(java.lang.String name)
           
 void setValue(java.lang.Object value)
          Sets the value of the node.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeImpl

public NodeImpl(InstanceComponent component)

NodeImpl

public NodeImpl(InstanceComponent component,
                java.lang.Object value)
Method Detail

getComponent

public InstanceComponent getComponent()
Specified by:
getComponent in interface Node
Returns:
The component instance.

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface Node
Returns:
The parsed value of the instance component.

setValue

public void setValue(java.lang.Object value)
Description copied from interface: Node
Sets the value of the node.

Specified by:
setValue in interface Node
Parameters:
value - The new parse value.

hasChild

public boolean hasChild(java.lang.String name)
Description copied from interface: Node
Determines if the node has a child with the specified name.

Specified by:
hasChild in interface Node
Parameters:
name - The name of a child node.
Returns:
true if a child node exists with the name, otehrwise false.

hasChild

public boolean hasChild(java.lang.Class clazz)
Description copied from interface: Node
Determines if the node has a child whose value is of the specified class.

Specified by:
hasChild in interface Node
Parameters:
clazz - The class of the child node value.
Returns:
true if a child node exists with the class, otherwise false.

getChildren

public java.util.List getChildren()
Contents of this node.

XXX: either return unmodifeable Collection, or return the collection directly. Client code should make the copy iff they need it. Going to try changing it and see what breaks.

Specified by:
getChildren in interface Node
Returns:
A list containing objects of type Node.
See Also:
Node.getChildren()

getNChildren

public int getNChildren()

getChildren

public java.util.List getChildren(java.lang.String name)
Description copied from interface: Node
Returns all nodes corresponding child elements with the specified name. This method returns an empty list if it finds no nodes corresponding to the specified name.

Specified by:
getChildren in interface Node
Parameters:
name - The name of a child element.
Returns:
A list containing objects of type Node.

getChildren

public java.util.List getChildren(java.lang.Class clazz)
Description copied from interface: Node
Returns all nodes corresponding to child elements with the parsed values that are instances of clazz

Specified by:
getChildren in interface Node
Parameters:
clazz - The class of parsed child values.
Returns:
A list containing objects of type Node, such that node#getValue() is an instance of clazz, or an empty list.

getChild

public Node getChild(java.lang.String name)
Description copied from interface: Node
Returns a node corresponding to a child element. This method returns the first such node it finds and no order is guaranteed, it is provided for convenience. This method returns null if it finds no such child node matching the specified name.

Specified by:
getChild in interface Node
Parameters:
name - The name of a child element.
Returns:
The first node that matches a child element with the specified name.

getChild

public Node getChild(java.lang.Class clazz)
Description copied from interface: Node
Returns a node corresponding to a child element which has a parsed value which is an instance of clazz. This method returns the first such node it finds and no order is guarenteed, it is providedd for convenience. This method returns null if it finds no such child mathing the above criteria.

Specified by:
getChild in interface Node
Parameters:
clazz - The class of the parsed value of a child element.
Returns:
The first node found, or null.

hasAttribute

public boolean hasAttribute(java.lang.Class clazz)
Description copied from interface: Node
Determines if the node has an attribute whose value is of the specified class.

Specified by:
hasAttribute in interface Node
Parameters:
clazz - The class of the attribute value
Returns:
true if an attribute exists with the class, otherwise false.

hasAttribute

public boolean hasAttribute(java.lang.String name)
Description copied from interface: Node
Determines if the node has an attribute with the specified name.

Specified by:
hasAttribute in interface Node
Parameters:
name - The name of an attribute
Returns:
true if am attribute exists with the name, otehrwise false.

getAttributes

public java.util.List getAttributes()
Description copied from interface: Node
Returns all nodes corresponding to attributes.

Specified by:
getAttributes in interface Node
Returns:
A list containing objects of type node.

getAttributes

public java.util.List getAttributes(java.lang.Class clazz)
Description copied from interface: Node
Returns all nodes corresponding to attributes which has a parsed values which are instances of clazz.

Specified by:
getAttributes in interface Node
Parameters:
clazz - The class of parsed attribute values.
Returns:
A list of attribute nodes whose parsed values are instances of clazz, or an empty list.

getNAttributes

public int getNAttributes()

getAttribute

public Node getAttribute(java.lang.String name)
Description copied from interface: Node
Returns the node corresonding to the attribute with the specified name. This method returns null if it finds no such attribute node matching the specified name.

Specified by:
getAttribute in interface Node
Parameters:
name - The name of the attribute.

getAttribute

public Node getAttribute(java.lang.Class clazz)
Description copied from interface: Node
Returns the node corresponding to the attribute which has a parsed value which is an instance of clazz. In the event that the node contains multple attributes matching the above criteria, the first encountered is returned, with no guaratnee of order. For all nodes matching this criteria use Node.getAttributes(Class).

Specified by:
getAttribute in interface Node
Parameters:
clazz - The class of parsed attribute values.
Returns:
The attribute node whose parsed value is an instance of clazz, or null if no such node exists.

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String name)
Description copied from interface: Node
Helper method for access to the parsed value of the attribute with the specified name.

Specified by:
getAttributeValue in interface Node
Parameters:
name - The name of the attribute in which to retreive the parsed value from.
Returns:
the parsed value of the attribute matching the criteria, or null if no such attribute is found.

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.Class clazz)
Description copied from interface: Node
Helper method for access to the parsed value of the attribute whose parsed value is an instance of clazz. In the event that the node contains multple attributes matching the above criteria, the first encountered is returned, with no guaratnee of order. For all values matching this criteria use Node.getAttributeValues(Class).

Specified by:
getAttributeValue in interface Node
Parameters:
clazz - The class of parsed attribute values.
Returns:
the parsed value of the attribute matching the criteria, or null if no such attribute is found.

getAttributeValues

public java.util.List getAttributeValues(java.lang.Class clazz)
Description copied from interface: Node
Helper method for access ot the parsed values of attribute nodes whose parsed values are instances of clazz.

Specified by:
getAttributeValues in interface Node
Parameters:
clazz - The class of parsed attribute values.
Returns:
The list of attribute values which are instances of clazz, or an empty list.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getChildValue

public java.lang.Object getChildValue(int index)
Description copied from interface: Node
Helper method for access to child's parsed contents.

Should be in the range of getChildren().size()

Simple helper method for the contents of getChildren: return ((Node)getChildren.get( index )).getValue();

Specified by:
getChildValue in interface Node
Returns:
the value of the child at the given index

getChildValue

public java.lang.Object getChildValue(java.lang.String name)
Description copied from interface: Node
Helper method for access to child's parsed contents by element name.

In the event that the node has multiple children mathing name the first encountered is returned, there is no guarantee of order. For a list of all values matching name use Node.getChildValues(String).

Specified by:
getChildValue in interface Node
Parameters:
name - The name of the child which parsed content is to be retrived.
Returns:
the value of the child with the given name, or null if the child does not exist.

getChildValue

public java.lang.Object getChildValue(java.lang.Class clazz)
Description copied from interface: Node
Helper method for access to child's parsed contents by class.

In the event that the node has multiple children which are instances of clazz, the first is returned, there is no guarantee of order. For a list of all values which are instances of clazz use Node.getChildValues(Class).

Specified by:
getChildValue in interface Node
Parameters:
clazz - The class of parsed child value.
Returns:
the value of the child which is an instance of clazz, or null if no such child exists.

getChildValues

public java.util.List getChildValues(java.lang.String name)
Description copied from interface: Node
Helper method for access to the set of parse child values with the specified name.

Specified by:
getChildValues in interface Node
Parameters:
name - The name of the child element in which to retreive the parsed value.
Returns:
A list of values representing the parsed values of the children, or an empty list of no such values exist.

getChildValues

public java.util.List getChildValues(java.lang.Class clazz)
Description copied from interface: Node
Helper method for access to the set of parsed child values which are instances of the specified class.

Specified by:
getChildValues in interface Node
Parameters:
clazz - The class of the child values.
Returns:
A list of child values which are instances of class, or an empty list if no such values exist.

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String name,
                                          java.lang.Object defaultValue)
Description copied from interface: Node
Helper method for access to the parsed value of the attribute with the specified name, returning a defaultValue when no such attribute is present

Specified by:
getAttributeValue in interface Node
Parameters:
name - The name of the attribute in which to retreive the parsed value from.
defaultValue - A defaultValue to return, if no such attribute found.
Returns:
the parsed value of the attribute matching the criteria, or defaultValue if no such attribute is found.

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.Class clazz,
                                          java.lang.Object defaultValue)
Description copied from interface: Node
Helper method for access to the parsed value of the attribute whose parsed value is an instance of clazz, returning a defaultValue when no such attribute is present. In the event that the node contains multple attributes matching the above criteria, the first encountered is returned, with no guaratnee of order. For all values matching this criteria use Node.getAttributeValues(Class).

Specified by:
getAttributeValue in interface Node
Parameters:
clazz - The class of parsed attribute values.
defaultValue - A defaultValue to return, if no such attribute found.
Returns:
the parsed value of the attribute matching the criteria, or defaultValue if no such attribute is found.

getChildValue

public java.lang.Object getChildValue(java.lang.String name,
                                      java.lang.Object defaultValue)
Description copied from interface: Node
Helper method for access to child's parsed contents by element name.returning a defaultValue when no such value is present

In the event that the node has multiple children mathing name the first encountered is returned, there is no guarantee of order. For a list of all values matching name use Node.getChildValues(String).

Specified by:
getChildValue in interface Node
Parameters:
name - The name of the child which parsed content is to be retrived.
defaultValue - A defaultValue to return, if no such child found.
Returns:
the value of the child with the given name, or defaultValue if the child does not exist.

getChildValue

public java.lang.Object getChildValue(java.lang.Class clazz,
                                      java.lang.Object defaultValue)
Description copied from interface: Node
Helper method for access to child's parsed contents by class, returning a defaultValue when no such value is present

In the event that the node has multiple children which are instances of clazz, the first is returned, there is no guarantee of order. For a list of all values which are instances of clazz use Node.getChildValues(Class).

Specified by:
getChildValue in interface Node
Parameters:
clazz - The class of parsed child value.
defaultValue - A defaultValue to return, if no such child found.
Returns:
the value of the child which is an instance of clazz, or defaultValue if no such child exists.

addChild

public void addChild(Node child)

removeChild

public Node removeChild(java.lang.String name)

removeChild

public void removeChild(Node child)

addAttribute

public void addAttribute(Node attribute)

removeAttribute

public Node removeAttribute(java.lang.String name)


Copyright © 1996-2010 Geotools. All Rights Reserved.