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