ucar.unidata.util
Class Parameter

java.lang.Object
  extended by ucar.unidata.util.Parameter
All Implemented Interfaces:
Serializable

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.

Author:
caron
See Also:
Serialized Form

Constructor Summary
Parameter(String name, double value)
          Create a scalar double-valued param.
Parameter(String name, double[] value)
          Create a array double-valued param.
Parameter(String name, Parameter from)
          Copy constructir, with new name.
Parameter(String name, String val)
          Create a String-valued param.
 
Method Summary
 boolean equals(Object oo)
          Instances which have same content are equal.
 int getLength()
          Get the number of 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; only call if isString() is true.
 int hashCode()
          Override Object.hashCode() to implement equals.
 boolean isString()
          True if value is a String.
 String toString()
          String representation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Parameter

public Parameter(String name,
                 Parameter from)
Copy constructir, 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 a 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

public String getStringValue()
Retrieve String value; only call if isString() is true.

Returns:
String if this is a String valued attribute, else null.

getNumericValue

public double getNumericValue()
Retrieve numeric value, use if isString() is false. Equivalent to getNumericValue(0)

Returns:
the first element of the value array, or null if its a String.

getNumericValue

public double getNumericValue(int i)
Get the ith numeric value.

Parameters:
i - index
Returns:
ith numeric value

getLength

public int getLength()
Get the number of values.

Returns:
the number of values.

getNumericValues

public double[] getNumericValues()
Get array of numeric values as doubles. Do not modify unless you own this object!

Returns:
array of numeric values.

equals

public boolean equals(Object oo)
Instances which have same content are equal.

Overrides:
equals in class Object
Parameters:
oo - compare to this Parameter.
Returns:
true if equal.

hashCode

public int hashCode()
Override Object.hashCode() to implement equals.

Overrides:
hashCode in class Object
Returns:
haschcode

toString

public String toString()
String representation

Overrides:
toString in class Object
Returns:
nice String


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.