## dods.dap
Class Attribute

    java.lang.Object
      dods.dap.Attribute

All Implemented Interfaces:
  Cloneable

public class Attribute
extends Object
implements Cloneable

An `Attribute` holds information about a single attribute in an `AttributeTable`. It has a type, and contains either a `Vector` of `String`s containing the attribute's values, or a reference to an `AttributeTable`, if the `Attribute` is a container. An `Attribute` may also be created as an alias pointing to another `Attribute` of any type, including container.

See Also:
  `AttributeTable`

Field Summary
`static int` `BYTE` Byte attribute type.
`static int` `CONTAINER` Container attribute type.
`static int` `FLOAT32` Float32 attribute type.
`static int` `FLOAT64` Float64 attribute type.
`static int` `INT16` Int16 attribute type.
`static int` `INT32` Int32 attribute type.
`static int` `STRING` String attribute type.
`static int` `UINT16` UInt16 attribute type.
`static int` `UINT32` UInt32 attribute type.
`static int` `UNKNOWN` Unknown attribute type.
`static int` `URL` URL attribute type.

Constructor Summary
`Attribute(AttributeTable container)` Deprecated. Use the ctor with the name.
`Attribute(int type, String name, String value)` Construct an `Attribute` with the given type and initial value.
`Attribute(int type, String name, String value, boolean check)` Construct an `Attribute` with the given type and initial value.
`Attribute(String aliasedTo, Attribute attr)` Construct an attribute aliased to the given name and contents.
`Attribute(String name, AttributeTable container)` Construct a container attribute.
`Attribute(String name, int type)` Construct an empty attribute with the given type.

Method Summary
`void` `appendValue(String value)` Append a value to this attribute.
`void` `appendValue(String value, boolean check)` Append a value to this attribute.
`Object` `clone()` Returns a clone of this `Attribute`.
`void` `deleteValueAt(int index)` Remove the `i`'th `String` from this attribute.
`String` `getAliasedTo()` Returns the name of the attribute aliased to.
`AttributeTable` `getContainer()` Returns the `AttributeTable` container.
`String` `getName()` Returns the attribute's name.
`int` `getType()` Returns the attribute type constant.
`String` `getTypeString()` Returns the attribute type as a `String`.
`String` `getValueAt(int index)` Returns the attribute value at `index`.
`Enumeration` `getValues()` Returns the values of this attribute as an `Enumeration` of `String`.
`boolean` `isAlias()` Returns true if the attribute is an alias.
`boolean` `isContainer()` Returns true if the attribute is a container.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### UNKNOWN

    public static final int UNKNOWN

  Unknown attribute type. This is currently unused.

  See Also:
    Constant Field Values

### CONTAINER

    public static final int CONTAINER

  Container attribute type. This Attribute holds an AttributeTable.

  See Also:
    Constant Field Values

### BYTE

    public static final int BYTE

  Byte attribute type. Holds an unsigned Byte.

  See Also:
    Constant Field Values

### INT16

    public static final int INT16

  Int16 attribute type. Holds a signed Short.

  See Also:
    Constant Field Values

### UINT16

    public static final int UINT16

  UInt16 attribute type. Holds an unsigned Short.

  See Also:
    Constant Field Values

### INT32

    public static final int INT32

  Int32 attribute type. Holds a signed Integer.

  See Also:
    Constant Field Values

### UINT32

    public static final int UINT32

  UInt32 attribute type. Holds an unsigned Integer.

  See Also:
    Constant Field Values

### FLOAT32

    public static final int FLOAT32

  Float32 attribute type. Holds a Float.

  See Also:
    Constant Field Values

### FLOAT64

    public static final int FLOAT64

  Float64 attribute type. Holds a Double.

  See Also:
    Constant Field Values

### STRING

    public static final int STRING

  String attribute type. Holds a String.

  See Also:
    Constant Field Values

### URL

    public static final int URL

  URL attribute type. Holds a String representing a URL.

  See Also:
    Constant Field Values

Constructor Detail

### Attribute

    public Attribute(AttributeTable container)

  Deprecated. Use the ctor with the name.

  Construct a container attribute.

Parameters:
  `container` - the `AttributeTable` container.

### Attribute

    public Attribute(int type,
                     String name,
                     String value,
                     boolean check)
              throws AttributeBadValueException

  Construct an `Attribute` with the given type and initial value.

Parameters:
  `type` - the type of attribute to create. Use one of the type constants defined by this class.
  `name` - the name of the attribute.
  `value` - the initial value of this attribute. Use the `appendValue` method to create a vector of values.
  `check` - if true, check the value and throw AttributeBadValueException if it's not valid; if false do not check its validity.
Throws:
  `AttributeBadValueException` - thrown if the value is not a legal member of type

### Attribute

    public Attribute(int type,
                     String name,
                     String value)
              throws AttributeBadValueException

  Construct an `Attribute` with the given type and initial value. Checks the value of the attribute and throws an exception if it's not valid.

Parameters:
  `type` - the type of attribute to create. Use one of the type constants defined by this class.
  `name` - the name of the attribute.
  `value` - the initial value of this attribute. Use the `appendValue` method to create a vector of values.
Throws:
  `AttributeBadValueException` - thrown if the value is not a legal member of type

### Attribute

    public Attribute(String name,
                     AttributeTable container)

  Construct a container attribute.

Parameters:
  `container` - the `AttributeTable` container.

### Attribute

    public Attribute(String aliasedTo,
                     Attribute attr)

  Construct an attribute aliased to the given name and contents.

Parameters:
  `aliasedTo` - the name of the target `Attribute`. This is necessary because `Attribute` doesn't know its own name (this is handled by the `DAS` or `AttributeTable` holding it.
  `attr` - the `Attribute` to point to.

### Attribute

    public Attribute(String name,
                     int type)
              throws IllegalArgumentException

  Construct an empty attribute with the given type.

Parameters:
  `type` - the type of attribute to create. Use one of the type constants defined by this class, other than `CONTAINER`.
Throws:
  `IllegalArgumentException` - thrown if `type` is `CONTAINER`. To construct an empty container attribute, first construct and empty AttributeTable and then use that to construct the Attribute.

Method Detail

### clone

    public Object clone()

  Returns a clone of this `Attribute`. A deep copy is performed on all attribute values.

  Returns:
    a clone of this `Attribute`.

### getTypeString

    public final String getTypeString()

  Returns the attribute type as a `String`.

  Returns:
    the attribute type `String`.

### getType

    public final int getType()

  Returns the attribute type constant.

  Returns:
    the attribute type constant.

### getName

    public final String getName()

  Returns the attribute's name.

  Returns:
    the attribute name.

### isContainer

    public final boolean isContainer()

  Returns true if the attribute is a container.

  Returns:
    true if the attribute is a container.

### isAlias

    public final boolean isAlias()

  Returns true if the attribute is an alias.

  Returns:
    true if the attribute is an alias.

### getAliasedTo

    public final String getAliasedTo()

  Returns the name of the attribute aliased to.

  Returns:
    the name of the attribute aliased to.

### getContainer

    public final AttributeTable getContainer()

  Returns the `AttributeTable` container.

  Returns:
    the `AttributeTable` container.

### getValues

    public final Enumeration getValues()

  Returns the values of this attribute as an `Enumeration` of `String`.

  Returns:
    an `Enumeration` of `String`.

### getValueAt

    public final String getValueAt(int index)

  Returns the attribute value at `index`.

  Parameters:
    `index` - the index of the attribute value to return.
  Returns:
    the attribute `String` at `index`.

### appendValue

    public final void appendValue(String value)
                           throws AttributeBadValueException

  Append a value to this attribute. Always checks the validity of the attribute's value.

  Parameters:
    `value` - the attribute `String` to add.
  Throws:
    `AttributeBadValueException` - thrown if the value is not a legal member of type

### appendValue

    public final void appendValue(String value,
                                  boolean check)
                           throws AttributeBadValueException

  Append a value to this attribute.

  Parameters:
    `value` - the attribute `String` to add.
    `check` - if true, check the validity of he attribute's value, if false don't.
  Throws:
    `AttributeBadValueException` - thrown if the value is not a legal member of type

### deleteValueAt

    public final void deleteValueAt(int index)

  Remove the `i`'th `String` from this attribute.

  Parameters:
    `index` - the index of the value to remove.