opendap.dap
Class AttributeTable

java.lang.Object
  extended by opendap.dap.DAPNode
      extended by opendap.dap.AttributeTable
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
DAS

public class AttributeTable
extends DAPNode

An AttributeTable stores a set of names and, for each name, an Attribute object. For more information on the types of data which can be stored in an attribute, including aliases and other AttributeTable objects, see the documentation for Attribute.

The attribute tables have a standard printed representation. There is a print method for writing this form and a parse method for reading the printed form.

An AttributeTable's print representation might look like:

   String long_name "Weekly Means of Sea Surface Temperature";
 
or
   actual_range {
       Float64 min -1.8;
       Float64 max 35.09;
   }
 
or
   String Investigators "Cornillon", "Fleirl", "Watts";
 
or
   Alias New_Attribute Old_Attribute;
 
Here, long_name and Investigators are simple attributes, actual_range is a container attribute, and New_Attribute is an alias pointing to Old_Attribute.

Version:
$Revision: 15901 $
Author:
jehamby
See Also:
DAS, Modified 1/9/2011 Dennis Heimbigner - Make subclass of BaseType for uniformity, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class opendap.dap.DAPNode
DAPNode.CloneMap
 
Field Summary
 
Fields inherited from class opendap.dap.DAPNode
_name, _nameEncoded
 
Constructor Summary
AttributeTable()
          Deprecated. Use constructor that takes the name of the table.
AttributeTable(String name)
          Create a new empty AttributeTable.
 
Method Summary
 void addAlias(String alias, String attributeName)
          Add an alias to the current table.
 void addContainer(String name, AttributeTable at)
          Create and append an attribute container to the table.
 void appendAttribute(String name, int type, String value)
          Adds an attribute to the table.
 void appendAttribute(String name, int type, String value, boolean check)
          Adds an attribute to the table.
 AttributeTable appendContainer(String name)
          Create and append an attribute container to the table.
 DAPNode cloneDAG(DAPNode.CloneMap map)
          Returns a clone of this AttributeTable.
 void delAttribute(String name)
          Delete the attribute named name.
 void delAttribute(String name, int i)
          Delete the attribute named name.
 Attribute getAttribute(String name)
          Returns the Attribute which matches name.
 Enumeration getNames()
          Returns an Enumeration of the attribute names in this AttributeTable.
 boolean hasAttribute(String name)
          Returns the Attribute which matches name.
 void print(OutputStream os)
          Print the attribute table on the given OutputStream with four spaces of indentation.
 void print(OutputStream os, String pad)
          Print the attribute table on the given OutputStream.
 void print(PrintWriter os)
          Print the attribute table on the given PrintWriter with four spaces of indentation.
 void print(PrintWriter os, String pad)
          Print the attribute table on the given PrintWriter.
 void printXML(OutputStream os)
           
 void printXML(OutputStream os, String pad)
           
 void printXML(PrintWriter pw)
           
 void printXML(PrintWriter pw, String pad)
           
 void printXML(PrintWriter pw, String pad, boolean constrained)
           
 
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeTable

public AttributeTable()
Deprecated. Use constructor that takes the name of the table.

Create a new empty AttributeTable.


AttributeTable

public AttributeTable(String name)
Create a new empty AttributeTable.

Method Detail

getNames

public final Enumeration getNames()
Returns an Enumeration of the attribute names in this AttributeTable. Use the getAttribute method to get the Attribute for a given name.

Returns:
an Enumeration of String.
See Also:
getAttribute(String)

getAttribute

public final Attribute getAttribute(String name)
Returns the Attribute which matches name.

Parameters:
name - the name of the Attribute to return.
Returns:
the Attribute with the specified name, or null if there is no matching Attribute.
See Also:
Attribute

hasAttribute

public final boolean hasAttribute(String name)
Returns the Attribute which matches name.

Parameters:
name - the name of the Attribute to return.
Returns:
True if an Attribute with named 'name' exists, False otherwise.
See Also:
Attribute

appendAttribute

public final void appendAttribute(String name,
                                  int type,
                                  String value,
                                  boolean check)
                           throws DASException
Adds an attribute to the table. If the given name already refers to an attribute, and the attribute has a vector value, the given value is appended to the attribute vector. Calling this function repeatedly is the way to create an attribute vector.

The function throws an exception if the attribute is a container, or if the type of the input value does not match the existing attribute's type and the check parameter is true. Use the appendContainer method to add container attributes.

Parameters:
name - The name of the attribute to add or modify.
type - The type code of the attribute to add or modify.
value - The value to add to the attribute table.
check - Check the validity of the attribute's value?
Throws:
AttributeExistsException - thrown if an Attribute with the same name, but a different type was previously defined.
AttributeBadValueException - thrown if the value is not a legal member of type
DASException
See Also:
appendContainer(String)

appendAttribute

public final void appendAttribute(String name,
                                  int type,
                                  String value)
                           throws DASException
Adds an attribute to the table. If the given name already refers to an attribute, and the attribute has a vector value, the given value is appended to the attribute vector. Calling this function repeatedly is the way to create an attribute vector.

The function throws an exception if the attribute is a container, or if the type of the input value does not match the existing attribute's type. Use the appendContainer method to add container attributes.

Parameters:
name - The name of the attribute to add or modify.
type - The type code of the attribute to add or modify.
value - The value to add to the attribute table.
Throws:
AttributeExistsException - thrown if an Attribute with the same name, but a different type was previously defined.
AttributeBadValueException - thrown if the value is not a legal member of type
DASException
See Also:
appendContainer(String)

appendContainer

public final AttributeTable appendContainer(String name)
Create and append an attribute container to the table. A container is another AttributeTable object.

Parameters:
name - the name of the container to add.
Returns:
A pointer to the new AttributeTable object, or null if a container by that name already exists.

addContainer

public final void addContainer(String name,
                               AttributeTable at)
                        throws AttributeExistsException
Create and append an attribute container to the table. A container is another AttributeTable object.

Parameters:
name - the name of the container to add. if a container by that name already exists.
Throws:
AttributeExistsException

addAlias

public final void addAlias(String alias,
                           String attributeName)
                    throws NoSuchAttributeException,
                           AttributeExistsException
Add an alias to the current table. This method is used by the DAS parser to build Aliases for the DAS. And the DDSXMLParser to add them to the DDX

The new (9/26/02) DDS requires the use of addAlias(String, String, String) and is the preffered way of representing the DAS information.

Parameters:
alias - The alias to insert into the attribute table.
attributeName - The normalized name of the attribute to which the alias will refer.
Throws:
NoSuchAttributeException - thrown if the existing attribute could not be found.
AttributeExistsException - thrown if the new alias has the same name as an existing attribute.

delAttribute

public final void delAttribute(String name)
Delete the attribute named name.

Parameters:
name - The name of the attribute to delete. This can be an attribute of any type, including containers.

delAttribute

public final void delAttribute(String name,
                               int i)
                        throws DASException
Delete the attribute named name. If the attribute has a vector value, delete the i'th element of the vector.

Parameters:
name - The name of the attribute to delete. This can be an attribute of any type, including containers.
i - If the named attribute is a vector, and i is non-negative, the i'th entry in the vector is deleted. If i equals -1, the entire attribute is deleted.
Throws:
DASException
See Also:
delAttribute(String)

print

public void print(PrintWriter os,
                  String pad)
Print the attribute table on the given PrintWriter.

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

print

public final void print(OutputStream os,
                        String pad)
Print the attribute table 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(PrintWriter os)
Print the attribute table on the given PrintWriter with four spaces of indentation.

Parameters:
os - the PrintWriter to use for output.

print

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

Parameters:
os - the OutputStream to use for output.

printXML

public void printXML(OutputStream os)
Parameters:
os -

printXML

public void printXML(OutputStream os,
                     String pad)
Parameters:
os -
pad -

printXML

public void printXML(PrintWriter pw)
Parameters:
pw -

printXML

public void printXML(PrintWriter pw,
                     String pad)
Parameters:
pw -
pad -

printXML

public void printXML(PrintWriter pw,
                     String pad,
                     boolean constrained)
Parameters:
pw -
pad -
constrained -

cloneDAG

public DAPNode cloneDAG(DAPNode.CloneMap map)
                 throws CloneNotSupportedException
Returns a clone of this AttributeTable. See DAPNode.cloneDag()

Overrides:
cloneDAG in class DAPNode
Parameters:
map - track previously cloned nodes
Returns:
a clone of this Attribute.
Throws:
CloneNotSupportedException


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.