de.grogra.util
Class EnumerationType

java.lang.Object
  extended by de.grogra.reflect.MemberBase
      extended by de.grogra.reflect.TypeImpl
          extended by de.grogra.util.EnumerationType
All Implemented Interfaces:
Member, Type, javax.swing.ListModel

public class EnumerationType
extends TypeImpl
implements javax.swing.ListModel

An EnumerationType is a type whose values are drawn from an enumeration. The enumeration type is either integral (consecutive int values beginning with 0) or a reference type (a set of Object values).

Author:
Ole Kniemeyer

Field Summary
protected  ObjectList descriptions
          Contains the descriptions for the values of this enumeration type.
static EnumerationType INT_ENUMERATION
          An "abstract" base enumeration type which is used as supertype for those enumeration types which use ints to encode their values.
static EnumerationType OBJECT_ENUMERATION
          An "abstract" base enumeration type which is used as supertype for those enumeration types which use Objects to encode their values.
protected  ObjectList values
          Contains the values of this enumeration type.
 
Fields inherited from class de.grogra.reflect.TypeImpl
typeId
 
Fields inherited from class de.grogra.reflect.MemberBase
annots, declaringType, descriptor, modifiers, name
 
Fields inherited from interface de.grogra.reflect.Type
BOOLEAN, BYTE, CHAR, CLASS, DOUBLE, FLOAT, FLOATING_POINT, INT, INTEGRAL, INVALID, LOCAL_CLASS_MODIFIERS, LONG, MEMBER_CLASS_MODIFIERS, MEMBER_INTERFACE_MODIFIERS, NULL, NUMBER, NUMERIC, OBJECT, SHORT, STRING, TOP_LEVEL_CLASS_MODIFIERS, TOP_LEVEL_INTERFACE_MODIFIERS, TYPE, TYPE_0, VOID
 
Fields inherited from interface de.grogra.reflect.Member
ABSTRACT, ACCESS_MODIFIERS, ARRAY, BRIDGE, CONSTANT, FINAL, INTERFACE, JAVA_MODIFIERS, LOCAL_CLASS, MIN_UNUSED_MODIFIER, NATIVE, PRIVATE, PROTECTED, PUBLIC, STATIC, STRICT, SYNCHRONIZED, SYNTHETIC, TRANSIENT, VARARGS, VOLATILE
 
Constructor Summary
EnumerationType(java.lang.String name, I18NBundle bundle, int count)
          Creates a new EnumerationType consisting of count values of type int beginning with 0.
EnumerationType(java.lang.String name, I18NBundle bundle, java.lang.String[] suffixes)
          Creates a new EnumerationType consisting of keys.length values of type int beginning with 0.
EnumerationType(java.lang.String name, I18NBundle bundle, java.lang.String[] suffixes, java.lang.Object[] values, Type implType)
           
EnumerationType(java.lang.String name, java.lang.Object[] values, EnumerationType superType, Type implType)
          Creates a new EnumerationType consisting of values.length values, their type being determined by supertype/code>.
EnumerationType(java.lang.String name, java.lang.String[] descriptions)
          Creates a new EnumerationType consisting of descriptions.length values of type int beginning with 0.
 
Method Summary
 void addListDataListener(javax.swing.event.ListDataListener l)
           
 java.lang.Object getDescriptionFor(java.lang.Object value)
           
 java.lang.Object getElementAt(int index)
           
 java.lang.Class getImplementationClass()
           
 int getSize()
           
 java.lang.Object getValueFor(java.lang.Object description)
           
 boolean isStringSerializable()
           
 void removeListDataListener(javax.swing.event.ListDataListener l)
           
 java.lang.Object valueOf(java.lang.String s)
           
 
Methods inherited from class de.grogra.reflect.TypeImpl
cloneObject, createArray, getArrayType, getBinaryName, getComponentType, getDeclaredField, getDeclaredFieldCount, getDeclaredInterface, getDeclaredInterfaceCount, getDeclaredMethod, getDeclaredMethodCount, getDeclaredType, getDeclaredTypeCount, getDefaultElementValue, getLookup, getPackage, getSimpleName, getSupertype, getTypeId, getTypeLoader, isInstance, newInstance, toString
 
Methods inherited from class de.grogra.reflect.MemberBase
getDeclaredAnnotation, getDeclaredAnnotationCount, getDeclaringType, getDescriptor, getModifiers, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.grogra.reflect.Member
getDeclaredAnnotation, getDeclaredAnnotationCount, getDeclaringType, getDescriptor, getModifiers, getName
 

Field Detail

descriptions

protected ObjectList descriptions
Contains the descriptions for the values of this enumeration type.


INT_ENUMERATION

public static final EnumerationType INT_ENUMERATION
An "abstract" base enumeration type which is used as supertype for those enumeration types which use ints to encode their values.


OBJECT_ENUMERATION

public static final EnumerationType OBJECT_ENUMERATION
An "abstract" base enumeration type which is used as supertype for those enumeration types which use Objects to encode their values.


values

protected ObjectList values
Contains the values of this enumeration type.

Constructor Detail

EnumerationType

public EnumerationType(java.lang.String name,
                       I18NBundle bundle,
                       int count)
Creates a new EnumerationType consisting of count values of type int beginning with 0. The representation of the values is obtained from the specified resource bundle: The used key for value i is name.i.

Parameters:
name - the base name for the keys and the name of the type
bundle - the resource bundle to obtain representations for the values
count - the number of values of this enumeration

EnumerationType

public EnumerationType(java.lang.String name,
                       I18NBundle bundle,
                       java.lang.String[] suffixes)
Creates a new EnumerationType consisting of keys.length values of type int beginning with 0. The representation of the values is obtained from the specified resource bundle using the suffixes: The keys for the bundle are the concatenations name + '.' + suffixes[i].

Parameters:
name - a name for the type
bundle - the resource bundle to obtain representations for the values
suffixes - the suffixes to use for the resource bundle

EnumerationType

public EnumerationType(java.lang.String name,
                       I18NBundle bundle,
                       java.lang.String[] suffixes,
                       java.lang.Object[] values,
                       Type implType)

EnumerationType

public EnumerationType(java.lang.String name,
                       java.lang.Object[] values,
                       EnumerationType superType,
                       Type implType)
Creates a new EnumerationType consisting of values.length values, their type being determined by supertype/code>.

Parameters:
name - a name for the type
values - the representation of the enumeration values
superType - the supertype
implType - the class of the internal values

EnumerationType

public EnumerationType(java.lang.String name,
                       java.lang.String[] descriptions)
Creates a new EnumerationType consisting of descriptions.length values of type int beginning with 0. A string representation of the values is obtained from the specified descriptions.

Parameters:
name - a name for the type
descriptions - strings to represent the values
Method Detail

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Specified by:
addListDataListener in interface javax.swing.ListModel

getDescriptionFor

public java.lang.Object getDescriptionFor(java.lang.Object value)

getElementAt

public java.lang.Object getElementAt(int index)
Specified by:
getElementAt in interface javax.swing.ListModel

getImplementationClass

public java.lang.Class getImplementationClass()
Specified by:
getImplementationClass in interface Type
Overrides:
getImplementationClass in class TypeImpl

getSize

public int getSize()
Specified by:
getSize in interface javax.swing.ListModel

getValueFor

public java.lang.Object getValueFor(java.lang.Object description)

isStringSerializable

public boolean isStringSerializable()
Specified by:
isStringSerializable in interface Type
Overrides:
isStringSerializable in class TypeImpl

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Specified by:
removeListDataListener in interface javax.swing.ListModel

valueOf

public java.lang.Object valueOf(java.lang.String s)
Specified by:
valueOf in interface Type
Overrides:
valueOf in class TypeImpl