step
Class StepArray

java.lang.Object
  |
  +--step.StepArray
All Implemented Interfaces:
Serializable, StepObject

public class StepArray
extends Object
implements StepObject

Implementation for arrays of STEP objects.

See Also:
Serialized Form

Field Summary
static FieldDef ELEMENT_FIELD
          The prototype definition for the element fields of array objects.
static FieldDef LENGTH_FIELD
          The prototype definition for the length field of array objects.
 
Fields inherited from interface step.StepObject
TYPE
 
Constructor Summary
StepArray(Collection elements)
          Create a new STEP array from a collection of objects.
StepArray(StepObject[] elements)
          Create a new STEP array.
 
Method Summary
 boolean equals(Object o)
          Compare two array objects for equality.
 StepObject[] getElements()
          Get the underlying array of elements.
 int hashCode()
          Get the hash-code for this object.
 Iterator iterator()
          Get an iterator over the elements of this array.
 int length()
          Get the length of this array.
 String toString()
          Get a string representation of this array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LENGTH_FIELD

public static final FieldDef LENGTH_FIELD
The prototype definition for the length field of array objects.


ELEMENT_FIELD

public static final FieldDef ELEMENT_FIELD
The prototype definition for the element fields of array objects.

Constructor Detail

StepArray

public StepArray(StepObject[] elements)
Create a new STEP array.

NOTE: The element values are assumed to be non-null.


StepArray

public StepArray(Collection elements)
Create a new STEP array from a collection of objects.

NOTE: The given collection is assumed to contain objects of the same type.

Throws:
ClassCastException - if an element is not a StepObject.
Method Detail

getElements

public StepObject[] getElements()
Get the underlying array of elements.


length

public int length()
Get the length of this array.


iterator

public Iterator iterator()
Get an iterator over the elements of this array.


equals

public boolean equals(Object o)
Compare two array objects for equality.

The objects are equivalent if they are the same size and contain the same data values.

The algorithm is fail-fast.

Specified by:
equals in interface StepObject
Overrides:
equals in class Object

hashCode

public int hashCode()
Get the hash-code for this object.

Algorithm:

 for (i=0; i<value.length; i++)
   code = (code << 1) ^ (hashCode[i]);
 

Specified by:
hashCode in interface StepObject
Overrides:
hashCode in class Object

toString

public String toString()
Get a string representation of this array. The elements are assumed to implement a valid version of toString().

Overrides:
toString in class Object