Package ucar.unidata.util
Class Parameter
- java.lang.Object
-
- ucar.unidata.util.Parameter
-
- All Implemented Interfaces:
Serializable
@Immutable public class Parameter extends Object implements Serializable
A parameter has a name and a value that is String, a double, or an array of doubles. A substitute for ucar.nc2.Attribute, to prevent dependencies of the ucar.unidata packages on ucar.nc2. LOOK will not implement Serializable in ver6; may be replaced by Attribute.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Parameter(String name, double value)
Create a scalar double-valued param.Parameter(String name, double[] value)
Create an array double-valued param.Parameter(String name, String val)
Create a String-valued param.Parameter(String name, Parameter from)
Copy constructor, with new name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
int
getLength()
Get the number of double values.String
getName()
Get the name of this Parameter.double
getNumericValue()
Retrieve numeric value, use if isString() is false.double
getNumericValue(int i)
Get the ith numeric value.double[]
getNumericValues()
Get array of numeric values as doubles.String
getStringValue()
Retrieve String value.int
hashCode()
boolean
isString()
True if value is a String.String
toString()
-
-
-
Constructor Detail
-
Parameter
public Parameter(String name, Parameter from)
Copy constructor, with new name.- Parameters:
name
- name of new Parameter.from
- copy values from here.
-
Parameter
public Parameter(String name, String val)
Create a String-valued param.- Parameters:
name
- name of new Parameter.val
- value of Parameter
-
Parameter
public Parameter(String name, double value)
Create a scalar double-valued param.- Parameters:
name
- name of new Parameter.value
- value of Parameter
-
Parameter
public Parameter(String name, double[] value)
Create an array double-valued param.- Parameters:
name
- name of new Parameter.value
- value of Parameter
-
-
Method Detail
-
getName
public String getName()
Get the name of this Parameter.- Returns:
- name
-
isString
public boolean isString()
True if value is a String.- Returns:
- if its String valued
-
getStringValue
@Nullable public String getStringValue()
Retrieve String value.- Returns:
- String value if this is a String valued attribute, else null.
-
getNumericValue
public double getNumericValue()
Retrieve numeric value, use if isString() is false. Equivalent togetNumericValue(0)
- Returns:
- the first element of the value array, or Exception if its a String.
-
getNumericValue
public double getNumericValue(int i)
Get the ith numeric value.- Parameters:
i
- index- Returns:
- ith numeric value, or Exception if its a String.
-
getLength
public int getLength()
Get the number of double values.- Returns:
- the number of values, 0 is its a string.
-
getNumericValues
@Nullable public double[] getNumericValues()
Get array of numeric values as doubles. Do not modify unless you own this object!- Returns:
- array of numeric values. LOOK: will return copy of array in ver 6.
-
-