opendap.dap
Class Attribute

java.lang.Object
  extended by opendap.dap.Attribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Alias

public class Attribute
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

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: 23881 $
Author:
jehamby
See Also:
AttributeTable, Serialized Form

Field Summary
static int ALIAS
          Alias attribute type.
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 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 getClearName()
          Returns the attribute's name.
 AttributeTable getContainer()
          Returns the AttributeTable container.
 AttributeTable getContainerN()
          Returns the AttributeTable container.
 java.lang.String getName()
          Returns the attribute's name.
 int getNumVal()
          Returns the nummber of values held in this attribute.
 int getType()
          Returns the attribute type constant.
 java.lang.String getTypeString()
          Returns the attribute type as a String.
static int getTypeVal(java.lang.String s)
          Returns the attribute type as a String.
 java.lang.String getValueAt(int index)
          Returns the attribute value at index.
 java.lang.String getValueAtN(int index)
          Returns the attribute value at index.
 java.util.Enumeration getValues()
          Returns the values of this attribute as an Enumeration of String.
 java.util.Iterator getValuesIterator()
          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.
 void print(java.io.OutputStream os)
          Print the attribute on the given OutputStream with four spaces of indentation.
 void print(java.io.OutputStream os, java.lang.String pad)
          Print the attribute on the given OutputStream.
 void print(java.io.PrintWriter os)
          Print the attribute on the given PrintWriter with four spaces of indentation.
 void print(java.io.PrintWriter os, java.lang.String pad)
           
 void printXML(java.io.OutputStream os)
           
 void printXML(java.io.OutputStream os, java.lang.String pad)
           
 void printXML(java.io.PrintWriter pw)
           
 void printXML(java.io.PrintWriter pw, java.lang.String pad)
           
 void printXML(java.io.PrintWriter pw, java.lang.String pad, boolean constrained)
           
 void setClearName(java.lang.String n)
          Sets the attribute's name.
 void setName(java.lang.String n)
          Sets the attribute's name.
 
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

ALIAS

public static final int ALIAS
Alias attribute type. This is an attribute that works like a UNIX style soft link to another attribute.

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 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.

Overrides:
clone in class java.lang.Object
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.

getTypeVal

public static final int getTypeVal(java.lang.String s)
Returns the attribute type as a String.

Returns:
the attribute type String.

getType

public int getType()
Returns the attribute type constant.

Returns:
the attribute type constant.

getName

public java.lang.String getName()
Returns the attribute's name.

Returns:
the attribute name.

setName

public void setName(java.lang.String n)
Sets the attribute's name.


getClearName

public java.lang.String getClearName()
Returns the attribute's name.

Returns:
the attribute name.

setClearName

public void setClearName(java.lang.String n)
Sets the attribute's name.


isContainer

public boolean isContainer()
Returns true if the attribute is a container.

Returns:
true if the attribute is a container.

isAlias

public boolean isAlias()
Returns true if the attribute is an alias.

Returns:
true if the attribute is an alias.

getContainer

public AttributeTable getContainer()
                            throws NoSuchAttributeException
Returns the AttributeTable container.

Returns:
the AttributeTable container.
Throws:
NoSuchAttributeException - If the instance of Attribute on which it is called is not a container.

getContainerN

public AttributeTable getContainerN()
Returns the AttributeTable container.

Returns:
the AttributeTable container, or null if not a container.

getValues

public java.util.Enumeration getValues()
                                throws NoSuchAttributeException
Returns the values of this attribute as an Enumeration of String.

Returns:
an Enumeration of String.
Throws:
NoSuchAttributeException

getValuesIterator

public java.util.Iterator getValuesIterator()
Returns the values of this attribute as an Enumeration of String.

Returns:
an Iterator of String , or null if a container..

getNumVal

public int getNumVal()
              throws NoSuchAttributeException
Returns the nummber of values held in this attribute.

Returns:
the attribute String at index.
Throws:
NoSuchAttributeException

getValueAt

public java.lang.String getValueAt(int index)
                            throws NoSuchAttributeException
Returns the attribute value at index.

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

getValueAtN

public java.lang.String getValueAtN(int index)
Returns the attribute value at index.

Parameters:
index - the index of the attribute value to return.
Returns:
the attribute String at index, or null if a container..

appendValue

public void appendValue(java.lang.String value)
                 throws NoSuchAttributeException,
                        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
NoSuchAttributeException

appendValue

public void appendValue(java.lang.String value,
                        boolean check)
                 throws NoSuchAttributeException,
                        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
NoSuchAttributeException

deleteValueAt

public void deleteValueAt(int index)
                   throws AttributeBadValueException,
                          NoSuchAttributeException
Remove the i'th String from this attribute.

Parameters:
index - the index of the value to remove.
Throws:
AttributeBadValueException
NoSuchAttributeException

print

public void print(java.io.PrintWriter os,
                  java.lang.String pad)

print

public final void print(java.io.OutputStream os,
                        java.lang.String pad)
Print the attribute on the given OutputStream.

Parameters:
os - the OutputStream to use for output.
pad - the number of spaces to indent each line.

print

public final void print(java.io.PrintWriter os)
Print the attribute on the given PrintWriter with four spaces of indentation.

Parameters:
os - the PrintWriter to use for output.

print

public final void print(java.io.OutputStream os)
Print the attribute on the given OutputStream with four spaces of indentation.

Parameters:
os - the OutputStream to use for output.

printXML

public void printXML(java.io.OutputStream os)
Parameters:
os -

This class/method is associated with pre-release version of the DDX API. It is experimental and is subject to (significant) change.


printXML

public void printXML(java.io.OutputStream os,
                     java.lang.String pad)
Parameters:
os -
pad -

This class/method is associated with pre-release version of the DDX API. It is experimental and is subject to (significant) change.


printXML

public void printXML(java.io.PrintWriter pw)
Parameters:
pw -

This class/method is associated with pre-release version of the DDX API. It is experimental and is subject to (significant) change.


printXML

public void printXML(java.io.PrintWriter pw,
                     java.lang.String pad)
Parameters:
pw -
pad -

This class/method is associated with pre-release version of the DDX API. It is experimental and is subject to (significant) change.


printXML

public void printXML(java.io.PrintWriter pw,
                     java.lang.String pad,
                     boolean constrained)
Parameters:
pw -
pad -
constrained -

This class/method is associated with pre-release version of the DDX API. It is experimental and is subject to (significant) change.