Package opendap.dap
Class Alias
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.Attribute
-
- opendap.dap.Alias
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class Alias extends Attribute
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:- Then Alias defintion begins with the word
Alias
- The name field is consumed in it's entirety (unparsed) and used as the name of the Alias.
- There a number of rules specific to the representation and interpretation of the attribute field in the Alias declaration.
- The " (double quote) and the \ (backslash aka escape) characters MUST be escaped (using \ character) in the value of the attribute field.
- Each variable and attribute name in the attribute field must be enclosed in double quotes if their values contain the dot (.) character. For example: .sometimes."names.contain".dots would be three names sometimes, names.contain, and dots.
- Fully qualified attribute names always begin with the dot (.) character.
- All attribute names always MUST be fully qualified (begin with a dot). The leading dot represents a fully qualifed path attribute reference, starting at top level of DDX, or the DAS.
- If the attribute field contains only the dot (.) character, then it is referencing the collection of attributes associated with the highest level of the Dataset (global attributes) This collection always exists, but may be empty.
- The attribute field MUST NOT be empty.
- The attribute field MUST NOT point to another Alias.
- After the parser has completely parsed the DDX (or DAS) it will attempt to reslove each alias to a specific attribute. If an alias cannot be resolved to some attribute, and exception will be thrown by the parser.
DAS
andDDS
objects built using methods other thanDDS.parse()
,DDS.parseXML
,DDS.getDAS()
, orDAS.parse()
must callDDS.resolveAliases()
orDAS.resolveAliases()
prior to allowing client software access to these objects. Since anAlias
essentially represents a "pointer" to some (other)Attribute
, thatAttribute
object must be found. Once this has been done (by calling the correctresolveAliases()
method) theAliases
will act transparently as references to their targetAttributes
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class opendap.dap.DAPNode
DAPNode.CloneMap
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendValue(String value)
Append a value to this attribute.void
appendValue(String value, boolean check)
Append a value to this attribute.DAPNode
cloneDAG(DAPNode.CloneMap map)
Returns a clone of thisAlias
.void
deleteValueAt(int index)
Remove thei
'thString
from this attribute.String
getAliasedTo()
Returns the name of the attribute aliased to.String
getAliasedToAttributeField()
Returns the name of the attribute aliased to.String
getAliasedToAttributeFieldAsClearString()
Returns the name of the attribute aliased to.AttributeTable
getContainer()
Returns theAttributeTable
container.int
getType()
Returns the attribute type constant.String
getValueAt(int index)
Returns the attribute value atindex
.Enumeration
getValues()
Returns the values of this attribute as anEnumeration
ofString
.boolean
isAlias()
Returns true if the attribute is an alias.boolean
isContainer()
Returns true if the attribute is a container.void
print(PrintWriter os, String pad)
void
printXML(PrintWriter pw, String pad, boolean constrained)
void
setMyAttribute(Attribute a)
void
setMyVariable(BaseType v)
-
Methods inherited from class opendap.dap.Attribute
getContainerN, getNumVal, getTypeString, getTypeVal, getValueAtN, getValuesIterator, print, print, print, printXML, printXML, printXML, printXML
-
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Constructor Detail
-
Alias
public Alias(String aName, String attributeName)
Construct an Alias. This constructor is used by the DDSXMLParser to and the DAS parser build Aliases for the DDX.- Parameters:
aName
- aString
containing the name of the alias.attributeName
- theString
containing the normalized name of the variable and attribute that this Alias references.
-
-
Method Detail
-
setMyAttribute
public void setMyAttribute(Attribute a)
-
setMyVariable
public void setMyVariable(BaseType v)
-
getType
public int getType()
Returns the attribute type constant.
-
isContainer
public boolean isContainer()
Returns true if the attribute is a container.- Overrides:
isContainer
in classAttribute
- Returns:
- true if the attribute is a container.
-
isAlias
public boolean isAlias()
Returns true if the attribute is an alias.
-
getAliasedTo
public String getAliasedTo()
Returns the name of the attribute aliased to.- Returns:
- the name of the attribute aliased to.
-
getAliasedToAttributeFieldAsClearString
public String getAliasedToAttributeFieldAsClearString()
Returns the name of the attribute aliased to.- Returns:
- the name of the attribute aliased to.
-
getAliasedToAttributeField
public 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 theAttributeTable
container.- Overrides:
getContainer
in classAttribute
- Returns:
- the
AttributeTable
container. - Throws:
NoSuchAttributeException
- If the instance of Attribute on which it is called is not a container.
-
getValues
public Enumeration getValues() throws NoSuchAttributeException
Returns the values of this attribute as anEnumeration
ofString
.- Overrides:
getValues
in classAttribute
- Returns:
- an
Enumeration
ofString
. - Throws:
NoSuchAttributeException
-
getValueAt
public String getValueAt(int index) throws NoSuchAttributeException
Returns the attribute value atindex
.- Overrides:
getValueAt
in classAttribute
- Parameters:
index
- the index of the attribute value to return.- Returns:
- the attribute
String
atindex
. - Throws:
NoSuchAttributeException
-
appendValue
public void appendValue(String value) throws AttributeBadValueException
Append a value to this attribute. Always checks the validity of the attribute's value.- Overrides:
appendValue
in classAttribute
- Parameters:
value
- the attributeString
to add.- Throws:
AttributeBadValueException
- thrown if the value is not a legal member of type
-
appendValue
public void appendValue(String value, boolean check) throws AttributeBadValueException
Append a value to this attribute.- Overrides:
appendValue
in classAttribute
- Parameters:
value
- the attributeString
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 thei
'thString
from this attribute.- Overrides:
deleteValueAt
in classAttribute
- Parameters:
index
- the index of the value to remove.- Throws:
AttributeBadValueException
-
print
public void print(PrintWriter os, String pad)
-
printXML
public void printXML(PrintWriter pw, String pad, boolean constrained)
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisAlias
. See DAPNode.cloneDag()- Overrides:
cloneDAG
in classAttribute
- Parameters:
map
- track previously cloned nodes- Returns:
- a clone of this
Alias
. - Throws:
CloneNotSupportedException
-
-