maspack.util
Class NumericIntervalRange

java.lang.Object
  extended by maspack.util.RangeBase
      extended by maspack.util.NumericIntervalRange
All Implemented Interfaces:
java.lang.Cloneable, Clonable, Range, Scannable

public class NumericIntervalRange
extends RangeBase

A base class for creating Range objects.


Field Summary
 
Fields inherited from interface maspack.util.Range
IllegalValue
 
Constructor Summary
NumericIntervalRange()
           
NumericIntervalRange(NumericInterval maxRange)
           
 
Method Summary
 NumericIntervalRange clone()
           
 void intersect(Range r)
          Intersects the set of valid values of this Range with those of another.
 boolean isEmpty()
          Returns true if this range is empty - i.e., if there are no valid values.
 boolean isValid(java.lang.Object obj, StringHolder errMsg)
          Returns true if the specified object is valid for this Range, and false otherwise.
 void scan(ReaderTokenizer rtok, java.lang.Object ref)
          Scans this element from a ReaderTokenizer.
 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
isWritable, makeValid, setError
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericIntervalRange

public NumericIntervalRange()

NumericIntervalRange

public NumericIntervalRange(NumericInterval maxRange)
Method Detail

isValid

public boolean isValid(java.lang.Object obj,
                       StringHolder errMsg)
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

isEmpty

public boolean isEmpty()
Returns true if this range is empty - i.e., if there are no valid values. This will typically result from the intersection of two non-overlapping ranges.

Specified by:
isEmpty in interface Range
Overrides:
isEmpty in class RangeBase
Returns:
true if this range has no valid values.

intersect

public void intersect(Range r)
Intersects the set of valid values of this Range with those of another. If the resulting intersection is null, then Range.isEmpty() should subsequently return true.

Specified by:
intersect in interface Range
Overrides:
intersect in class RangeBase
Parameters:
r - range to intersect with.

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

clone

public NumericIntervalRange clone()
Specified by:
clone in interface Clonable
Overrides:
clone in class RangeBase