com.ds.fw.types.collections
Class FwListIterator

java.lang.Object
  |
  +--com.ds.fw.types.collections.FwListIterator
All Implemented Interfaces:
FwListIteratorIF, java.util.Iterator, java.util.ListIterator
Direct Known Subclasses:
FwListCursorIterator

public class FwListIterator
extends java.lang.Object
implements FwListIteratorIF

This class implements the FwListIteratorIF, which wraps the ListIterator interface. The list for the iterator to use could be set explicitly (in the Java API usually the ListInterator is an interface that is get from the existing list).


Field Summary
 int _index
          Current list index
 int _lastReturned
          Index of the last returned list element
 java.util.List _list
          Handle of the list to be iterated
 
Constructor Summary
FwListIterator()
          Constructor.
 
Method Summary
 void add(java.lang.Object o)
          Adds an object to the list.
 java.util.List getList()
          Gets the current list this iterator works with.
 void gotoEnd()
          Positions the list cursor at the last element of the list.
 void gotoStart()
          Positions the list cursor at the first element of the list.
 boolean hasNext()
          Checks if there is next element in the list (if the array boundary is reached)
 boolean hasPrevious()
          Checks if there is previous element in the list (if the array boundary is reached)
 java.lang.Object next()
          Returns the the next element of the list.
 com.ds.fw.types.collections.FwListIF next(int n)
          Returns a sublist with next n elements of the list.
 int nextIndex()
          Returns the index of the next element.
 java.lang.Object previous()
          Returns the the previous element of the list.
 com.ds.fw.types.collections.FwListIF previous(int n)
          Returns a sublist with previous n elements of the list.
 int previousIndex()
          Returns the index of the previuos element.
 void remove()
          Removes the current element of the list.
 void set(java.lang.Object o)
          Sets current element of the list to the given object.
 void setList(java.util.List o)
          Sets the current list this iterator works with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_list

public java.util.List _list
Handle of the list to be iterated


_index

public int _index
Current list index


_lastReturned

public int _lastReturned
Index of the last returned list element

Constructor Detail

FwListIterator

public FwListIterator()
Constructor. Initiaizes the class members.

Method Detail

getList

public java.util.List getList()
Gets the current list this iterator works with.

Specified by:
getList in interface FwListIteratorIF

setList

public void setList(java.util.List o)
Sets the current list this iterator works with.

Specified by:
setList in interface FwListIteratorIF
Parameters:
o - the list

hasNext

public boolean hasNext()
Checks if there is next element in the list (if the array boundary is reached)

Specified by:
hasNext in interface java.util.ListIterator
Returns:
true if has one otherwise false

hasPrevious

public boolean hasPrevious()
Checks if there is previous element in the list (if the array boundary is reached)

Specified by:
hasPrevious in interface java.util.ListIterator
Returns:
true if has one otherwise false

nextIndex

public int nextIndex()
Returns the index of the next element.

Specified by:
nextIndex in interface java.util.ListIterator
Returns:
the index

previousIndex

public int previousIndex()
Returns the index of the previuos element.

Specified by:
previousIndex in interface java.util.ListIterator
Returns:
the index

next

public java.lang.Object next()
Returns the the next element of the list. If there is not such an element a NoSuchElementException is thrown.

Specified by:
next in interface java.util.ListIterator
Returns:
the element

previous

public java.lang.Object previous()
Returns the the previous element of the list. If there is not such an element a NoSuchElementException is thrown.

Specified by:
previous in interface java.util.ListIterator
Returns:
the element

next

public com.ds.fw.types.collections.FwListIF next(int n)
Returns a sublist with next n elements of the list. If n exceeds the array boundary the sublist will be ternminated at the boundary.


previous

public com.ds.fw.types.collections.FwListIF previous(int n)
Returns a sublist with previous n elements of the list. If n exceeds the array boundary the sublist will be ternminated at the boundary.


set

public void set(java.lang.Object o)
Sets current element of the list to the given object. If the list cursor does not point to a valid element an IllegalStateException is thrown.

Specified by:
set in interface java.util.ListIterator
Parameters:
o - the object to be set to the list

remove

public void remove()
Removes the current element of the list. If the list cursor does not point to a valid element an IllegalStateException is thrown.

Specified by:
remove in interface java.util.ListIterator

add

public void add(java.lang.Object o)
Adds an object to the list.

Specified by:
add in interface java.util.ListIterator
Parameters:
o - the object to be added

gotoStart

public void gotoStart()
Positions the list cursor at the first element of the list.


gotoEnd

public void gotoEnd()
Positions the list cursor at the last element of the list.