opendap/src/main/java/opendap/dap/DDS.java
public DAS getDAS() throws DASException
    {

        DAS myDAS = new DAS();

        try {

            // Since the DDS can contain Attributes, in addtion to Attribute containers (AttributeTables)
            // at the top (dataset) level and the DAS cannot, it is required that these Attributes be
            // bundled into a container at the top level of the DAS.
            // In the code that follows this container is called "looseEnds"

            // Make the container.
            AttributeTable looseEnds = new AttributeTable(getLooseEndsTableName());

            // Carfully populate it from the one at our top-level. Since we are using the
            // API and also copying containers here in order to build a new version,
            // we must use a clone of this (the DDS's) AttributeTable.
            AttributeTable atTbl = (AttributeTable) getAttributeTable().clone();

            int countLooseAttributes = 0;
            // Work on each Attribute in the container.
            Enumeration e = atTbl.getNames();
            while (e.hasMoreElements()) {
                String aName = (String) e.nextElement();
                Attribute a = atTbl.getAttribute(aName);
                String clearname = a.getClearName();

                if (a.isAlias()) { // copy an alias.

                    String attribute = ((Alias) a).getAliasedToAttributeFieldAsClearString();

                    looseEnds.addAlias(clearname, convertDDSAliasFieldsToDASAliasFields(attribute));
                    countLooseAttributes++;

                } else if (a.isContainer()) {
                    // A reference copy. This is why we are working with a clone.
                    myDAS.addAttributeTable(clearname, a.getContainer());
                } else { // copy an Attribute and it's values...

                    int type = a.getType();

                    Enumeration vals = a.getValues();
                    while (vals.hasMoreElements()) {
                        String value = (String) vals.nextElement();
                        looseEnds.appendAttribute(clearname, type, value, true);
                    }
                    countLooseAttributes++;

                }
            }

            if (_Debug) {
		DAPNode.log.debug("Found " + countLooseAttributes + " top level Attributes.");
	    }

            //if (_Debug) myDAS.print(LogStream.dbg);

            // Only add this AttributeTable if actually contains Attributes!
            if (countLooseAttributes > 0) {
                if (_Debug) DAPNode.log.debug("Creating looseEnds table: " + looseEnds.getEncodedName());
                myDAS.addAttributeTable(looseEnds.getEncodedName(), looseEnds);
            }

// Walk through the variables at the top level.
            e = getVariables();
            while (e.hasMoreElements()) {
                BaseType bt = (BaseType) e.nextElement();
                // Build the correct AttributeTable for it at the Toplevel of the DAS
                buildDASAttributeTable(bt, myDAS);
            }

            //if (_Debug) myDAS.print(LogStream.dbg);

            // Make sure that the Aliases resolve correctly. Since we are moving from a
            // DDS/DDX space to a DFAS space the Aliases may not be resolvable. In that
            // case an exception will get thrown...
            myDAS.resolveAliases();

        } catch (Exception e) {
            e.printStackTrace();
            throw new DASException(opendap.dap.DAP2Exception.UNKNOWN_ERROR,
                    "Could not create a DAS from this DDX object.\n" +
                            "Because of the structural differences between the DDX and the DAS it is " +
                            "possible for the DDX to contain sets of Attributes that cannot be represented " +
                            "in a DAS object.\n" +
                            "The specific problem was an execption of type " + e.getClass().getName() + " with an " +
                            "error message of: \n" +
                            e.getMessage());
        }

        return (myDAS);

    }
public DAS getDAS() throws DASException
    {

        DAS myDAS = new DAS();

        try {

            // Since the DDS can contain Attributes, in addtion to Attribute containers (AttributeTables)
            // at the top (dataset) level and the DAS cannot, it is required that these Attributes be
            // bundled into a container at the top level of the DAS.
            // In the code that follows this container is called "looseEnds"

            // Make the container.
            AttributeTable looseEnds = new AttributeTable(getLooseEndsTableName());

            // Carfully populate it from the one at our top-level. Since we are using the
            // API and also copying containers here in order to build a new version,
            // we must use a clone of this (the DDS's) AttributeTable.
            AttributeTable atTbl = (AttributeTable) getAttributeTable().clone();

            int countLooseAttributes = 0;
            // Work on each Attribute in the container.
            Enumeration e = atTbl.getNames();
            while (e.hasMoreElements()) {
                String aName = (String) e.nextElement();
                Attribute a = atTbl.getAttribute(aName);
                String clearname = a.getClearName();

                if (a.isAlias()) { // copy an alias.

                    String attribute = ((Alias) a).getAliasedToAttributeFieldAsClearString();

                    looseEnds.addAlias(clearname, convertDDSAliasFieldsToDASAliasFields(attribute));
                    countLooseAttributes++;

                } else if (a.isContainer()) {
                    // A reference copy. This is why we are working with a clone.
                    myDAS.addAttributeTable(clearname, a.getContainer());
                } else { // copy an Attribute and it's values...

                    int type = a.getType();

                    Enumeration vals = a.getValues();
                    while (vals.hasMoreElements()) {
                        String value = (String) vals.nextElement();
                        looseEnds.appendAttribute(clearname, type, value, true);
                    }
                    countLooseAttributes++;

                }
            }

            if (_Debug) {
		DAPNode.log.debug("Found " + countLooseAttributes + " top level Attributes.");
	    }

            //if (_Debug) myDAS.print(LogStream.dbg);

            // Only add this AttributeTable if actually contains Attributes!
            if (countLooseAttributes > 0) {
                if (_Debug) DAPNode.log.debug("Creating looseEnds table: " + looseEnds.getEncodedName());
                myDAS.addAttributeTable(looseEnds.getEncodedName(), looseEnds);
            }

// Walk through the variables at the top level.
            e = getVariables();
            while (e.hasMoreElements()) {
                BaseType bt = (BaseType) e.nextElement();
                // Build the correct AttributeTable for it at the Toplevel of the DAS
                buildDASAttributeTable(bt, myDAS);
            }

            //if (_Debug) myDAS.print(LogStream.dbg);

            // Make sure that the Aliases resolve correctly. Since we are moving from a
            // DDS/DDX space to a DFAS space the Aliases may not be resolvable. In that
            // case an exception will get thrown...
            myDAS.resolveAliases();

        } catch (Exception e) {
            e.printStackTrace();
            throw new DASException(opendap.dap.DAP2Exception.UNKNOWN_ERROR,
                    "Could not create a DAS from this DDX object.\n" +
                            "Because of the structural differences between the DDX and the DAS it is " +
                            "possible for the DDX to contain sets of Attributes that cannot be represented " +
                            "in a DAS object.\n" +
                            "The specific problem was an execption of type " + e.getClass().getName() + " with an " +
                            "error message of: \n" +
                            e.getMessage());
        }

        return (myDAS);

    }
public DAS getDAS ( ) throws DASException { DAS myDAS = new DAS ( ) ; try { // Since the DDS can contain Attributes, in addtion to Attribute containers (AttributeTables) // at the top (dataset) level and the DAS cannot, it is required that these Attributes be // bundled into a container at the top level of the DAS. // In the code that follows this container is called "looseEnds" // Make the container. AttributeTable looseEnds = new AttributeTable ( getLooseEndsTableName ( ) ) ; // Carfully populate it from the one at our top-level. Since we are using the // API and also copying containers here in order to build a new version, // we must use a clone of this (the DDS's) AttributeTable. AttributeTable atTbl = ( AttributeTable ) getAttributeTable ( ) . clone ( ) ; int countLooseAttributes = 0 ; // Work on each Attribute in the container. Enumeration e = atTbl . getNames ( ) ; while ( e . hasMoreElements ( ) ) { String aName = ( String ) e . nextElement ( ) ; Attribute a = atTbl . getAttribute ( aName ) ; String clearname = a . getClearName ( ) ; if ( a . isAlias ( ) ) { // copy an alias. String attribute = ( ( Alias ) a ) . getAliasedToAttributeFieldAsClearString ( ) ; looseEnds . addAlias ( clearname , convertDDSAliasFieldsToDASAliasFields ( attribute ) ) ; countLooseAttributes ++ ; } else if ( a . isContainer ( ) ) { // A reference copy. This is why we are working with a clone. myDAS . addAttributeTable ( clearname , a . getContainer ( ) ) ; } else { // copy an Attribute and it's values... int type = a . getType ( ) ; Enumeration vals = a . getValues ( ) ; while ( vals . hasMoreElements ( ) ) { String value = ( String ) vals . nextElement ( ) ; looseEnds . appendAttribute ( clearname , type , value , true ) ; } countLooseAttributes ++ ; } } if ( _Debug ) { DAPNode . log . debug ( "Found " + countLooseAttributes + " top level Attributes." ) ; } //if (_Debug) myDAS.print(LogStream.dbg); // Only add this AttributeTable if actually contains Attributes! if ( countLooseAttributes > 0 ) { if ( _Debug ) DAPNode . log . debug ( "Creating looseEnds table: " + looseEnds . getEncodedName ( ) ) ; myDAS . addAttributeTable ( looseEnds . getEncodedName ( ) , looseEnds ) ; } // Walk through the variables at the top level. e = getVariables ( ) ; while ( e . hasMoreElements ( ) ) { BaseType bt = ( BaseType ) e . nextElement ( ) ; // Build the correct AttributeTable for it at the Toplevel of the DAS buildDASAttributeTable ( bt , myDAS ) ; } //if (_Debug) myDAS.print(LogStream.dbg); // Make sure that the Aliases resolve correctly. Since we are moving from a // DDS/DDX space to a DFAS space the Aliases may not be resolvable. In that // case an exception will get thrown... myDAS . resolveAliases ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new DASException ( opendap . dap . DAP2Exception . UNKNOWN_ERROR , "Could not create a DAS from this DDX object.\n" + "Because of the structural differences between the DDX and the DAS it is " + "possible for the DDX to contain sets of Attributes that cannot be represented " + "in a DAS object.\n" + "The specific problem was an execption of type " + e . getClass ( ) . getName ( ) + " with an " + "error message of: \n" + e . getMessage ( ) ) ; } return ( myDAS ) ; }
Creates a DAS object from the collection of <code>BaseType</code> variables and their
associated <code>Attributes</code>. This DAS is correctly formed (vis-a-vis the DAP
specification) for this DDS.

@return A correctly formed <code>DAS</code> object for this DDS.
@throws DASException
@see DAS
@see BaseType
Creates a DAS object from the collection of <code > BaseType< / code > variables and their associated <code > Attributes< / code > . This DAS is correctly formed ( vis - a - vis the DAP specification ) for this DDS .