opendap.dap
Class Alias

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

public class Alias
extends Attribute
implements java.lang.Cloneable

The Alias type is a special attribute. It is simply a reference (like a "soft link" in a UNIX file system) to another attribute.

The rules for the definiton and interpretation an Alias are as follows:

In the persistent representation of the DDS (XML, or old DAS & DDS syntax) Alias definitions will contain 2 fields: name, attribute. Example from a DDS:

 Alias CalDate  .profiler.cast.conductivity.calibration.date
 
Or a DDX:
 <Alias name="CalDate" attribute=".profiler.cast.conductivity.calibration.date"/>
 

The rules for the interpretation of these fields are as follows:

Warning: DAS and DDS objects built using methods other than DDS.parse(), DDS.parseXML, DDS.getDAS(), or DAS.parse() must call DDS.resolveAliases() or DAS.resolveAliases() prior to allowing client software access to these objects. Since an Alias essentially represents a "pointer" to some (other) Attribute, that Attribute object must be found. Once this has been done (by calling the correct resolveAliases() method) the Aliases will act transparently as references to their target Attributes.

Version:
$Revision: 23881 $
Author:
ndp
See Also:
AttributeTable, DDS, DDS.parse(java.io.InputStream), DDS.parseXML(java.io.InputStream, boolean), DDS.getDAS(), DAS, DAS.resolveAliases(), Serialized Form

Field Summary
 
Fields inherited from class opendap.dap.Attribute
ALIAS, BYTE, CONTAINER, FLOAT32, FLOAT64, INT16, INT32, STRING, UINT16, UINT32, UNKNOWN, URL
 
Constructor Summary
Alias(java.lang.String aName, java.lang.String attributeName)
          Construct an Alias.
 
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.
 java.lang.String getAliasedToAttributeField()
          Returns the name of the attribute aliased to.
 java.lang.String getAliasedToAttributeFieldAsClearString()
          Returns the name of the attribute aliased to.
 AttributeTable getContainer()
          Returns the AttributeTable container.
 int getType()
          Returns the attribute type constant.
 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.
 void print(java.io.PrintWriter os, java.lang.String pad)
           
 void printXML(java.io.PrintWriter pw, java.lang.String pad, boolean constrained)
           
 void setMyAttribute(Attribute a)
           
 void setMyVariable(BaseType v)
           
 
Methods inherited from class opendap.dap.Attribute
getClearName, getContainerN, getName, getNumVal, getTypeString, getTypeVal, getValueAtN, getValuesIterator, print, print, print, printXML, printXML, printXML, printXML, setClearName, setName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Alias

public Alias(java.lang.String aName,
             java.lang.String attributeName)
Construct an Alias. This constructor is used by the DDSXMLParser to and the DAS parser build Aliases for the DDX.

Parameters:
aName - a String containing the name of the alias.
attributeName - the String containing the normalized name of the variable and attribute that this Alias references.
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 Attribute
Returns:
a clone of this Attribute.

setMyAttribute

public void setMyAttribute(Attribute a)

setMyVariable

public void setMyVariable(BaseType v)

getType

public int getType()
Returns the attribute type constant.

Overrides:
getType in class Attribute
Returns:
the attribute type constant.

isContainer

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

Overrides:
isContainer in class Attribute
Returns:
true if the attribute is a container.

isAlias

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

Overrides:
isAlias in class Attribute
Returns:
true if the attribute is an alias.

getAliasedTo

public java.lang.String getAliasedTo()
Returns the name of the attribute aliased to.

Returns:
the name of the attribute aliased to.

getAliasedToAttributeFieldAsClearString

public java.lang.String getAliasedToAttributeFieldAsClearString()
Returns the name of the attribute aliased to.

Returns:
the name of the attribute aliased to.

getAliasedToAttributeField

public java.lang.String getAliasedToAttributeField()
Returns the name of the attribute aliased to.

Returns:
the name of the attribute aliased to.

getContainer

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

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

getValues

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

Overrides:
getValues in class Attribute
Returns:
an Enumeration of String.
Throws:
NoSuchAttributeException

getValueAt

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

Overrides:
getValueAt in class Attribute
Parameters:
index - the index of the attribute value to return.
Returns:
the attribute String at index.
Throws:
NoSuchAttributeException

appendValue

public void appendValue(java.lang.String value)
                 throws AttributeBadValueException
Append a value to this attribute. Always checks the validity of the attribute's value.

Overrides:
appendValue in class Attribute
Parameters:
value - the attribute String to add.
Throws:
AttributeBadValueException - thrown if the value is not a legal member of type

appendValue

public void appendValue(java.lang.String value,
                        boolean check)
                 throws AttributeBadValueException
Append a value to this attribute.

Overrides:
appendValue in class 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 void deleteValueAt(int index)
                   throws AttributeBadValueException
Remove the i'th String from this attribute.

Overrides:
deleteValueAt in class Attribute
Parameters:
index - the index of the value to remove.
Throws:
AttributeBadValueException

print

public void print(java.io.PrintWriter os,
                  java.lang.String pad)
Overrides:
print in class Attribute

printXML

public void printXML(java.io.PrintWriter pw,
                     java.lang.String pad,
                     boolean constrained)
Overrides:
printXML in class Attribute