1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package gov.nasa.pds.tools.label;
17
18 /***
19 * This class represents a numeric scalar. It is not type
20 * specific so everything is represented as a String.
21 * @author pramirez
22 * @version $Revision: 2606 $
23 *
24 */
25 public class Numeric extends Scalar {
26 private String units;
27 private int radix;
28
29 /***
30 * Constructs a Numeric with the given value
31 * @param value of numeric
32 */
33 public Numeric(String value) {
34 this(value, null, 10);
35 }
36
37 /***
38 * Constructs a Numeric with the given value and units
39 * @param value of numeric
40 * @param units of numeric
41 */
42 public Numeric(String value, String units) {
43 this(value, units, 10);
44 }
45
46 /***
47 * Constructs a Numeric with the given value and radix
48 * @param value of numeric
49 * @param radix of numeric
50 */
51 public Numeric(String value, int radix) {
52 this(value, null, radix);
53 }
54
55 /***
56 * Constructs a Numeric with the given value, units and radix
57 * @param value of numeric
58 * @param units of numeric
59 * @param radix of numeric
60 */
61 public Numeric(String value, String units, int radix) {
62 super(value);
63 this.units = units;
64 this.radix = radix;
65 }
66
67 /***
68 * Sets the units
69 * @param units of the numeric
70 */
71 public void setUnits(String units) {
72
73 if (units.startsWith("<") && units.endsWith(">"))
74 this.units = units.substring(1, units.length()-1).trim();
75 else
76 this.units = units.trim();
77 }
78
79 /***
80 * Retrieves the units
81 * @return units
82 */
83 public String getUnits() {
84 return units;
85 }
86
87 /***
88 * Sets the radix
89 * @param radix of the numeric
90 */
91 public void setRadix(int radix) {
92 this.radix = radix;
93 }
94
95 /***
96 * Retrieves the base
97 * @return base
98 */
99 public int getRadix() {
100 return radix;
101 }
102
103 }