antsnest.datastructure
Interface AntNode

All Superinterfaces:
Serializable
All Known Subinterfaces:
AntCData, AntComment, AntElement, AntNodeText, AntProject, AntTarget
All Known Implementing Classes:
DefaultAntCData, DefaultAntComment, DefaultAntElement, DefaultAntNode, DefaultAntProject, DefaultAntTarget, DefaultAntTextNode

public interface AntNode
extends Serializable

Represents a generic node encapsulating common behaviour

Author:
Chris Clohosy
See Also:
AntAttribute

Method Summary
 void addAttribute(AntAttribute attribute)
          Adds an attribute to the end of this node
 void addAttribute(AntAttribute attribute, int position)
          Adds an attribute to this node
 void addNode(AntNode node)
          Adds a node to this node
 void addNode(AntNode node, int position)
          Adds a node to this node
 void changeAttribute(AntAttribute attribute)
          Changes an attribute in the list
 AntNode cloneNode(IDPool idPool)
          Gets a clone of this node
 AntAttribute getAttribute(int position)
          Gets an attribute from this node
 AntAttribute getAttribute(String name)
          Gets the attribute with the required name
 int getAttributeSize()
          Gets the number of attributes held by this node
 String getData()
          Gets any character data stored in this node
 String getDescription()
          Gets the description of this node
 IDPool getIDPool()
          Gets the ID pool used by this node
 String getName()
          Gets the name of this node
 AntNode getNode(int position)
          Gets a node from this node
 long getNodeID()
          Gets the ID of this node
 int getNodeSize()
          Gets tthe number of nested elements held by thsi node
 AntNodeText getNodeText()
          Gets the text node in this one, if any
 AntNode getParent()
          Gets the parent of this node
 int getType()
          Gets the type of this node
 int getTypeAt(int position)
          Gets the type of the node at the specified position
 int indexOfAttribute(AntAttribute attribute)
          Gets the index of an attribute in this node
 int indexOfNode(AntNode node)
          Gets the index of a node nested in this node
 void moveAttribute(int fromPosition, int toPosition)
          Moves an attribute in this node
 void moveNode(int fromPosition, int toPosition)
          Moves a node to a new position
 void removeAttribute(AntAttribute attribute)
          Removes an attribute from this node
 void removeAttribute(int position)
          Removes an attribute from this node
 void removeNode(AntNode node)
          Removes a node from this node
 void removeNode(int position)
          Removes a node from this node
 void setData(String data)
          Sets the character data stored in this node
 void setDescription(String description)
          Sets the description of this node
 void setIDPool(IDPool idPool)
          Sets the ID pool used by this node
 void setName(String name)
          Sets the name of this node
 void setNodeID(long id)
          Sets the ID of this node
 void setParent(AntNode parent)
          Sets the parent of this node
 

Method Detail

getName

String getName()
Gets the name of this node

Returns:
a String, the name

setName

void setName(String name)
Sets the name of this node

Parameters:
name - the new name

getParent

AntNode getParent()
Gets the parent of this node

Returns:
an AntNode, the parent

setParent

void setParent(AntNode parent)
Sets the parent of this node

Parameters:
parent - the new parent

getDescription

String getDescription()
Gets the description of this node

Returns:
a String, the description

setDescription

void setDescription(String description)
Sets the description of this node

Parameters:
description - the new description

getType

int getType()
Gets the type of this node

Returns:
an int, the type

getAttribute

AntAttribute getAttribute(int position)
Gets an attribute from this node

Parameters:
position - the index of the attribute required
Returns:
an AntAttribute, the required attribute

getAttribute

AntAttribute getAttribute(String name)
Gets the attribute with the required name

Parameters:
name - the required attribute's name
Returns:
an AntAttribute, the required attribute

addAttribute

void addAttribute(AntAttribute attribute,
                  int position)
Adds an attribute to this node

Parameters:
attribute - the attribute to add
position - the index to place the attribute

addAttribute

void addAttribute(AntAttribute attribute)
Adds an attribute to the end of this node

Parameters:
attribute - the attribute to add

changeAttribute

void changeAttribute(AntAttribute attribute)
Changes an attribute in the list

Parameters:
attribute - the new version of an attribute

removeAttribute

void removeAttribute(AntAttribute attribute)
Removes an attribute from this node

Parameters:
attribute - the attribute to remove

removeAttribute

void removeAttribute(int position)
Removes an attribute from this node

Parameters:
position - the position of the attribute to remove

moveAttribute

void moveAttribute(int fromPosition,
                   int toPosition)
Moves an attribute in this node

Parameters:
fromPosition - the index of the attribute to move
toPosition - the index to move the attribute to

indexOfAttribute

int indexOfAttribute(AntAttribute attribute)
Gets the index of an attribute in this node

Parameters:
attribute - the specified attribute
Returns:
an int, the index

getNode

AntNode getNode(int position)
Gets a node from this node

Parameters:
position - the position of the required node
Returns:
an AntNode, the required node

addNode

void addNode(AntNode node,
             int position)
             throws CannotAddNodeException
Adds a node to this node

Parameters:
node - the node to add
position - the the index where to place the node
Throws:
CannotAddNodeException - if the node is not allowed to be added

addNode

void addNode(AntNode node)
             throws CannotAddNodeException
Adds a node to this node

Parameters:
node - the node to add
Throws:
CannotAddNodeException - if the node is not allowed to be added

removeNode

void removeNode(AntNode node)
Removes a node from this node

Parameters:
node - the node to remove

removeNode

void removeNode(int position)
Removes a node from this node

Parameters:
position - the index of the node to remove

indexOfNode

int indexOfNode(AntNode node)
Gets the index of a node nested in this node

Parameters:
node - the specified node
Returns:
an int, the index

getTypeAt

int getTypeAt(int position)
Gets the type of the node at the specified position

Parameters:
position - the index of the required node type
Returns:
an int, the type

getAttributeSize

int getAttributeSize()
Gets the number of attributes held by this node

Returns:
an int, the number of attributes

getNodeSize

int getNodeSize()
Gets tthe number of nested elements held by thsi node

Returns:
an int, the number of elements

getData

String getData()
Gets any character data stored in this node

Returns:
a String, the character data, or null if empty

setData

void setData(String data)
Sets the character data stored in this node

Parameters:
data - the new character data

setIDPool

void setIDPool(IDPool idPool)
Sets the ID pool used by this node

Parameters:
idPool - the ID pool to use

getIDPool

IDPool getIDPool()
Gets the ID pool used by this node

Returns:
an IDPool, the ID pool being used

setNodeID

void setNodeID(long id)
Sets the ID of this node

Parameters:
id - the ID of this node

getNodeID

long getNodeID()
Gets the ID of this node

Returns:
a long, the ID of this node

moveNode

void moveNode(int fromPosition,
              int toPosition)
              throws CannotAddNodeException
Moves a node to a new position

Parameters:
fromPosition - the position the node is moving from
toPosition - the position the node is moving to
Throws:
CannotAddNodeException - if the node is not allowed to be added

getNodeText

AntNodeText getNodeText()
Gets the text node in this one, if any

Returns:
an AntNodeText, the text nose inside this one

cloneNode

AntNode cloneNode(IDPool idPool)
Gets a clone of this node

Parameters:
idPool - an ID pool to use
Returns:
an AntNode, the cloned node