@Immutable public class Attribute extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Attribute.Builder |
| Constructor and Description |
|---|
Attribute(String name,
Number val)
Create a scalar, signed, numeric-valued Attribute.
|
Attribute(String name,
String val)
Create a String-valued Attribute.
|
| Modifier and Type | Method and Description |
|---|---|
static Attribute.Builder |
builder()
Create an Attribute builder.
|
static Attribute.Builder |
builder(String name)
Create an Attribute builder with the given Attribute name.
|
static Attribute |
emptyValued(String name,
ArrayType dtype)
Create an Attribute with a datatype but no value.
|
static Attribute |
emptyValued(String name,
DataType dtype)
Deprecated.
use emptyValued(String name, ArrayType dtype)
|
boolean |
equals(Object o) |
static Attribute |
fromArray(String name,
Array values)
Deprecated.
use fromArray(String name, Array> values)
|
static Attribute |
fromArray(String name,
Array<?> values)
Create an Attribute from an Array.
|
static Attribute |
fromParameter(Parameter param)
Create an Attribute from a ucar.unidata.util.Parameter.
|
ArrayType |
getArrayType()
Get the data type of the Attribute value.
|
Array<?> |
getArrayValues()
Get the values as an ucar.array.Array.
|
DataType |
getDataType()
Deprecated.
use getArrayType()
|
EnumTypedef |
getEnumType()
Get the EnumTypedef of the Attribute value, if DataType is an ENUM.
|
int |
getLength()
Get the length of the array of values
|
String |
getName()
Get the Attribute name, same as the short name.
|
Number |
getNumericValue()
Retrieve first numeric value.
|
Number |
getNumericValue(int index)
Retrieve a numeric value by index.
|
String |
getShortName()
Get the Attribute name.
|
String |
getStringValue()
Retrieve first String value if this is a String valued attribute, else null.
|
String |
getStringValue(int index)
Retrieve ith String value; only call if isString() is true.
|
Object |
getValue(int index)
Get the value as an Object (String or Number).
|
Array |
getValues()
Get the values as an ucar.ma2.Array.
|
int |
hashCode() |
boolean |
isArray()
True if value is an array (getLength() > 1)
|
boolean |
isString()
True if value is of type String and not null.
|
Attribute.Builder |
toBuilder()
Turn into a mutable Builder.
|
static Parameter |
toParameter(Attribute att)
Create an Attribute from a ucar.unidata.util.Parameter.
|
String |
toString() |
public Attribute(String name, @Nullable String val)
name - name of Attributeval - value of Attributepublic static Attribute fromParameter(Parameter param)
public static Parameter toParameter(Attribute att)
@Deprecated public static Attribute fromArray(String name, Array values)
public static Attribute fromArray(String name, Array<?> values)
@Deprecated public static Attribute emptyValued(String name, DataType dtype)
public static Attribute emptyValued(String name, ArrayType dtype)
@Deprecated public DataType getDataType()
public ArrayType getArrayType()
@Nullable public EnumTypedef getEnumType()
public int getLength()
public String getName()
@Nullable public Number getNumericValue()
getNumericValue(0)@Nullable public Number getNumericValue(int index)
index - the index into the value array.value[index], or null if its a non-parseable String or
the index is out of range.public String getShortName()
@Nullable public String getStringValue()
@Nullable public String getStringValue(int index)
index - which index@Nullable public Object getValue(int index)
index - index into value Array.public boolean isArray()
public boolean isString()
public Attribute.Builder toBuilder()
public static Attribute.Builder builder()
public static Attribute.Builder builder(String name)