maspack.util
Class EnumRange<E extends java.lang.Enum>

java.lang.Object
  extended by maspack.util.RangeBase
      extended by maspack.util.EnumRange<E>
All Implemented Interfaces:
java.lang.Cloneable, Clonable, Range, Scannable

public class EnumRange<E extends java.lang.Enum>
extends RangeBase


Field Summary
 
Fields inherited from interface maspack.util.Range
IllegalValue
 
Constructor Summary
EnumRange(java.lang.Class<E> cls)
           
EnumRange(java.lang.Class<E> cls, E[] validEnums)
           
 
Method Summary
 E[] getValidEnums()
           
 java.lang.String getValidEnumsString()
           
 boolean isValid(java.lang.Object obj, StringHolder errMsg)
          Returns true if the specified object is valid for this Range, and false otherwise.
static void main(java.lang.String[] args)
           
 void scan(ReaderTokenizer rtok, java.lang.Object ref)
          Scans this element from a ReaderTokenizer.
 java.lang.String toString()
           
 void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref)
          Writes a text description of this element to a PrintWriter.
 
Methods inherited from class maspack.util.RangeBase
clone, intersect, isEmpty, isWritable, makeValid, setError
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnumRange

public EnumRange(java.lang.Class<E> cls)

EnumRange

public EnumRange(java.lang.Class<E> cls,
                 E[] validEnums)
Method Detail

getValidEnums

public E[] getValidEnums()

getValidEnumsString

public java.lang.String getValidEnumsString()

isValid

public boolean isValid(java.lang.Object obj,
                       StringHolder errMsg)
Description copied from class: RangeBase
Returns true if the specified object is valid for this Range, and false otherwise. If the object is not valid, and errMsg is not null, then errMsg.value should be set to a message describing why the object is not valid.

Specified by:
isValid in interface Range
Specified by:
isValid in class RangeBase
Parameters:
obj - Object to be testes
errMsg - Optional handle for storing error message
Returns:
true if the object is valid

scan

public void scan(ReaderTokenizer rtok,
                 java.lang.Object ref)
          throws java.io.IOException
Scans this element from a ReaderTokenizer. The expected text format is assumed to be compatible with that produced by write.

Specified by:
scan in interface Scannable
Overrides:
scan in class RangeBase
Parameters:
rtok - Tokenizer from which to scan the element
ref - optional reference object which can be used for resolving references to other objects
Throws:
java.io.IOException - if an I/O or formatting error occured

write

public void write(java.io.PrintWriter pw,
                  NumberFormat fmt,
                  java.lang.Object ref)
           throws java.io.IOException
Writes a text description of this element to a PrintWriter. The text description should be compatable with scan and complete enough to allow full reconstruction of the element.

Specified by:
write in interface Scannable
Overrides:
write in class RangeBase
Parameters:
pw - stream for writing the element
fmt - numeric formating information
ref - optional reference object which can be used for producing references to other objects
Throws:
java.io.IOException - if an I/O error occured

toString

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

main

public static void main(java.lang.String[] args)