Class NodeImpl
- Object
-
- NodeImpl
-
-
Constructor Summary
Constructors Constructor Description NodeImpl(InstanceComponent component)NodeImpl(InstanceComponent component, Object value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(Node attribute)voidaddChild(Node child)voidcollapseWhitespace()NodegetAttribute(Class<?> clazz)Returns the node corresponding to the attribute which has a parsed value which is an instance ofclazz.NodegetAttribute(String name)Returns the node corresonding to the attribute with the specified name.List<Node>getAttributes()Returns all nodes corresponding to attributes.List<Node>getAttributes(Class<?> clazz)Returns all nodes corresponding to attributes which has a parsed values which are instances ofclazz.ObjectgetAttributeValue(Class<?> clazz)Helper method for access to the parsed value of the attribute whose parsed value is an instance ofclazz.ObjectgetAttributeValue(Class clazz, Object defaultValue)Helper method for access to the parsed value of the attribute whose parsed value is an instance ofclazz, returning adefaultValuewhen no such attribute is present.ObjectgetAttributeValue(String name)Helper method for access to the parsed value of the attribute with the specified name.ObjectgetAttributeValue(String name, Object defaultValue)Helper method for access to the parsed value of the attribute with the specified name, returning adefaultValuewhen no such attribute is presentList<Object>getAttributeValues(Class<?> clazz)Helper method for access ot the parsed values of attribute nodes whose parsed values are instances ofclazz.NodegetChild(Class<?> clazz)Returns a node corresponding to a child element which has a parsed value which is an instance ofclazz.NodegetChild(String name)Returns a node corresponding to a child element.List<Node>getChildren()Contents of this node.List<Node>getChildren(Class<?> clazz)Returns all nodes corresponding to child elements with the parsed values that are instances ofclazzList<Node>getChildren(String name)Returns all nodes corresponding child elements with the specified name.ObjectgetChildValue(int index)Helper method for access to child's parsed contents.<T> TgetChildValue(Class<T> clazz)Helper method for access to child's parsed contents by class.<T> TgetChildValue(Class<T> clazz, T defaultValue)Helper method for access to child's parsed contents by class, returning a defaultValue when no such value is presentObjectgetChildValue(String name)Helper method for access to child's parsed contents by element name.ObjectgetChildValue(String name, Object defaultValue)Helper method for access to child's parsed contents by element name.returning a defaultValue when no such value is present<T> List<T>getChildValues(Class<T> clazz)Helper method for access to the set of parsed child values which are instances of the specified class.List<Object>getChildValues(String name)Helper method for access to the set of parse child values with the specified name.InstanceComponentgetComponent()intgetNAttributes()intgetNChildren()NodegetParent()Returns the parent node for this nodeObjectgetValue()booleanhasAttribute(Class<?> clazz)Determines if the node has an attribute whose value is of the specified class.booleanhasAttribute(String name)Determines if the node has an attribute with the specified name.booleanhasChild(Class<?> clazz)Determines if the node has a child whose value is of the specified class.booleanhasChild(String name)Determines if the node has a child with the specified name.NoderemoveAttribute(String name)NoderemoveChild(String name)voidremoveChild(Node child)voidsetParent(Node parent)Sets the parent pointer for this node.voidsetValue(Object value)Sets the value of the node.StringtoString()
-
-
-
Constructor Detail
-
NodeImpl
public NodeImpl(InstanceComponent component)
-
NodeImpl
public NodeImpl(InstanceComponent component, Object value)
-
-
Method Detail
-
getComponent
public InstanceComponent getComponent()
- Specified by:
getComponentin interfaceNode- Returns:
- The component instance.
-
getValue
public Object getValue()
-
setValue
public void setValue(Object value)
Description copied from interface:NodeSets the value of the node.
-
hasChild
public boolean hasChild(String name)
Description copied from interface:NodeDetermines if the node has a child with the specified name.
-
hasChild
public boolean hasChild(Class<?> clazz)
Description copied from interface:NodeDetermines if the node has a child whose value is of the specified class.
-
getChildren
public List<Node> 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:
getChildrenin interfaceNode- Returns:
- A list containing objects of type Node.
- See Also:
Node.getChildren()
-
getNChildren
public int getNChildren()
-
getChildren
public List<Node> getChildren(String name)
Description copied from interface:NodeReturns 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:
getChildrenin interfaceNode- Parameters:
name- The name of a child element.- Returns:
- A list containing objects of type Node.
-
getChildren
public List<Node> getChildren(Class<?> clazz)
Description copied from interface:NodeReturns all nodes corresponding to child elements with the parsed values that are instances ofclazz- Specified by:
getChildrenin interfaceNode- 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(String name)
Description copied from interface:NodeReturns 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.
-
getChild
public Node getChild(Class<?> clazz)
Description copied from interface:NodeReturns a node corresponding to a child element which has a parsed value which is an instance ofclazz. This method returns the first such node it finds and no order is guarenteed, it is providedd for convenience. This method returnsnull if it finds no such child mathing the above criteria.
-
hasAttribute
public boolean hasAttribute(Class<?> clazz)
Description copied from interface:NodeDetermines if the node has an attribute whose value is of the specified class.- Specified by:
hasAttributein interfaceNode- Parameters:
clazz- The class of the attribute value- Returns:
trueif an attribute exists with the class, otherwisefalse.
-
hasAttribute
public boolean hasAttribute(String name)
Description copied from interface:NodeDetermines if the node has an attribute with the specified name.- Specified by:
hasAttributein interfaceNode- Parameters:
name- The name of an attribute- Returns:
trueif am attribute exists with the name, otehrwisefalse.
-
getAttributes
public List<Node> getAttributes()
Description copied from interface:NodeReturns all nodes corresponding to attributes.- Specified by:
getAttributesin interfaceNode- Returns:
- A list containing objects of type node.
-
getAttributes
public List<Node> getAttributes(Class<?> clazz)
Description copied from interface:NodeReturns all nodes corresponding to attributes which has a parsed values which are instances ofclazz.- Specified by:
getAttributesin interfaceNode- 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(String name)
Description copied from interface:NodeReturns 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:
getAttributein interfaceNode- Parameters:
name- The name of the attribute.
-
getAttribute
public Node getAttribute(Class<?> clazz)
Description copied from interface:NodeReturns the node corresponding to the attribute which has a parsed value which is an instance ofclazz. 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 useNode.getAttributes(Class).- Specified by:
getAttributein interfaceNode- Parameters:
clazz- The class of parsed attribute values.- Returns:
- The attribute node whose parsed value is an instance of
clazz, ornullif no such node exists.
-
getAttributeValue
public Object getAttributeValue(String name)
Description copied from interface:NodeHelper method for access to the parsed value of the attribute with the specified name.- Specified by:
getAttributeValuein interfaceNode- 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
nullif no such attribute is found.
-
getAttributeValue
public Object getAttributeValue(Class<?> clazz)
Description copied from interface:NodeHelper method for access to the parsed value of the attribute whose parsed value is an instance ofclazz. 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 useNode.getAttributeValues(Class).- Specified by:
getAttributeValuein interfaceNode- Parameters:
clazz- The class of parsed attribute values.- Returns:
- the parsed value of the attribute matching the criteria, or
nullif no such attribute is found.
-
getAttributeValues
public List<Object> getAttributeValues(Class<?> clazz)
Description copied from interface:NodeHelper method for access ot the parsed values of attribute nodes whose parsed values are instances ofclazz.- Specified by:
getAttributeValuesin interfaceNode- Parameters:
clazz- The class of parsed attribute values.- Returns:
- The list of attribute values which are instances of
clazz, or an empty list.
-
getChildValue
public Object getChildValue(int index)
Description copied from interface:NodeHelper 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:
getChildValuein interfaceNode- Returns:
- the value of the child at the given index
-
getChildValue
public Object getChildValue(String name)
Description copied from interface:NodeHelper method for access to child's parsed contents by element name.In the event that the node has multiple children matching
name the first encountered is returned, there is no guarantee of order. For a list of all values matching name useNode.getChildValues(String).- Specified by:
getChildValuein interfaceNode- Parameters:
name- The name of the child which parsed content is to be retrieved.- Returns:
- the value of the child with the given name, or
nullif the child does not exist.
-
getChildValue
public <T> T getChildValue(Class<T> clazz)
Description copied from interface:NodeHelper 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 ofclazzuseNode.getChildValues(Class).- Specified by:
getChildValuein interfaceNode- Parameters:
clazz- The class of parsed child value.- Returns:
- the value of the child which is an instance of
clazz, ornullif no such child exists.
-
getChildValues
public List<Object> getChildValues(String name)
Description copied from interface:NodeHelper method for access to the set of parse child values with the specified name.- Specified by:
getChildValuesin interfaceNode- 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 <T> List<T> getChildValues(Class<T> clazz)
Description copied from interface:NodeHelper method for access to the set of parsed child values which are instances of the specified class.- Specified by:
getChildValuesin interfaceNode- 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 Object getAttributeValue(String name, Object defaultValue)
Description copied from interface:NodeHelper method for access to the parsed value of the attribute with the specified name, returning adefaultValuewhen no such attribute is present- Specified by:
getAttributeValuein interfaceNode- 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
defaultValueif no such attribute is found.
-
getAttributeValue
public Object getAttributeValue(Class clazz, Object defaultValue)
Description copied from interface:NodeHelper method for access to the parsed value of the attribute whose parsed value is an instance ofclazz, returning adefaultValuewhen 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 useNode.getAttributeValues(Class).- Specified by:
getAttributeValuein interfaceNode- 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
defaultValueif no such attribute is found.
-
getChildValue
public Object getChildValue(String name, Object defaultValue)
Description copied from interface:NodeHelper method for access to child's parsed contents by element name.returning a defaultValue when no such value is presentIn 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 useNode.getChildValues(String).- Specified by:
getChildValuein interfaceNode- 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
defaultValueif the child does not exist.
-
getChildValue
public <T> T getChildValue(Class<T> clazz, T defaultValue)
Description copied from interface:NodeHelper method for access to child's parsed contents by class, returning a defaultValue when no such value is presentIn 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 ofclazzuseNode.getChildValues(Class).- Specified by:
getChildValuein interfaceNode- 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, ordefaultValueif no such child exists.
-
addChild
public void addChild(Node child)
-
removeChild
public void removeChild(Node child)
-
getParent
public Node getParent()
Description copied from interface:NodeReturns the parent node for this node
-
setParent
public void setParent(Node parent)
Description copied from interface:NodeSets the parent pointer for this node. Call with a null parameter to clear the parent pointer
-
addAttribute
public void addAttribute(Node attribute)
-
collapseWhitespace
public void collapseWhitespace()
-
-