com.sdm.quasar.client.core.common.util
Class ArrayIterator

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.util.ArrayIterator
All Implemented Interfaces:
java.util.Iterator, java.util.ListIterator

public class ArrayIterator
extends java.lang.Object
implements java.util.ListIterator

The ArrayIterator is a simple implementation of the ListIterator interface (and so of the Iterator interface), iterating over arrays (of Objects). Additionally this class provides a lot of toString()- methods converting arrays - also of basic types - to Strings.

Author:
Thomas Wolf

Field Summary
static ArrayIterator EMPTY_ITERATOR
          An empty iterator, which iterates nothing.
static java.lang.Object[] EMPTY_OBJECT_ARRAY
          An empty object array.
 
Constructor Summary
ArrayIterator(java.lang.Object[] array)
          Creates an ArrayIterator, that iterates the given array.
ArrayIterator(java.lang.Object[] array, int start, int length)
          Creates an ArrayIterator, that iterates the given sub-array.
 
Method Summary
 void add(java.lang.Object o)
           
 boolean hasNext()
           
 boolean hasPrevious()
           
 java.lang.Object next()
           
 int nextIndex()
           
 java.lang.Object previous()
           
 int previousIndex()
           
 void remove()
           
 void set(java.lang.Object o)
           
 java.lang.String toString()
          Overrides java.lang.Object.toString().
static java.lang.String toString(byte[] a)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(byte[] a, int start, int len)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(byte[] a, int start, int len, java.lang.String separator)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(byte[] a, int start, int len, java.lang.String separator, boolean hex)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(double[] a)
          Converts an array a to a string using commas "," to separate array elements.
static java.lang.String toString(double[] a, int start, int len)
          Converts a subarray starting at start with length len to a string using commas "," to separate array elements.
static java.lang.String toString(double[] a, int start, int len, java.lang.String separator)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(float[] a)
          Converts an array a to a string using commas "," to separate array elements.
static java.lang.String toString(float[] a, int start, int len)
          Converts a subarray starting at start with length len to a string using commas "," to separate array elements.
static java.lang.String toString(float[] a, int start, int len, java.lang.String separator)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(int[] a)
          Converts an array a to a string using commas "," to separate array elements.
static java.lang.String toString(int[] a, int start, int len)
          Converts a subarray starting at start with length len to a string using commas "," to separate array elements.
static java.lang.String toString(int[] a, int start, int len, java.lang.String separator)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(int[] a, int start, int len, java.lang.String separator, boolean hex)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(java.util.Iterator i)
          Converts the elements iterated by the given Iterator to a string using the separation string separator.
static java.lang.String toString(java.util.Iterator i, java.lang.String separator)
          Converts the elements iterated by the given Iteratorto a string using the separation string separator.
static java.lang.String toString(long[] a)
          Converts an array a to a string using commas "," to separate array elements.
static java.lang.String toString(long[] a, int start, int len)
          Converts a subarray starting at start with length len to a string using commas "," to separate array elements.
static java.lang.String toString(long[] a, int start, int len, java.lang.String separator)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(long[] a, int start, int len, java.lang.String separator, boolean hex)
          Converts a subarray starting at start with length len to a string using the separation string separator.
static java.lang.String toString(java.lang.Object[] a)
          Converts an array a to a string using commas "," to separate array elements.
static java.lang.String toString(java.lang.Object[] a, int start, int len)
          Converts a subarray starting at start with length len to a string using commas "," to separate array elements.
static java.lang.String toString(java.lang.Object[] a, int start, int len, java.lang.String separator)
          Converts a subarray starting at start with length len to a string using the separation string separator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_OBJECT_ARRAY

public static final java.lang.Object[] EMPTY_OBJECT_ARRAY
An empty object array.


EMPTY_ITERATOR

public static final ArrayIterator EMPTY_ITERATOR
An empty iterator, which iterates nothing.

Constructor Detail

ArrayIterator

public ArrayIterator(java.lang.Object[] array)
Creates an ArrayIterator, that iterates the given array.

Parameters:
array - the array to iterate
Throws:
java.lang.NullPointerException - if the array is null.

ArrayIterator

public ArrayIterator(java.lang.Object[] array,
                     int start,
                     int length)
Creates an ArrayIterator, that iterates the given sub-array. If the given length is less than 0, the sub-array will be extended to the end of the array.

Parameters:
array - the array to iterate
start - the start index
length - the subarray length (if <=0, then to the end of the array)
Throws:
java.lang.NullPointerException - if the array is null.
Method Detail

add

public void add(java.lang.Object o)
Specified by:
add in interface java.util.ListIterator
See Also:
ListIterator.add(java.lang.Object)

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.ListIterator
See Also:
Iterator.hasNext()

hasPrevious

public boolean hasPrevious()
Specified by:
hasPrevious in interface java.util.ListIterator
See Also:
ListIterator.hasPrevious()

next

public java.lang.Object next()
Specified by:
next in interface java.util.ListIterator
See Also:
Iterator.next()

nextIndex

public int nextIndex()
Specified by:
nextIndex in interface java.util.ListIterator
See Also:
ListIterator.nextIndex()

previous

public java.lang.Object previous()
Specified by:
previous in interface java.util.ListIterator
See Also:
ListIterator.previous()

previousIndex

public int previousIndex()
Specified by:
previousIndex in interface java.util.ListIterator
See Also:
ListIterator.previousIndex()

remove

public void remove()
Specified by:
remove in interface java.util.ListIterator
See Also:
Iterator.remove()

set

public void set(java.lang.Object o)
Specified by:
set in interface java.util.ListIterator
See Also:
ListIterator.set(java.lang.Object)

toString

public java.lang.String toString()
Overrides java.lang.Object.toString().

See Also:
Object.toString()

toString

public static java.lang.String toString(byte[] a)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - byte array
Returns:
string representation of the subarray

toString

public static java.lang.String toString(byte[] a,
                                        int start,
                                        int len)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - byte array
start - start index
len - length of subarray
Returns:
string representation of the subarray

toString

public static java.lang.String toString(byte[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - byte array
start - start index
len - length of subarray
separator - separation string between elements
Returns:
string representation of the subarray

toString

public static java.lang.String toString(byte[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator,
                                        boolean hex)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - byte array
start - start index
len - length of subarray
separator - separation string between elements
hex - if true the numbers are represented in hexadecimal notation
Returns:
string representation of the subarray

toString

public static java.lang.String toString(double[] a)
Converts an array a to a string using commas "," to separate array elements.

Parameters:
a - double array
Returns:
string representation of the array a

toString

public static java.lang.String toString(double[] a,
                                        int start,
                                        int len)
Converts a subarray starting at start with length len to a string using commas "," to separate array elements.

Parameters:
a - double array
Returns:
string representation of the array a

toString

public static java.lang.String toString(double[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - double array
start - start index
len - length of subarray
separator - separation string between elements
Returns:
string representation of the subarray

toString

public static java.lang.String toString(float[] a)
Converts an array a to a string using commas "," to separate array elements.

Parameters:
a - float array
Returns:
string representation of the array a

toString

public static java.lang.String toString(float[] a,
                                        int start,
                                        int len)
Converts a subarray starting at start with length len to a string using commas "," to separate array elements.

Parameters:
a - float array
Returns:
string representation of the array a

toString

public static java.lang.String toString(float[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - float array
start - start index
len - length of subarray
separator - separation string between elements
Returns:
string representation of the subarray

toString

public static java.lang.String toString(int[] a)
Converts an array a to a string using commas "," to separate array elements.

Parameters:
a - int array
Returns:
string representation of the array a

toString

public static java.lang.String toString(int[] a,
                                        int start,
                                        int len)
Converts a subarray starting at start with length len to a string using commas "," to separate array elements.

Parameters:
a - int array
Returns:
string representation of the array a

toString

public static java.lang.String toString(int[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - int array
start - start index
len - length of subarray
separator - separation string between elements
Returns:
string representation of the subarray

toString

public static java.lang.String toString(int[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator,
                                        boolean hex)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - int array
start - start index
len - length of subarray
separator - separation string between elements
hex - if true the numbers are represented in hexadecimal notation
Returns:
string representation of the subarray

toString

public static java.lang.String toString(long[] a)
Converts an array a to a string using commas "," to separate array elements.

Parameters:
a - long array
Returns:
string representation of the array a

toString

public static java.lang.String toString(long[] a,
                                        int start,
                                        int len)
Converts a subarray starting at start with length len to a string using commas "," to separate array elements.

Parameters:
a - long array
Returns:
string representation of the array a

toString

public static java.lang.String toString(long[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - long array
start - start index
len - length of subarray
separator - separation string between elements
Returns:
string representation of the subarray

toString

public static java.lang.String toString(long[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator,
                                        boolean hex)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - long array
start - start index
len - length of subarray
separator - separation string between elements
hex - if true the numbers are represented in hexadecimal notation
Returns:
string representation of the subarray

toString

public static java.lang.String toString(java.lang.Object[] a)
Converts an array a to a string using commas "," to separate array elements.

Parameters:
a - object array
Returns:
string representation of the array a

toString

public static java.lang.String toString(java.lang.Object[] a,
                                        int start,
                                        int len)
Converts a subarray starting at start with length len to a string using commas "," to separate array elements.

Parameters:
a - object array
Returns:
string representation of the array a

toString

public static java.lang.String toString(java.lang.Object[] a,
                                        int start,
                                        int len,
                                        java.lang.String separator)
Converts a subarray starting at start with length len to a string using the separation string separator.

Parameters:
a - object array
start - start index
len - length of subarray
separator - separation string between elements
Returns:
string representation of the subarray

toString

public static java.lang.String toString(java.util.Iterator i)
Converts the elements iterated by the given Iterator to a string using the separation string separator.

Parameters:
i - the Iterator to get string representation of
Returns:
string representation of the subarray

toString

public static java.lang.String toString(java.util.Iterator i,
                                        java.lang.String separator)
Converts the elements iterated by the given Iteratorto a string using the separation string separator.

Parameters:
i - the Iteratorto get string representation of
separator - separation string between elements
Returns:
string representation of the subarray