|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.lucidviews.util.Enumeration<V>
V
- the type of value (EnumValue) stored in this enumerationpublic class Enumeration<V extends EnumValue>
An enumerated list of values.
An enumeration is a finite set of distinct values.
Each value in an Enumeration
is an instance of an
EnumValue
. Creating an enumeration simply requires you to
create a sub-class of EnumValue
- see the documentation of that
class for more information.
Note: Java version 1.5 contains support for enum types. These classes
(Enumeration
and EnumValue
) are provided to give
backwards compatibiity with previous versions of Java.
These classes also provide the ability to define sub-lists. An
EnumValue
class can extend where one
enumeration is an extension of another.
EnumValue
Field Summary | |
---|---|
protected Enumeration<? super V> |
_superEnumeration
The super enumeration - this enumeration is a sub-list within the super enumeration. |
protected List<V> |
_values
The values in this enumeration. |
protected static Enumeration |
NO_SUPER_ENUMERATION
Value assigned to the _superEnumeration variable when there
is no super enumeration. |
Constructor Summary | |
---|---|
Enumeration()
Create an enumeration. |
|
Enumeration(Enumeration<? super V> superEnumeration)
Create an enumeration. |
|
Enumeration(Enumeration<? super V> superEnumeration,
int initialCapacity)
Create an enumeration, specifying the number of values so that the enumeration list can be sized at creation, thereby improving performance. |
|
Enumeration(int initialCapacity)
Create an enumeration, specifying the number of values so that the enumeration list can be sized at creation, thereby improving performance. |
Method Summary | |
---|---|
(package private) int |
addValue(V value)
Add a value to this enumeration. |
boolean |
equals(Object obj)
|
Class<V> |
getType()
Returns the type of enum value being stored in this enumeration. |
protected String |
getTypeString()
Get the name of the type of object held in this enumeration. |
int |
hashCode()
|
boolean |
isEmpty()
Tests if this enumeration has no values. |
ListIterator<? extends V> |
listIterator()
Returns an iterator of the values in this enumeration (in proper sequence). |
V |
lookupValue(Object value)
Lookup a value in this enumeration. |
int |
size()
Returns the number of values in this enumeration. |
Object[] |
toArray()
Returns an array containing all of the values in this enumeration in the correct order. |
String |
toString()
|
static EnumValue<?> |
valueOf(Class<? extends EnumValue<?>> enumType,
String name)
Returns the EnumValue of the specified enumeration type
with the specified name. |
V |
valueOf(String name)
Lookup a value in this enumeration using its name. |
EnumValue[] |
values()
Get the values of this enumeration. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final Enumeration NO_SUPER_ENUMERATION
_superEnumeration
variable when there
is no super enumeration.
protected Enumeration<? super V extends EnumValue> _superEnumeration
null
if there is no
super enumeration.
protected List<V extends EnumValue> _values
Constructor Detail |
---|
public Enumeration(int initialCapacity)
initialCapacity
- the expected number of values in this enumerationpublic Enumeration()
public Enumeration(Enumeration<? super V> superEnumeration, int initialCapacity)
superEnumeration
- the enumeration this enumeration is a sub-list ofinitialCapacity
- the expected number of values in this enumerationpublic Enumeration(Enumeration<? super V> superEnumeration)
superEnumeration
- the enumeration this enumeration is a sub-list ofMethod Detail |
---|
int addValue(V value) throws IllegalArgumentException, IllegalStateException
EnumValue
class. Attempting to add a
different type of value to the enumeration will result in an exception.
Enumeration
s are not editable once they have been created.
This method should only be called from within the EnumValue
class while the list of enumeration values is being built. Therefore this
method has been given package scope to prevent the list being changed
after it has been created.
value
- enumeration value to be added to this list
IllegalArgumentException
- invalid value for this enumeration
IllegalStateException
- invalid value for this enumerationpublic V lookupValue(Object value) throws NoSuchElementException
value
parameter can be any Object
. The
return value is always an EnumValue
that is considered equal
(using the equals
method to compare values) to the specified
value
.
Enumeration
contains an EnumValue
with id 6 and string-value "yard":
lookupValue( "yard" );
lookupValue( new Integer( 6 ) );
EnumValue
instance.
value
- the value to find
NoSuchElementException
- the value could not be foundprotected String getTypeString()
getType()
returns null
).
public Class<V> getType()
null
if no values have been added to this
enumeration list.
public int size()
public boolean isEmpty()
true
if no values have been defined in this
enuemration; false
otherwisepublic Object[] toArray()
public ListIterator<? extends V> listIterator()
EnumValue
s)EnumValue
public EnumValue[] values()
public V valueOf(String name) throws IllegalArgumentException
name
- the name of the enumeration value
IllegalArgumentException
- if there is no value with the specified
namepublic static EnumValue<?> valueOf(Class<? extends EnumValue<?>> enumType, String name) throws IllegalArgumentException, NullPointerException
EnumValue
of the specified enumeration type
with the specified name. The name must match with the text value of
the enum value. (Extraneous whitespace characters are not permitted.)
enumType
- the Class
object of the
EnumValue
from which to return a constantname
- the text value of the enum value to return
EnumValue
from the specified enumeration type
with the specified name
IllegalArgumentException
- if the specified enumeration class has
no constant with the specified name, or
the specified class does not represent
an enum type
NullPointerException
- if enumType
or
name
is null
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |