View Javadoc

1   // Copyright 2006-2007, by the California Institute of Technology.
2   // ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged.
3   // Any commercial use must be negotiated with the Office of Technology Transfer
4   // at the California Institute of Technology.
5   //
6   // This software is subject to U. S. export control laws and regulations
7   // (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software
8   // is subject to U.S. export control laws and regulations, the recipient has
9   // the responsibility to obtain export licenses or other export authority as
10  // may be required before exporting such information to foreign countries or
11  // providing access to foreign nationals.
12  //
13  // $Id: Numeric.java 3383 2008-07-22 17:47:18Z pramirez $ 
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          //Remove angle brackets if found
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 }