|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.ivmaidns.util.ConstVector
public final class ConstVector
Class for immutable vectors for objects.
This final class is useful for representation of a
constant vector (container) of custom objects of any type. An
instance of this class encapsulates/wraps (when constructed) a
given Object array. Important notes: the component
type of the encapsulated Object array is hidden; an
object of this class may be serialized only if all custom objects
it contains are serializable.
ConstPair,
ObjectVector,
GComparator,
Serialized Form| Field Summary | |
|---|---|
protected java.lang.Object[] |
array
The wrapped (encapsulated) custom array of objects. |
| Constructor Summary | |
|---|---|
ConstVector(java.lang.Object[] array)
Constructs an immutable vector by wrapping a given custom array of objects. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Creates and returns a copy of this object. |
boolean |
equals(java.lang.Object obj)
Indicates whether this object is equal to the
specified one. |
java.lang.Object |
getAt(int index)
Returns value of the element at the specified index. |
boolean |
greaterThan(java.lang.Object obj)
Tests for being semantically greater than the argument. |
int |
hashCode()
Computes and returns a hash code value for the object. |
void |
integrityCheck()
Verifies this object for its integrity. |
int |
length()
Returns the number of elements in this vector. |
java.lang.Object[] |
toArray()
Returns a newly created array filled with the values of the elements of this vector. |
java.lang.String |
toString()
Converts vector to its 'in-line' string representation. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final java.lang.Object[] array
null (but its elements
may be null). Important notes:
array[index] must not be changed anyhow for every
index; the component type of array is of no
use here.
ConstVector(java.lang.Object[]),
length(),
getAt(int),
toArray(),
integrityCheck()| Constructor Detail |
|---|
public ConstVector(java.lang.Object[] array)
throws java.lang.NullPointerException
array - the object array (must be non-null) to be
encapsulated.
java.lang.NullPointerException - if array is null.getAt(int),
toArray(),
equals(java.lang.Object),
greaterThan(java.lang.Object),
toString()| Method Detail |
|---|
public int length()
this vector.
The result is the same as length of
toArray().
length in interface IndexablegetAt(int),
toArray()
public java.lang.Object getAt(int index)
throws java.lang.ArrayIndexOutOfBoundsException
toArray()[index].
getAt in interface Indexableindex - the index (must be in the range) at which to return an element.
null) at index.
java.lang.ArrayIndexOutOfBoundsException - if index is negative or is not less than
length().ConstVector(java.lang.Object[]),
length(),
toArray()public java.lang.Object[] toArray()
this vector.
Here, the result is the exact instance of Object[].
null), containing values of all the
elements of this vector.
java.lang.OutOfMemoryError - if there is not enough memory.ConstVector(java.lang.Object[]),
getAt(int),
length(),
equals(java.lang.Object),
greaterThan(java.lang.Object),
toString()public java.lang.Object clone()
this object.
Important notes: the encapsulated array is not cloned itself.
clone in interface ReallyCloneableclone in class java.lang.Objectnull and != this) of
this instance.
java.lang.OutOfMemoryError - if there is not enough memory.ConstVector(java.lang.Object[]),
toArray(),
equals(java.lang.Object)public int hashCode()
null elements of
this vector and mixes them all to produce a single
hash code value.
hashCode in class java.lang.Objectthis object.length(),
getAt(int),
equals(java.lang.Object)public boolean equals(java.lang.Object obj)
this object is equal to the
specified one.
This method returns true if and only if
obj is instance of this vector class and all the
elements of this vector are equal to the
corresponding elements of obj vector.
equals in class java.lang.Objectobj - the object (may be null) with which to compare.
true if and only if this value is the
same as obj value.length(),
getAt(int),
hashCode(),
greaterThan(java.lang.Object)public boolean greaterThan(java.lang.Object obj)
true if and only if obj is
instance of this class and this object
is greater than the specified object. Vectors are compared in the
element-by-element manner, starting at index 0 and
at each index elements are compared for equality and the first
non-equal elements pair is compared through INSTANCE
of GComparator class.
greaterThan in interface Sortableobj - the second compared object (may be null).
true if obj is comparable with
this and this object is greater than
obj, else false.length(),
getAt(int),
equals(java.lang.Object)public java.lang.String toString()
null then "null") of this vector are
placed into the resulting string in the direct index order,
delimited by a single space.
toString in class java.lang.Objectnull) of
this object.
java.lang.OutOfMemoryError - if there is not enough memory.ConstVector(java.lang.Object[]),
toArray()public void integrityCheck()
this object for its integrity.
The elements are not checked. For debug purpose only.
integrityCheck in interface Verifiablejava.lang.InternalError - if integrity violation is detected.ConstVector(java.lang.Object[])
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||