01: package org.incava.jagol;
02:
03: import java.io.*;
04: import java.util.*;
05:
06: /**
07: * Represents an option that is an double.
08: */
09: public class DoubleOption extends NonBooleanOption {
10: private Double value;
11:
12: public DoubleOption(String longName, String description) {
13: this (longName, description, null);
14: }
15:
16: public DoubleOption(String longName, String description,
17: Double value) {
18: super (longName, description);
19: this .value = value;
20: }
21:
22: /**
23: * Returns the value. Returns null if not set.
24: */
25: public Double getValue() {
26: return value;
27: }
28:
29: /**
30: * Sets the value.
31: */
32: public void setValue(Double value) {
33: this .value = value;
34: }
35:
36: /**
37: * Sets the value from the string, for a double type.
38: */
39: public void setValue(String value) throws InvalidTypeException {
40: tr.Ace.log("value: '" + value + "'");
41: try {
42: setValue(new Double(value));
43: } catch (NumberFormatException nfe) {
44: throw new InvalidTypeException(longName
45: + " expects double argument, not '" + value + "'");
46: }
47: }
48:
49: public String toString() {
50: return value == null ? "" : value.toString();
51: }
52:
53: protected String getType() {
54: return "double";
55: }
56:
57: }
|