|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drools.core.util.ArrayIterator
public class ArrayIterator
Implements an Iterator
over any array.
The array can be either an array of object or of primitives. If you know
that you have an object array, the
ObjectArrayIterator
class is a better choice, as it will perform better.
The iterator implements a #reset
method, allowing the reset of
the iterator back to the start if required.
Field Summary | |
---|---|
protected Object |
array
The array to iterate over |
protected int |
endIndex
The end index to loop to |
protected int |
index
The current iterator index |
Constructor Summary | |
---|---|
ArrayIterator(Object array)
Constructs an ArrayIterator that will iterate over the values in the specified array. |
Method Summary | |
---|---|
protected void |
checkBound(int bound,
String type)
Checks whether the index is valid or not. |
Object |
getArray()
Gets the array that this iterator is iterating over. |
boolean |
hasNext()
Returns true if there are more elements to return from the array. |
Object |
next()
Returns the next element in the array. |
void |
remove()
Throws UnsupportedOperationException . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Object array
protected int endIndex
protected int index
Constructor Detail |
---|
public ArrayIterator(Object array)
array
- the array to iterate over.
IllegalArgumentException
- if array
is not an array.
NullPointerException
- if array
is null
Method Detail |
---|
protected void checkBound(int bound, String type)
bound
- the index to checktype
- the index type (for error messages)
IndexOutOfBoundsException
- if the index is invalidpublic boolean hasNext()
hasNext
in interface Iterator
public Object next()
next
in interface Iterator
NoSuchElementException
- if all the elements in the array
have already been returnedpublic void remove()
UnsupportedOperationException
.
remove
in interface Iterator
UnsupportedOperationException
- alwayspublic Object getArray()
null
if
the no-arg constructor was used and setArray(Object)
has never
been called with a valid array.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |