|
|||||||||
| Home >> All >> com >> aendvari >> common >> [ osm overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.aendvari.common.osm
Class OsmNode

java.lang.Objectcom.aendvari.common.osm.OsmNode
- Direct Known Subclasses:
- Osm
- public class OsmNode
- extends java.lang.Object
Represents a single node in the Object Space Model tree.
An OsmNode has a parent and zero or more child nodes. A single Object
value may be stored within an OsmNode.
| Field Summary | |
protected java.util.HashMap |
attributes
The attributes of this node. |
protected java.util.ArrayList |
children
Children nodes. |
protected java.lang.String |
name
The node name. |
protected OsmNode |
parent
The parent node. |
protected int |
position
The child position in the parent. |
protected java.lang.Object |
value
The node value. |
| Constructor Summary | |
protected |
OsmNode()
Constructs an OsmNode instance. |
protected |
OsmNode(OsmNode setNode)
Constructs an OsmNode instance as a copy of the supplied node. |
protected |
OsmNode(java.lang.String setName,
java.lang.Object setValue)
Constructs an OsmNode instance using the supplied value. |
| Method Summary | |
OsmNode |
appendChild(OsmNode newChild)
Adds the node newChild to the end of the list of children of this node. |
OsmNode |
cloneNode(boolean deep)
Returns a duplicate of this node. |
java.util.List |
getAllChildNodes()
Returns a List containing all the children of this node. |
protected void |
getAllChildNodes(java.util.List children,
java.util.List collectedNodes)
Helper method for #getAllChildNodes(). |
java.lang.Object |
getAttribute(java.lang.Class type)
Returns the value of the specified attribute. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the specified attribute. |
java.util.Map |
getAttributes()
Returns the attributes of this node. |
java.util.List |
getChildNodes()
Returns a List containing all the children of this node. |
OsmNode |
getFirstChild()
The first child of this node. |
OsmNode |
getLastChild()
The last child of this node. |
OsmNode |
getNextSibling()
The node immediately following this node. |
java.lang.String |
getNodeName()
Returns the name of this node. |
java.lang.String |
getNodePath()
Returns a string representation of the node's position in the hierarchy. |
java.lang.Object |
getNodeValue()
Returns the value of this node. |
java.lang.Object |
getNodeValue(java.lang.Class type)
Returns the value of this node. |
Osm |
getOwnerOsm()
Returns the OSM to which this node belongs. |
OsmNode |
getParentNode()
The parent of this node. |
OsmNode |
getPreviousSibling()
The node immediately preceding this node. |
boolean |
hasAttributes()
Returns whether this node has any attributes. |
boolean |
hasChildNodes()
Returns whether this node has any children. |
OsmNode |
insertBefore(OsmNode newChild,
OsmNode refChild)
Inserts the node newChild before the existing child node refChild. |
OsmNode |
removeChild(OsmNode oldChild)
Removes the child node indicated by oldChild from the list of children,
and returns it. |
void |
removeChildNodes()
Removes all children of this node. |
OsmNode |
replaceChild(OsmNode newChild,
OsmNode oldChild)
Replaces the child node oldChild with newChild, and returns
the oldChild node. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the value of the specified attribute. |
void |
setNodeValue(java.lang.Object object)
Sets the value of this node. |
java.lang.String |
toString()
Returns a string representation of the node. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
name
protected java.lang.String name
- The node name.
value
protected java.lang.Object value
- The node value.
parent
protected OsmNode parent
- The parent node.
children
protected java.util.ArrayList children
- Children nodes.
position
protected int position
- The child position in the parent.
attributes
protected java.util.HashMap attributes
- The attributes of this node.
| Constructor Detail |
OsmNode
protected OsmNode()
- Constructs an
OsmNodeinstance.
OsmNode
protected OsmNode(OsmNode setNode)
- Constructs an
OsmNodeinstance as a copy of the supplied node. Only the value name, value, and attributes are copied.
OsmNode
protected OsmNode(java.lang.String setName, java.lang.Object setValue)
- Constructs an
OsmNodeinstance using the supplied value.
| Method Detail |
getNodeValue
public java.lang.Object getNodeValue()
- Returns the value of this node.
getNodeValue
public java.lang.Object getNodeValue(java.lang.Class type) throws OsmException
- Returns the value of this node. If an object is not already assigned, then
an instance of the specified class is created and stored.
setNodeValue
public void setNodeValue(java.lang.Object object)
- Sets the value of this node.
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Returns the value of the specified attribute.
getAttribute
public java.lang.Object getAttribute(java.lang.Class type) throws OsmException
- Returns the value of the specified attribute. If an object is not already set,
then an instance of the specified class is created and stored.
getAttributes
public java.util.Map getAttributes()
- Returns the attributes of this node. Modifications to this
Mapdo not affect the node's attributes.
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
- Sets the value of the specified attribute.
hasAttributes
public boolean hasAttributes()
- Returns whether this node has any attributes.
getNodeName
public java.lang.String getNodeName()
- Returns the name of this node.
getNodePath
public java.lang.String getNodePath()
- Returns a string representation of the node's position in the hierarchy.
getOwnerOsm
public Osm getOwnerOsm()
- Returns the OSM to which this node belongs. This is the OSM object used to
create new nodes.
cloneNode
public OsmNode cloneNode(boolean deep)
- Returns a duplicate of this node. The duplicate node has no parent.
If a shallow copy is performed, only the value name, value, and attributes are copied.
If a deep copy is performed, a shallow copy of the node is made, then deep copies of
each child of the node is made.
Any objects stored as values or attributes are not copied, even if a deep copy is
being performed.
getParentNode
public OsmNode getParentNode()
- The parent of this node. All nodes, exception the root (Osm)
node may have a parent. If a node has just been created and not yet added to the tree, or if
it has been removed from the tree, this is null.
hasChildNodes
public boolean hasChildNodes()
- Returns whether this node has any children.
getFirstChild
public OsmNode getFirstChild()
- The first child of this node. If there is no such node, this returns null.
getLastChild
public OsmNode getLastChild()
- The last child of this node. If there is no such node, this returns null.
getPreviousSibling
public OsmNode getPreviousSibling()
- The node immediately preceding this node. If there is no such node,
this returns null.
getNextSibling
public OsmNode getNextSibling()
- The node immediately following this node. If there is no such node,
this returns null.
getChildNodes
public java.util.List getChildNodes()
- Returns a
Listcontaining all the children of this node. Modifying this collection does not affect this node's children.
removeChildNodes
public void removeChildNodes()
- Removes all children of this node.
getAllChildNodes
public java.util.List getAllChildNodes()
- Returns a
Listcontaining all the children of this node. This recursively collects all the children of each child node.
getAllChildNodes
protected void getAllChildNodes(java.util.List children, java.util.List collectedNodes)
- Helper method for #getAllChildNodes().
This recursively collects all the children of each child node.
appendChild
public OsmNode appendChild(OsmNode newChild)
- Adds the node
newChildto the end of the list of children of this node. IfnewChildis already in the tree, it is first removed.
insertBefore
public OsmNode insertBefore(OsmNode newChild, OsmNode refChild)
- Inserts the node
newChildbefore the existing child noderefChild. IfrefChildis null,newChildis inserted at the end of the list of children. If thenewChildis already in the tree, it is first removed.
replaceChild
public OsmNode replaceChild(OsmNode newChild, OsmNode oldChild)
- Replaces the child node
oldChildwithnewChild, and returns theoldChildnode. If thenewChildis already in the tree, it is first removed.
removeChild
public OsmNode removeChild(OsmNode oldChild)
- Removes the child node indicated by
oldChildfrom the list of children, and returns it.
toString
public java.lang.String toString()
- Returns a string representation of the node.
|
|||||||||
| Home >> All >> com >> aendvari >> common >> [ osm overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.aendvari.common.osm.OsmNode