jfun.yan.element
Class AnyArrayStore<T>

java.lang.Object
  extended by jfun.yan.element.AnyArrayStore<T>
All Implemented Interfaces:
ElementStore<T>
Direct Known Subclasses:
ArrayStore

public class AnyArrayStore<T>
extends java.lang.Object
implements ElementStore<T>

This class stores component instances into any array. For a primitive array such as int[], wrapper objects are automatically unboxed.

Author:
Ben Yu Nov 12, 2005 2:19:48 PM

Constructor Summary
AnyArrayStore(java.lang.Object arr)
          To create an AnyArrayStore object.
AnyArrayStore(java.lang.Object arr, int begin)
          To create an AnyArrayStore object.
AnyArrayStore(java.lang.Object arr, int begin, int end)
          To create an AnyArrayStore object.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.Object getArrayObject()
          Get the array object that stores the elements.
 int getBegin()
          Get the begin index.
 int getEnd()
          Get the non-inclusive end index.
protected  int getIndex(int ind)
          Map an element to the real index on the array.
 int hashCode()
           
 void storeElement(int ind, T obj)
          Store an element.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AnyArrayStore

public AnyArrayStore(java.lang.Object arr,
                     int begin,
                     int end)
To create an AnyArrayStore object.

Parameters:
arr - the array object
begin - the begin index of the array. Elements are stored from this index.
end - the non-inclusive end index. Elements cannot be stored at or after this index.

AnyArrayStore

public AnyArrayStore(java.lang.Object arr,
                     int begin)
To create an AnyArrayStore object.

Parameters:
arr - the array object
begin - the begin index of the array. Elements are stored from this index.

AnyArrayStore

public AnyArrayStore(java.lang.Object arr)
To create an AnyArrayStore object.

Parameters:
arr - the array object
Method Detail

getArrayObject

public java.lang.Object getArrayObject()
Get the array object that stores the elements.


getBegin

public int getBegin()
Get the begin index.


getEnd

public int getEnd()
Get the non-inclusive end index.


storeElement

public void storeElement(int ind,
                         T obj)
Description copied from interface: ElementStore
Store an element.

Specified by:
storeElement in interface ElementStore<T>
Parameters:
ind - the element index.
obj - the element value.

getIndex

protected final int getIndex(int ind)
Map an element to the real index on the array.

Parameters:
ind - the index.
Returns:
the real index on the physical array.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is not within the [begin,end) range.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object