dods.dap
Class Attribute

java.lang.Object
  extended bydods.dap.Attribute
All Implemented Interfaces:
java.lang.Cloneable

public class Attribute
extends java.lang.Object
implements java.lang.Cloneable

An Attribute holds information about a single attribute in an AttributeTable. It has a type, and contains either a Vector of Strings 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.

Version:
$Revision: 1.5 $
Author:
jehamby
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, java.lang.String name, java.lang.String value)
          Construct an Attribute with the given type and initial value.
Attribute(int type, java.lang.String name, java.lang.String value, boolean check)
          Construct an Attribute with the given type and initial value.
Attribute(java.lang.String aliasedTo, Attribute attr)
          Construct an attribute aliased to the given name and contents.
Attribute(java.lang.String name, AttributeTable container)
          Construct a container attribute.
Attribute(java.lang.String name, int type)
          Construct an empty attribute with the given type.
 
Method Summary
 void appendValue(java.lang.String value)
          Append a value to this attribute.
 void appendValue(java.lang.String value, boolean check)
          Append a value to this attribute.
 java.lang.Object clone()
          Returns a clone of this Attribute.
 void deleteValueAt(int index)
          Remove the i'th String from this attribute.
 java.lang.String getAliasedTo()
          Returns the name of the attribute aliased to.
 AttributeTable getContainer()
          Returns the AttributeTable container.
 java.lang.String getName()
          Returns the attribute's name.
 int getType()
          Returns the attribute type constant.
 java.lang.String getTypeString()
          Returns the attribute type as a String.
 java.lang.String getValueAt(int index)
          Returns the attribute value at index.
 java.util.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,
                 java.lang.String name,
                 java.lang.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,
                 java.lang.String name,
                 java.lang.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(java.lang.String name,
                 AttributeTable container)
Construct a container attribute.

Parameters:
container - the AttributeTable container.

Attribute

public Attribute(java.lang.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(java.lang.String name,
                 int type)
          throws java.lang.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:
java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.util.Enumeration getValues()
Returns the values of this attribute as an Enumeration of String.

Returns:
an Enumeration of String.

getValueAt

public final java.lang.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(java.lang.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(java.lang.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.