|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.martiansoftware.jsap.StringParser
com.martiansoftware.jsap.stringparsers.DoubleStringParser
edu.byu.ece.edif.util.jsap.BoundedDoubleStringParser
public class BoundedDoubleStringParser
A StringParser for parsing Doubles with
optional minimum and maximum values. The parse(String) method
delegates the actual parsing to new Double(String). If
new Double(String) throws a NumberFormatException, it
is encapsulated in a ParseException and re-thrown. Also, if the
parameter is lower than the minimum or higher than the maximum, a
ParseException is thrown.
The default minimum limit is Double.MIN_VALUE and the default maximum
limit is Double.MAX_VALUE.
StringParser,
DoubleStringParser,
Double| Field Summary | |
|---|---|
protected java.lang.Boolean |
includeMax
If true, the valid range includes the maximum value. |
protected java.lang.Boolean |
includeMin
If true, the valid range includes the minimum value. |
protected java.lang.Double |
max
Maximum acceptable value. |
protected java.lang.Double |
min
Minimum acceptable value. |
protected java.lang.String |
range
Text representation of the range. |
| Constructor Summary | |
|---|---|
BoundedDoubleStringParser(java.lang.Double min,
java.lang.Double max,
java.lang.Boolean includeMin,
java.lang.Boolean includeMax)
Deprecated. Use getParser(Double, Double, Boolean, Boolean). |
|
| Method Summary | |
|---|---|
static BoundedDoubleStringParser |
getParser()
|
static BoundedDoubleStringParser |
getParser(java.lang.Double min,
java.lang.Double max)
|
static BoundedDoubleStringParser |
getParser(java.lang.Double min,
java.lang.Double max,
java.lang.Boolean includeMin,
java.lang.Boolean includeMax)
|
java.lang.String |
getRange()
|
java.lang.Object |
parse(java.lang.String arg)
Parses the specified argument into a Double. |
| Methods inherited from class com.martiansoftware.jsap.StringParser |
|---|
setUp, tearDown |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.Boolean includeMin
protected java.lang.Boolean includeMax
protected java.lang.Double min
protected java.lang.Double max
protected java.lang.String range
Text representation of the range.
Examples:
| Constructor Detail |
|---|
@Deprecated
public BoundedDoubleStringParser(java.lang.Double min,
java.lang.Double max,
java.lang.Boolean includeMin,
java.lang.Boolean includeMax)
throws java.lang.IllegalArgumentException
getParser(Double, Double, Boolean, Boolean).
BoundedDoubleStringParser with the specified minimum
and maximum values. Also, the minimum and maximum can each optionally be
inclusive or non-inclusive.
min - Minimum acceptable value. If null, the minimum will be set to
Double.MIN_VALUEmax - Maximum acceptable value. If null, the maximum will be set to
Double.MAX_VALUEincludeMax - Determines if max should be considered part of the
valid range. If true, the valid range includes max. If null, includeMax
will default to true.
java.lang.IllegalArgumentException - if min is greater than max.| Method Detail |
|---|
public static BoundedDoubleStringParser getParser(java.lang.Double min,
java.lang.Double max,
java.lang.Boolean includeMin,
java.lang.Boolean includeMax)
throws java.lang.IllegalArgumentException
min - Minimum acceptable value. If null, the minimum will be set to
Double.MIN_VALUEmax - Maximum acceptable value. If null, the maximum will be set to
Double.MAX_VALUEincludeMin - Determines if min should be considered part of the
valid range. If true, the valid range includes min. If null, includeMin
will default to true.includeMax - Determines if max should be considered part of the
valid range. If true, the valid range includes max. If null, includeMax
will default to true.
java.lang.IllegalArgumentException - if min is greater than max.
public static BoundedDoubleStringParser getParser(java.lang.Double min,
java.lang.Double max)
throws java.lang.IllegalArgumentException
min - Minimum acceptable value. If null, the minimum will be set to
Double.MIN_VALUEmax - Maximum acceptable value. If null, the maximum will be set to
Double.MAX_VALUE
java.lang.IllegalArgumentException - if min is greater than max.
public static BoundedDoubleStringParser getParser()
throws java.lang.IllegalArgumentException
JSAP.DOUBLE_PARSER and is provided
for complete flexibility.
java.lang.IllegalArgumentException - Only if getParser(Double, Double,
Boolean, Boolean) does so.DoubleStringParser.getParser()public java.lang.String getRange()
range.
public java.lang.Object parse(java.lang.String arg)
throws com.martiansoftware.jsap.ParseException
new Double(String). If
new Double(String) throws a
NumberFormatException, it is encapsulated in a
ParseException and re-thrown. Also ensures that the value
specified is in the range for this parser.DoubleStringParser.parse(String)
parse in class com.martiansoftware.jsap.stringparsers.DoubleStringParserarg - the argument to parse
com.martiansoftware.jsap.ParseException - if the specified value is outside the valid range
or if new Double(arg) throws a NumberFormatException.Double,
StringParser.parse(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||