edu.stanford.rt.datatype
Class EnumType

java.lang.Object
  |
  +--edu.stanford.rt.datatype.DataType
        |
        +--edu.stanford.rt.datatype.SimpleType
              |
              +--edu.stanford.rt.datatype.OrderedType
                    |
                    +--edu.stanford.rt.datatype.EnumType

public class EnumType
extends OrderedType

Author:
Ninghui Li, Sandra Qiu
Represents EnumType element in DomainSpecification. Each EnumType declaration object knows its legal values and the ordering of the values if the values are ordered.

Field Summary
private  boolean ignoreCase
          are values case-sensitive?
private  boolean ordered
          are values ordered in any way?
private  int size
          the number of values this type has
private  java.util.ArrayList values
          the list of values in their natural order, i.e.
private  java.util.HashSet valuesCopy
          We also store the values in a hash set to speed up membership tests.
private  DataType valueType
          Defines the ordering of values.
 
Fields inherited from class edu.stanford.rt.datatype.DataType
 
Constructor Summary
EnumType(java.lang.String name, DataType valueType, OrderedMap enumValues, boolean ignoreCase, boolean ordered, int size)
          Constructor for EnumType.
 
Method Summary
 int compares(DataValue value1, DataValue value2)
          Method compares.
 boolean contains(java.lang.String value)
          Method contains.
 int getSize()
          Method getSize.
 java.util.List getValues()
          Method getValues.
 DataType getValueType()
          Method getValueType.
 boolean isIgnoreCase()
          Method isIgnoreCase.
 boolean isOrdered()
          Method isOrdered.
 boolean isValidValue(DataValue v)
          Check if the DataValue o is a legal value for its type.
 void setValueType(DataType type)
          Method setValueType.
 java.lang.String toString(java.lang.String indent)
          Method toString.
 
Methods inherited from class edu.stanford.rt.datatype.DataType
getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

size

private int size
the number of values this type has


valueType

private DataType valueType
Defines the ordering of values.


ignoreCase

private boolean ignoreCase
are values case-sensitive?


ordered

private boolean ordered
are values ordered in any way?


values

private java.util.ArrayList values
the list of values in their natural order, i.e. the order that being added to the list


valuesCopy

private java.util.HashSet valuesCopy
We also store the values in a hash set to speed up membership tests.

Constructor Detail

EnumType

public EnumType(java.lang.String name,
                DataType valueType,
                OrderedMap enumValues,
                boolean ignoreCase,
                boolean ordered,
                int size)
         throws java.lang.IllegalArgumentException
Constructor for EnumType.

Method Detail

setValueType

public void setValueType(DataType type)
Method setValueType.

Parameters:
type -

getValueType

public DataType getValueType()
Method getValueType.

Returns:
DataType

getValues

public java.util.List getValues()
Method getValues.

returns an unmodifiable view of the legal values.

Returns:
List

contains

public boolean contains(java.lang.String value)
Method contains.

checks whether the given value is part of the legal values.

Parameters:
value -
Returns:
boolean

getSize

public int getSize()
Method getSize.

returns the actual number of legal values defined for this type.

Returns:
int

isIgnoreCase

public boolean isIgnoreCase()
Method isIgnoreCase.

Returns:
boolean

isOrdered

public boolean isOrdered()
Method isOrdered.

Returns:
boolean

isValidValue

public boolean isValidValue(DataValue v)
Description copied from class: SimpleType
Check if the DataValue o is a legal value for its type.

Specified by:
isValidValue in class SimpleType

compares

public int compares(DataValue value1,
                    DataValue value2)
Description copied from class: OrderedType
Method compares. Compares two DataValue objects.

Specified by:
compares in class OrderedType
Parameters:
value1 -
value2 -
Returns:
int

toString

public java.lang.String toString(java.lang.String indent)
Description copied from class: DataType
Method toString.

Overrides:
toString in class DataType
Parameters:
indent -
Returns:
String