|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.util.RangeBase
public abstract class RangeBase
A base class for creating Range objects.
Field Summary |
---|
Fields inherited from interface maspack.util.Range |
---|
IllegalValue |
Constructor Summary | |
---|---|
RangeBase()
|
Method Summary | |
---|---|
RangeBase |
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. |
abstract boolean |
isValid(java.lang.Object obj,
StringHolder errMsg)
Returns true if the specified object is valid for this Range, and false otherwise. |
boolean |
isWritable()
Returns true if this component should in fact be written to
secondary storage. |
java.lang.Object |
makeValid(java.lang.Object obj)
Projects an object to lie within the range allowed by this Range, if possible. |
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer. |
static void |
setError(StringHolder errMsg,
java.lang.String msg)
|
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 java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RangeBase()
Method Detail |
---|
public static void setError(StringHolder errMsg, java.lang.String msg)
public abstract boolean isValid(java.lang.Object obj, StringHolder errMsg)
errMsg
is not null
, then errMsg.value
should
be set to a message describing why the object is not valid.
isValid
in interface Range
obj
- Object to be testeserrMsg
- Optional handle for storing error message
public java.lang.Object makeValid(java.lang.Object obj)
obj
is already within the range, then
obj
should be returned unchanged. Otherwise, if it can be
projected to the range, then a new (projected) object should be
returned. Otherwise, if it cannot be projected, Range.IllegalValue
should be returned.
In particular, projectToRange(obj) != obj
should
be a valid indication that the obj
is not within range.
makeValid
in interface Range
obj
- object to be projected
null
.public boolean isEmpty()
isEmpty
in interface Range
public void intersect(Range r)
Range.isEmpty()
should subsequently return true
.
intersect
in interface Range
r
- range to intersect with.public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
write
.
scan
in interface Scannable
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objects
java.io.IOException
- if an I/O or formatting error occuredpublic boolean isWritable()
true
if this component should in fact be written to
secondary storage. This gives subclasses control over whether or
not they are actually written out.
isWritable
in interface Scannable
true
if this component should be written to
secondary storage.public void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
scan
and complete
enough to allow full reconstruction of the element.
write
in interface Scannable
pw
- stream for writing the elementfmt
- numeric formating informationref
- optional reference object which can be used for producing references to
other objects
java.io.IOException
- if an I/O error occuredpublic RangeBase clone()
clone
in interface Clonable
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |