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(java.lang.String name,
java.lang.Number val)
Create a scalar, signed, numeric-valued Attribute.
|
Attribute(java.lang.String name,
java.lang.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(java.lang.String name)
Create an Attribute builder with the given Attribute name.
|
boolean |
equals(java.lang.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
|
java.lang.String |
getName()
Get the Attribute name.
|
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 of type String and not null.
|
Attribute.Builder |
toBuilder()
Turn into a mutable Builder.
|
java.lang.String |
toString() |
public Attribute(java.lang.String name, java.lang.Number val)
name
- name of Attributeval
- value of Attributepublic Attribute(java.lang.String name, java.lang.String val)
name
- name of Attributeval
- value of Attributepublic static Attribute.Builder builder()
public static Attribute.Builder builder(java.lang.String name)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public DataType getDataType()
@Nullable public EnumTypedef getEnumType()
public int getLength()
public java.lang.String getName()
getName
in class ucar.nc2.CDMNode
@Nullable public java.lang.Number getNumericValue()
getNumericValue(0)
@Nullable public java.lang.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 java.lang.String getStringValue()
isString()
@Nullable public java.lang.String getStringValue(int index)
index
- which indexisString()
@Nullable public java.lang.Object getValue(int index)
index
- which index@Nullable public Array getValues()
public int hashCode()
hashCode
in class java.lang.Object
public boolean isArray()
public boolean isString()
public Attribute.Builder toBuilder()
public java.lang.String toString()
toString
in class java.lang.Object