Module org.hdfgroup.object
Package hdf.object

# Interface Attribute

All Known Subinterfaces:
  `H5Attribute`

All Known Implementing Classes:
  `FitsAttribute`, `H4CompoundAttribute`, `H4ScalarAttribute`, `H5CompoundAttr`, `H5ScalarAttr`, `NC2Attribute`

public interface Attribute
An interface that provides general attribute operations for object data. For example, reference to a parent object.

See Also:
  - `HObject`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getAttributeData()`
  Retrieves the attribute data from the file.
  `Datatype`
  `getAttributeDatatype()`
  Returns the datatype of the attribute.
  `long[]`
  `getAttributeDims()`
  Returns the array that contains the dimension sizes of the data value of the attribute.
  `String`
  `getAttributeName()`
  Returns the name of the attribute.
  `int`
  `getAttributePlane()`
  Returns the selected size of the rows and columns of the attribute.
  `int`
  `getAttributeRank()`
  Returns the rank (number of dimensions) of the attribute.
  `int`
  `getAttributeSpaceType()`
  Returns the space type for the attribute.
  `HObject`
  `getParentObject()`
  Returns the HObject to which this Attribute is currently "attached".
  `Object`
  `getProperty(String key)`
  get a property for a given key.
  `Collection<String>`
  `getPropertyKeys()`
  get all property keys.
  `boolean`
  `isAttributeNULL()`
  `boolean`
  `isAttributeScalar()`
  `void`
  `setAttributeData(Object d)`
  Not for public use in the future.
  `void`
  `setParentObject(HObject pObj)`
  Sets the HObject to which this Attribute is "attached".
  `void`
  `setProperty(String key, Object value)`
  set a property for the attribute.
  `String`
  `toAttributeString(String delimiter)`
  Returns a string representation of the data value.
  `String`
  `toAttributeString(String delimiter, int maxItems)`
  Returns a string representation of the data value.
  `void`
  `writeAttribute()`
  Writes the memory buffer of this dataset to file.
  `void`
  `writeAttribute(Object buf)`
  Writes the given data buffer into this attribute in a file.

- ## Method Details

  - ### getParentObject

    HObject getParentObject()
    Returns the HObject to which this Attribute is currently "attached".
    Returns:
      the HObject to which this Attribute is currently "attached".

  - ### setParentObject

    void setParentObject(HObject pObj)
    Sets the HObject to which this Attribute is "attached".
    Parameters:
      `pObj` - the new HObject to which this Attributet is "attached".

  - ### setProperty

    void setProperty(String key, Object value)
    set a property for the attribute.
    Parameters:
      `key` - the attribute Map key
      `value` - the attribute Map value

  - ### getProperty

    Object getProperty(String key)
    get a property for a given key.
    Parameters:
      `key` - the attribute Map key
    Returns:
      the property

  - ### getPropertyKeys

    Collection<String> getPropertyKeys()
    get all property keys.
    Returns:
      the Collection of property keys

  - ### getAttributeName

    String getAttributeName()
    Returns the name of the attribute.
    Returns:
      The name of the attribute.

  - ### getAttributeData

    Object getAttributeData() throws Exception, OutOfMemoryError
    Retrieves the attribute data from the file.
    Returns:
      the attribute data.
    Throws:
      `Exception` - if the data can not be retrieved
      `OutOfMemoryError`

  - ### getAttributeDatatype

    Datatype getAttributeDatatype()
    Returns the datatype of the attribute.
    Returns:
      the datatype of the attribute.

  - ### getAttributeSpaceType

    int getAttributeSpaceType()
    Returns the space type for the attribute. It returns a negative number if it failed to retrieve the type information from the file.
    Returns:
      the space type for the attribute.

  - ### getAttributeRank

    int getAttributeRank()
    Returns the rank (number of dimensions) of the attribute. It returns a negative number if it failed to retrieve the dimension information from the file.
    Returns:
      the number of dimensions of the attribute.

  - ### getAttributeDims

    long[] getAttributeDims()
    Returns the array that contains the dimension sizes of the data value of the attribute. It returns null if it failed to retrieve the dimension information from the file.
    Returns:
      the dimension sizes of the attribute.

  - ### getAttributePlane

    int getAttributePlane()
    Returns the selected size of the rows and columns of the attribute. It returns a negative number if it failed to retrieve the size information from the file.
    Returns:
      the selected size of the rows and colums of the attribute.

  - ### isAttributeNULL

    boolean isAttributeNULL()
    Returns:
      true if the dataspace is a NULL; otherwise, returns false.

  - ### isAttributeScalar

    boolean isAttributeScalar()
    Returns:
      true if the data is a single scalar point; otherwise, returns false.

  - ### setAttributeData

    void setAttributeData(Object d)
    Not for public use in the future. setData() is not safe to use because it changes memory buffer of the dataset object. Dataset operations such as write/read will fail if the buffer type or size is changed.
    Parameters:
      `d` - the object data -must be an array of Objects

  - ### writeAttribute

    void writeAttribute() throws Exception
    Writes the memory buffer of this dataset to file.
    Throws:
      `Exception` - if buffer can not be written

  - ### writeAttribute

    void writeAttribute(Object buf) throws Exception
    Writes the given data buffer into this attribute in a file. The data buffer is a vector that contains the data values of compound fields. The data is written into file as one data blob.
    Parameters:
      `buf` - The vector that contains the data values of compound fields.
    Throws:
      `Exception` - If there is an error at the library level.

  - ### toAttributeString

    String toAttributeString(String delimiter)
    Returns a string representation of the data value. For example, "0, 255". For a compound datatype, it will be a 1D array of strings with field members separated by the delimiter. For example, "{0, 10.5}, {255, 20.0}, {512, 30.0}" is a compound attribute of {int, float} of three data points.
    Parameters:
      `delimiter` - The delimiter used to separate individual data points. It can be a comma, semicolon, tab or space. For example, toString(",") will separate data by commas.
    Returns:
      the string representation of the data values.

  - ### toAttributeString

    String toAttributeString(String delimiter, int maxItems)
    Returns a string representation of the data value. For example, "0, 255". For a compound datatype, it will be a 1D array of strings with field members separated by the delimiter. For example, "{0, 10.5}, {255, 20.0}, {512, 30.0}" is a compound attribute of {int, float} of three data points.
    Parameters:
      `delimiter` - The delimiter used to separate individual data points. It can be a comma, semicolon, tab or space. For example, toString(",") will separate data by commas.
      `maxItems` - The maximum number of Array values to return
    Returns:
      the string representation of the data values.