LBJ2.parse
Class LinkedVector

java.lang.Object
  extended by LBJ2.parse.LinkedChild
      extended by LBJ2.parse.LinkedVector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
NLDocument

public class LinkedVector
extends LinkedChild

A LinkedVector is used to store a vector of LinkedChildren which all maintain links between each other and the parent LinkedVector.

See Also:
LinkedChild, Serialized Form

Field Summary
protected  java.util.Vector children
          The linked vector is simply represented as a vector of children.
 
Fields inherited from class LBJ2.parse.LinkedChild
end, next, parent, previous, start
 
Constructor Summary
LinkedVector()
          Initializes the vector.
LinkedVector(int s, int e)
          Constructor that sets the character offsets of this vector.
LinkedVector(LinkedChild c)
          Constructor for when only a single child from anywhere in this vector is available.
LinkedVector(LinkedChild c, int s, int e)
          Constructor for when only a single child from anywhere in this vector is available.
LinkedVector(LinkedVector p)
          Useful when the information that this child represents is parsed forwards.
LinkedVector(LinkedVector p, int s, int e)
          Useful when the information that this child represents is parsed forwards.
 
Method Summary
 boolean add(LinkedChild c)
          Adds the specified child to the end of the vector, informing the child of its parent and index and linking the child to its only neighbor (which was previously the last child in the vector).
 java.lang.Object clone()
          Returns a clone of this object that is deep in the sense that all of the children objects are cloned.
 LinkedChild get(int i)
          Retrieves the child at the specified index in the vector.
 boolean insert(LinkedChild c, int i)
          Inserts the specified child into the specified index.
 LinkedChild remove(int i)
          Removes the child at the specified index.
 int size()
          Returns the size of the vector.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children

protected java.util.Vector children
The linked vector is simply represented as a vector of children.

Constructor Detail

LinkedVector

public LinkedVector()
Initializes the vector.


LinkedVector

public LinkedVector(LinkedChild c)
Constructor for when only a single child from anywhere in this vector is available. It is assumed that the previous and next links are filled in by every child.

Parameters:
c - Any child in this vector.

LinkedVector

public LinkedVector(LinkedVector p)
Useful when the information that this child represents is parsed forwards.

Parameters:
p - The previous child in the parent vector.

LinkedVector

public LinkedVector(int s,
                    int e)
Constructor that sets the character offsets of this vector.

Parameters:
s - The offset at which this sentence starts.
e - The offset at which this sentence ends.

LinkedVector

public LinkedVector(LinkedChild c,
                    int s,
                    int e)
Constructor for when only a single child from anywhere in this vector is available. It is assumed that the previous and next links are filled in by every child.

Parameters:
c - Any child in this vector.
s - The offset at which this sentence starts.
e - The offset at which this sentence ends.

LinkedVector

public LinkedVector(LinkedVector p,
                    int s,
                    int e)
Useful when the information that this child represents is parsed forwards.

Parameters:
p - The previous child in the parent vector.
s - The offset at which this sentence starts.
e - The offset at which this sentence ends.
Method Detail

add

public boolean add(LinkedChild c)
Adds the specified child to the end of the vector, informing the child of its parent and index and linking the child to its only neighbor (which was previously the last child in the vector).

Parameters:
c - The child to add.

remove

public LinkedChild remove(int i)
Removes the child at the specified index.

Parameters:
i - The index of the child to remove.
Returns:
The child removed, or null if there was no child at that index.

insert

public boolean insert(LinkedChild c,
                      int i)
Inserts the specified child into the specified index. All children that previously had index greater than or equal to the specified index are shifted up one.

Parameters:
c - The child to insert.
i - The index at which to insert the child.
Returns:
true if and only if the insert was successful.

get

public LinkedChild get(int i)
Retrieves the child at the specified index in the vector.

Parameters:
i - The index from which to retrieve a child.
Returns:
The child at the specified index, or null if there was no child at that index.

size

public int size()
Returns the size of the vector.

Returns:
The size of the vector.

clone

public java.lang.Object clone()
Returns a clone of this object that is deep in the sense that all of the children objects are cloned.

Overrides:
clone in class LinkedChild
Returns:
A deep clone of this object.