|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectncsa.hdf.object.Attribute
public class Attribute
An attribute is a (name, value) pair of metadata attached to a primary data object such as dataset, group or named datatype.
Like a dataset, an attribute has a name, datatype and dataspace.
For more details on attibutes, see HDF5 User's Guide
The following code is an example of an attribute with 1D integer array of two elements.
// Example of creatinge a new attribute
// The name of the new attribute
String name = "Data range";
// Creating an unsigned 1-byte integer datatype
Datatype type = new Datatype(Datatype.CLASS_INTEGER, // class
1, // size in bytes
Datatype.ORDER_LE, // byte order
Datatype.SIGN_NONE); // signed or unsigned
// 1-D array of size two
long[] dims = {2};
// The value of the attribute
int[] value = {0, 255};
// Create a new attribute
Attribute dataRange = new Attribute(name, type, dims);
// Set the attribute value
dataRange.setValue(value);
// See FileFormat.writeAttribute() for how to attach an attribute to an object,
,
Datatype,
Serialized Form| Field Summary | |
|---|---|
static long |
serialVersionUID
|
| Constructor Summary | |
|---|---|
Attribute(java.lang.String attrName,
Datatype attrType,
long[] attrDims)
Create an attribute with specified name, data type and dimension sizes. |
|
Attribute(java.lang.String attrName,
Datatype attrType,
long[] attrDims,
java.lang.Object attrValue)
Create an attribute with specific name and value. |
|
| Method Summary | |
|---|---|
long[] |
getDataDims()
Returns the dimension sizes of the data value of the attribute. |
java.lang.String |
getName()
Returns the name of the attribute. |
int |
getRank()
Returns the rank (number of dimensions) of the attribute. |
Datatype |
getType()
Returns the datatype of the attribute. |
java.lang.Object |
getValue()
Returns the value of the attribute. |
boolean |
isUnsigned()
Checks if the data type of this attribute is an unsigned integer. |
void |
setValue(java.lang.Object theValue)
Sets the value of the attribute. |
java.lang.String |
toString(java.lang.String delimiter)
Returns a string representation of the data value of the attribute. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long serialVersionUID
HObject.serialVersionUID,
Constant Field Values| Constructor Detail |
|---|
public Attribute(java.lang.String attrName,
Datatype attrType,
long[] attrDims)
The following example creates a string attribute with the name "CLASS" and value "IMAGE".
long[] attrDims = {1};
String attrName = "CLASS";
String[] classValue = {"IMAGE"};
Datatype attrType = new H5Datatype(Datatype.CLASS_STRING, classValue[0].length()+1, -1, -1);
Attribute attr = new Attribute(attrName, attrType, attrDims);
attr.setValue(classValue);
attrName - the name of the attribute.attrType - the datatype of the attribute.attrDims - the dimension sizes of the attribute, null for scalar attributeDatatype
public Attribute(java.lang.String attrName,
Datatype attrType,
long[] attrDims,
java.lang.Object attrValue)
The following example creates a string attribute with the name "CLASS" and value "IMAGE".
long[] attrDims = {1};
String attrName = "CLASS";
String[] classValue = {"IMAGE"};
Datatype attrType = new H5Datatype(Datatype.CLASS_STRING, classValue[0].length()+1, -1, -1);
Attribute attr = new Attribute(attrName, attrType, attrDims, classValue);
attrName - the name of the attribute.attrType - the datatype of the attribute.attrDims - the dimension sizes of the attribute, null for scalar attributeattrValue - the value of the attribute, null if no valueDatatype| Method Detail |
|---|
public java.lang.Object getValue()
getValue in interface Metadatapublic void setValue(java.lang.Object theValue)
setValue in interface MetadatatheValue - The value of the attribute to setpublic java.lang.String getName()
public int getRank()
public long[] getDataDims()
public Datatype getType()
public boolean isUnsigned()
public java.lang.String toString(java.lang.String delimiter)
For compound datatype, it will be an 1D array of strings with field members separated by comma. For example, "{0, 10.5}, {255, 20.0}, {512, 30.0}" is a cmpound attribute of {int, float} of three data points.
delimiter - The delimiter to separate individual data point.
It can be comma, semicolon, tab or space.
For example, to String(",") will separate data by comma.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||