public class Attribute
extends ucar.nc2.CDMNode
Modifier and Type | Class and Description |
---|---|
static class |
Attribute.Builder
A builder for Attributes
|
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.
|
boolean |
equals(Object o)
Instances which have same content are equal.
|
DataType |
getDataType()
Get the data type of the Attribute value.
|
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.
|
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.
|
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.
|
String |
toString() |
public Attribute(String name, Number val)
name
- name of Attributeval
- value of Attributepublic static Attribute.Builder builder()
public static Attribute.Builder builder(String name)
public boolean equals(Object o)
public DataType getDataType()
@Nullable public EnumTypedef getEnumType()
public int getLength()
public String getName()
getName
in class ucar.nc2.CDMNode
@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.@Nullable public String getStringValue()
isString()
@Nullable public String getStringValue(int index)
index
- which indexisString()
@Nullable public Object getValue(int index)
index
- which indexpublic int hashCode()
public boolean isArray()
public boolean isString()
public Attribute.Builder toBuilder()