org.jibx.util
Class SparseArrayIterator

java.lang.Object
  extended by org.jibx.util.SparseArrayIterator
All Implemented Interfaces:
Iterator

public class SparseArrayIterator
extends Object
implements Iterator

Iterator class for sparse values in an array. This type of iterator can be used for an object array which has references interspersed with nulls.

Author:
Dennis M. Sosnoski

Field Summary
static SparseArrayIterator EMPTY_ITERATOR
          Empty iterator.
 
Method Summary
protected  boolean advance()
          Advance to next iteration value.
static Iterator buildIterator(Object[] array)
          Build iterator.
 boolean hasNext()
          Check for iteration element available.
 Object next()
          Get next iteration element.
 void remove()
          Remove element from iteration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ITERATOR

public static final SparseArrayIterator EMPTY_ITERATOR
Empty iterator.

Method Detail

advance

protected boolean advance()
Advance to next iteration value. This advances the current position in the array to the next non-null value.

Returns:
true if element available, false if not

hasNext

public boolean hasNext()
Check for iteration element available.

Specified by:
hasNext in interface Iterator
Returns:
true if element available, false if not

next

public Object next()
Get next iteration element.

Specified by:
next in interface Iterator
Returns:
next iteration element
Throws:
NoSuchElementException - if past end of iteration

remove

public void remove()
Remove element from iteration. This optional operation is not supported and always throws an exception.

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - for unsupported operation

buildIterator

public static Iterator buildIterator(Object[] array)
Build iterator.

Parameters:
array - array containing values to be iterated (may be null)
Returns:
constructed iterator


Copyright © 2005-2011 jibx.org. All Rights Reserved.