opendap/src/main/java/opendap/dap/DDS.java
private void resolveAlias(Alias alias) throws MalformedAliasException, UnresolvedAliasException
    {

        //Get the crucial stuff out of the Alias
        String name = alias.getEncodedName();
        String attribute = alias.getAliasedToAttributeFieldAsClearString();

        if (Debug.isSet("DDS.resolveAliases")) {
		DAPNode.log.debug("\n\nFound: Alias " + name +
                    "  " + attribute);
	    }

        // The Attribute field MAY NOT be empty.
        if (attribute.equals("")) {
            throw new MalformedAliasException("The attribute 'attribute' in the Alias " +
                    "element (name: '" + name + "') must have a value other than an empty string.");
        }


        if (Debug.isSet("DDS.resolveAliases")) {
		DAPNode.log.debug("Attribute: `" + attribute + "'");
	    }

        // Tokenize the attribute field.
        Vector aNames = tokenizeAliasField(attribute);

        if (Debug.isSet("DDS.resolveAliases")) {
            DAPNode.log.debug("Attribute name tokenized to " + aNames.size() + " elements");
            Enumeration e = aNames.elements();
            while (e.hasMoreElements()) {
                String aname = (String) e.nextElement();
                DAPNode.log.debug("name: " + aname);
            }
        }

        // The variable reference is the first part of the attribute field.
        // Let's go find it...


        BaseType targetBT = null;

        // Absolute paths for attributes names must start with the dot character.
        boolean isAbsolutePath = aNames.get(0).equals(".");

        if (!isAbsolutePath) { //Is it not an absolute path?
            throw new MalformedAliasException("In the Alias '" + name + "'" +
                    " the value of the attribute 'attribute' does not begin with the character dot (.). " +
                    "The value of the 'attribute' field must always be an absolute path name from the " +
                    "top level of the variable reference, and thus must always begin with the dot (.) character.");
        }

        if (aNames.size() == 1) { // Is it only a dot?
            throw new MalformedAliasException("In the Alias '" + name + "'" +
                    " the value of the attribute 'attribute' contains only the character dot (.). " +
                    "The value of the 'attribute' field must always reference an Attribute using an absolute path name from the " +
                    "top level of the DAS, and must reference an attribute within the DAS. A simple dot is not allowed.");

        }

        aNames.remove(0); // Remove the first token, which by now we know is a single dot.


        targetBT = getDeepestMatchingVariable(this, aNames);

        if (targetBT == null) { // No matching BaseType?

            // Then assume the attribute field references a
            // top (Dataset) level Attribute.
            targetBT = this;
        }

        //LogStream.out.println("Alias references variable:	."+targetBT.getLongName());

        // Now that we have found a target BaseType variable that matches the reference in
        // the variable field of the Alias (b.t.w. that's a good thing) let's go
        // see if we can find an Attribute within that targetBT that matches the attribute field
        // in the Alias decleration.

        Attribute targetAT = null;

        if (aNames.size() == 0) {
            // If there are no remaining tokens in the attribute field then
            // we are referencing the attribute container of the targetBT.
            targetAT = targetBT.getAttribute();

        } else {
            // Go try to find the Attribute in the targetBT.
            targetAT = getAttribute(targetBT.getAttributeTable(), aNames);
        }

        alias.setMyVariable(targetBT);
        alias.setMyAttribute(targetAT);


    }
private void resolveAlias(Alias alias) throws MalformedAliasException, UnresolvedAliasException
    {

        //Get the crucial stuff out of the Alias
        String name = alias.getEncodedName();
        String attribute = alias.getAliasedToAttributeFieldAsClearString();

        if (Debug.isSet("DDS.resolveAliases")) {
		DAPNode.log.debug("\n\nFound: Alias " + name +
                    "  " + attribute);
	    }

        // The Attribute field MAY NOT be empty.
        if (attribute.equals("")) {
            throw new MalformedAliasException("The attribute 'attribute' in the Alias " +
                    "element (name: '" + name + "') must have a value other than an empty string.");
        }


        if (Debug.isSet("DDS.resolveAliases")) {
		DAPNode.log.debug("Attribute: `" + attribute + "'");
	    }

        // Tokenize the attribute field.
        Vector aNames = tokenizeAliasField(attribute);

        if (Debug.isSet("DDS.resolveAliases")) {
            DAPNode.log.debug("Attribute name tokenized to " + aNames.size() + " elements");
            Enumeration e = aNames.elements();
            while (e.hasMoreElements()) {
                String aname = (String) e.nextElement();
                DAPNode.log.debug("name: " + aname);
            }
        }

        // The variable reference is the first part of the attribute field.
        // Let's go find it...


        BaseType targetBT = null;

        // Absolute paths for attributes names must start with the dot character.
        boolean isAbsolutePath = aNames.get(0).equals(".");

        if (!isAbsolutePath) { //Is it not an absolute path?
            throw new MalformedAliasException("In the Alias '" + name + "'" +
                    " the value of the attribute 'attribute' does not begin with the character dot (.). " +
                    "The value of the 'attribute' field must always be an absolute path name from the " +
                    "top level of the variable reference, and thus must always begin with the dot (.) character.");
        }

        if (aNames.size() == 1) { // Is it only a dot?
            throw new MalformedAliasException("In the Alias '" + name + "'" +
                    " the value of the attribute 'attribute' contains only the character dot (.). " +
                    "The value of the 'attribute' field must always reference an Attribute using an absolute path name from the " +
                    "top level of the DAS, and must reference an attribute within the DAS. A simple dot is not allowed.");

        }

        aNames.remove(0); // Remove the first token, which by now we know is a single dot.


        targetBT = getDeepestMatchingVariable(this, aNames);

        if (targetBT == null) { // No matching BaseType?

            // Then assume the attribute field references a
            // top (Dataset) level Attribute.
            targetBT = this;
        }

        //LogStream.out.println("Alias references variable:	."+targetBT.getLongName());

        // Now that we have found a target BaseType variable that matches the reference in
        // the variable field of the Alias (b.t.w. that's a good thing) let's go
        // see if we can find an Attribute within that targetBT that matches the attribute field
        // in the Alias decleration.

        Attribute targetAT = null;

        if (aNames.size() == 0) {
            // If there are no remaining tokens in the attribute field then
            // we are referencing the attribute container of the targetBT.
            targetAT = targetBT.getAttribute();

        } else {
            // Go try to find the Attribute in the targetBT.
            targetAT = getAttribute(targetBT.getAttributeTable(), aNames);
        }

        alias.setMyVariable(targetBT);
        alias.setMyAttribute(targetAT);


    }
This method attempts to resolve the past Alias to a specific Attribute in the DDS.
It does this by:
<ul>
<li>1) Tokenizing the Alias's attribute field (see <code>Alias</code>) </li>
<li>2) Evaluating the tokenized field to locate the longest
possible variable name represented as a consecutive set of tokens </li>
<li>2) Evaluating the the remaining tokenized field to locate the Attribute
that this Alias is attempting to reference</li>
<li>4) Setting the Aliases internal references for it's Variable and it's Attribute.
</ul>
<p/>
If an Attribute matching the definition of the Alias cannot be located,
an Exception is thrown

@param alias The <code>Alias</code> which needs to be resolved