@Immutable public class Attribute extends CDMNode
Modifier | Constructor and Description |
---|---|
|
Attribute(Parameter param)
A copy constructor using a ucar.unidata.util.Parameter.
|
protected |
Attribute(String name)
Constructor.
|
|
Attribute(String name,
Array values)
Construct attribute with Array of values.
|
|
Attribute(String name,
Attribute from)
Copy constructor
|
|
Attribute(String name,
DataType dataType,
boolean isUnsigned)
Construct an empty attribute with no values
|
|
Attribute(String name,
List values)
Construct attribute with list of String or Number values.
|
|
Attribute(String name,
Number val)
Create a scalar numeric-valued Attribute.
|
|
Attribute(String name,
Number val,
boolean isUnsigned) |
|
Attribute(String name,
String val)
Create a String-valued Attribute.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(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
|
Number |
getNumericValue()
Retrieve numeric value.
|
Number |
getNumericValue(int index)
Retrieve a numeric value by index.
|
String |
getStringValue()
Retrieve String value; only call if isString() is true.
|
String |
getStringValue(int index)
Retrieve ith String value; only call if isString() is true.
|
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.
|
void |
hashCodeShow(Indent indent) |
boolean |
isArray()
True if value is an array (getLength() > 1)
|
boolean |
isString()
True if value is of type String and not null.
|
boolean |
isUnsigned()
Find whether the underlying data should be interpreted as unsigned.
|
static Map<String,Attribute> |
makeMap(List<Attribute> atts)
Turn a list into a map
|
void |
setName(String name)
Set the name of this Attribute.
|
protected void |
setValues(Array arr)
set the values from an Array
|
String |
toString()
CDL representation, not strict
|
String |
toString(boolean strict)
CDL representation, may be strict
|
protected void |
writeCDL(Formatter f,
boolean strict)
Write CDL representation into f
|
getDODSName, getFullName, getFullNameEscaped, getGroup, getImmutable, getName, getParentGroup, getParentStructure, getShortName, getSort, isMemberOfStructure, localhash, setDODSName, setImmutable, setParentGroup, setParentStructure, setShortName, setSort, unwrap
public Attribute(String name, Attribute from)
name
- name of new Attributefrom
- copy value from here.public Attribute(String name, String val)
name
- name of Attributeval
- value of Attributepublic Attribute(String name, Number val)
name
- name of Attributeval
- value of Attributepublic Attribute(String name, Array values)
name
- name of attributevalues
- array of values.public Attribute(String name, DataType dataType, boolean isUnsigned)
name
- name of attributedataType
- type of Attribute.public Attribute(String name, 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.protected Attribute(String name)
name
- name of Attributepublic static Map<String,Attribute> makeMap(List<Attribute> atts)
atts
- list of attributespublic DataType getDataType()
public boolean isArray()
public int getLength()
public boolean isUnsigned()
public Array getValues()
public Object getValue(int index)
index
- which indexpublic boolean isString()
public String getStringValue()
isString()
public String getStringValue(int index)
index
- which indexisString()
public Number getNumericValue()
getNumericValue(0)
public 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 String toString()
public String toString(boolean strict)
strict
- if true, create strict CDL, escaping namesprotected void writeCDL(Formatter f, boolean strict)
f
- write into thisstrict
- if true, create strict CDL, escaping namesprotected void setValues(Array arr)
arr
- value of Attributepublic void setName(String name)
name
- name of attributepublic boolean equals(Object o)
public int hashCode()
public void hashCodeShow(Indent indent)
hashCodeShow
in class CDMNode
Copyright © 1999–2015 UCAR/Unidata. All rights reserved.