|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.nc2.Attribute
@Immutable public class Attribute
An Attribute has a name and a value, used for associating arbitrary metadata with a Variable or a Group. The value can be a one dimensional array of Strings or numeric values.
Attributes are immutable.
Constructor Summary | |
---|---|
Attribute(Parameter param)
A copy constructor using a ucar.unidata.util.Parameter. |
|
Attribute(java.lang.String name,
Array values)
Construct attribute with Array of values. |
|
Attribute(java.lang.String name,
Attribute from)
Copy constructor |
|
Attribute(java.lang.String name,
java.util.List values)
Construct attribute with list of String or Number values. |
|
Attribute(java.lang.String name,
java.lang.Number val)
Create a scalar numeric-valued Attribute. |
|
Attribute(java.lang.String name,
java.lang.String val)
Create a String-valued Attribute. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object o)
Instances which have same content are equal. |
DataType |
getDataType()
Get the data type of the Attribute value. |
int |
getLength()
Get the length of the array of values; = 1 if scaler. |
java.lang.String |
getName()
Get the name of this Attribute. |
java.lang.Number |
getNumericValue()
Retrieve numeric value. |
java.lang.Number |
getNumericValue(int index)
Retrieve a numeric value by index. |
java.lang.String |
getStringValue()
Retrieve String value; only call if isString() is true. |
java.lang.String |
getStringValue(int index)
Retrieve ith String value; only call if isString() is true. |
java.lang.Object |
getValue(int index)
Get the value as an Object. |
Array |
getValues()
Get the value as an Array. |
int |
hashCode()
Override Object.hashCode() to implement equals. |
boolean |
isArray()
True if value is an array (getLength() > 1) |
boolean |
isString()
True if value is a String or String[]. |
java.lang.String |
toString()
CDL representation, not strict |
java.lang.String |
toString(boolean strict)
CDL representation |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Attribute(java.lang.String name, Attribute from)
name
- name of Attributefrom
- copy value from here.public Attribute(java.lang.String name, java.lang.String val)
name
- name of Attributeval
- value of Attributepublic Attribute(java.lang.String name, java.lang.Number val)
name
- name of Attributeval
- value of Attributepublic Attribute(java.lang.String name, Array values)
name
- name of attributevalues
- array of values.public Attribute(java.lang.String name, java.util.List values)
name
- name of attributevalues
- list of values. must be String or Number, must all be the same type, and have at least 1 memberpublic Attribute(Parameter param)
param
- copy info from here.Method Detail |
---|
public java.lang.String getName()
public DataType getDataType()
public boolean isString()
public boolean isArray()
public int getLength()
public Array getValues()
public java.lang.Object getValue(int index)
index
- which index
public java.lang.String getStringValue()
isString()
public java.lang.String getStringValue(int index)
index
- which index
isString()
public java.lang.Number getNumericValue()
getNumericValue(0)
public java.lang.Number getNumericValue(int index)
index
- the index into the value array.
value[index]
, or null if its a non-parsable String or
the index is out of range.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean strict)
strict
- if true, create strict CDL, escaping names
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |