edu.rice.cs.drjava.model.definitions.reducedmodel
Class TokenList.Iterator

java.lang.Object
  extended by edu.rice.cs.drjava.model.definitions.reducedmodel.TokenList.Iterator
Enclosing class:
TokenList

public class TokenList.Iterator
extends Object


Constructor Summary
TokenList.Iterator()
           
 
Method Summary
 boolean atEnd()
          Return true if we're pointing at the tail.
 boolean atFirstItem()
          Return true if we're pointing at the node after the head.
 boolean atLastItem()
          Return true if we're pointing at the node before the tail.
 boolean atStart()
          Return true if we're pointing at the head.
 void collapse(edu.rice.cs.drjava.model.definitions.reducedmodel.ModelList.ModelIterator iter)
          Delete all nodes between the current position of this and the current position of the given iterator.
 TokenList.Iterator copy()
          Makes a fresh copy of this TokenList.Iterator.
 T current()
          Return the item associated with the current node.
 void delete(int count)
          Update the BraceReduction to reflect text deletion.
 void dispose()
          Disposes of an iterator by removing it from the listeners.
 boolean eq(edu.rice.cs.drjava.model.definitions.reducedmodel.ModelList.ModelIterator that)
          Tests "that" for equality with "this".
 int getBlockOffset()
           
 ReducedModelState getStateAtCurrent()
          Returns the current commented/quoted state at the cursor.
 void insert(T item)
          Inserts an item before the current item.
 void move(int count)
          Updates the BraceReduction to reflect cursor movement.
 void next()
          Moves to the next node.
 T nextItem()
          Returns the item associated with the node after the current node.
 int pos()
           
 void prev()
          Moves to the previous node.
 T prevItem()
          Returns the item associated with the node before the current node.
 void remove()
          Removes the current item from the list.
 void setBlockOffset(int offset)
           
 void setTo(edu.rice.cs.drjava.model.definitions.reducedmodel.ModelList.ModelIterator that)
          Force "this" iterator to take the values of "that".
 void setTo(TokenList.Iterator that)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TokenList.Iterator

public TokenList.Iterator()
Method Detail

copy

public TokenList.Iterator copy()
Makes a fresh copy of this TokenList.Iterator. copy() returns a ModelList.Iterator copy which is more restrictive than TokenList.Iterator. An underscore differentiates the two methods. This differentiation was easiest since it allowed us to keep TokenList.Iterator extending ModelList.Iterator.


setTo

public void setTo(TokenList.Iterator that)

getBlockOffset

public int getBlockOffset()

setBlockOffset

public void setBlockOffset(int offset)

getStateAtCurrent

public ReducedModelState getStateAtCurrent()
Returns the current commented/quoted state at the cursor.

Returns:
FREE | INSIDE_BLOCK_COMMENT | INSIDE_LINE_COMMENT | INSIDE_SINGLE_QUOTE | INSIDE_DOUBLE_QUOTE

move

public void move(int count)
Updates the BraceReduction to reflect cursor movement. Negative values move left from the cursor, positive values move right. ASSUMES that count is within range, i.e. that the move will not push cursor past start or end.

Parameters:
count - indicates the direction and magnitude of cursor movement

delete

public void delete(int count)

Update the BraceReduction to reflect text deletion.

Parameters:
count - A number specifying the size and direction of text deletion. Negative values delete text to the left of the cursor; positive values delete text to the right. Assumes deletion is within range!

toString

public String toString()
Overrides:
toString in class Object

eq

public boolean eq(edu.rice.cs.drjava.model.definitions.reducedmodel.ModelList.ModelIterator that)
Tests "that" for equality with "this".


setTo

public void setTo(edu.rice.cs.drjava.model.definitions.reducedmodel.ModelList.ModelIterator that)
Force "this" iterator to take the values of "that".


dispose

public void dispose()
Disposes of an iterator by removing it from the listeners. If an iterator becomes unreachable, it is automatically reclaimed as part of system garbage collection. The manual use of dispose() reduces the cost of notifying the listeners because it reduces the size of the listener set.


atStart

public boolean atStart()
Return true if we're pointing at the head.


atEnd

public boolean atEnd()
Return true if we're pointing at the tail.


atFirstItem

public boolean atFirstItem()
Return true if we're pointing at the node after the head.


atLastItem

public boolean atLastItem()
Return true if we're pointing at the node before the tail.


current

public T current()
Return the item associated with the current node.


prevItem

public T prevItem()
Returns the item associated with the node before the current node.


nextItem

public T nextItem()
Returns the item associated with the node after the current node.


pos

public int pos()

insert

public void insert(T item)
Inserts an item before the current item. If current is head, we need to move to the next node to perform the insert properly. Otherwise, we'll get a null pointer exception because the function will try to insert the new item before the head. Ends pointing to inserted item.


remove

public void remove()
Removes the current item from the list. Ends pointing to the node following the removed node. Throws exception if performed atStart() or atEnd().


prev

public void prev()
Moves to the previous node. Throws exception atStart().


next

public void next()
Moves to the next node. Throws exception atEnd().


collapse

public void collapse(edu.rice.cs.drjava.model.definitions.reducedmodel.ModelList.ModelIterator iter)
Delete all nodes between the current position of this and the current position of the given iterator. 1) Two iterators pointing to same node: do nothing 2) Iterator 2 is before iterator 1: remove between iterator 2 and iterator 1 3) Iterator 1 is before iterator 2: remove between iterator 1 and iterator 2 Does not remove points iterators point to.