opendap/src/main/java/ucar/nc2/dods/DodsV.java
static private void parseDataVariables(DodsV parent, Enumeration children) throws NoSuchVariableException {
    while (children.hasMoreElements()) {
      opendap.dap.BaseType bt = (opendap.dap.BaseType) children.nextElement();
      DodsV dodsV = new DodsV(parent, bt);
      parent.children.add(dodsV);

      if (bt instanceof DGrid) {
        DGrid dgrid = (DGrid) bt;
        if (dodsV.parent.bt == null) { // is top level
          // top level grids are replaced by their "data array"
          dodsV.darray = (DArray) dgrid.getVar(0);
          processDArray(dodsV);
        } else {
          // nested grids are made into Structures
          dodsV.makeAllDimensions();
        }

        java.util.Enumeration enumerate2 = dgrid.getVariables();
        parseDataVariables(dodsV, enumerate2);

      } else if (bt instanceof DSequence) {
        DSequence dseq = (DSequence) bt;
        int seqlen = dseq.getRowCount();
        if (seqlen > 0) {
          DArrayDimension ddim = new DArrayDimension(seqlen, null);
          dodsV.dimensions.add(ddim);
        }
        dodsV.makeAllDimensions();

        java.util.Enumeration enumerate2 = dseq.getVariables();
        parseDataVariables(dodsV, enumerate2);

      } else if (bt instanceof DConstructor) {
        DStructure dcon = (DStructure) bt; // LOOK DConstructor != DStructure?
        dodsV.makeAllDimensions();
        java.util.Enumeration enumerate2 = dcon.getVariables();
        parseDataVariables(dodsV, enumerate2);

      } else if (bt instanceof DArray) {
        dodsV.darray = (DArray) bt;
        processDArray(dodsV);

        dodsV.bt = dodsV.elemType;
        if (dodsV.elemType instanceof DStructure) {
          DStructure dcon = (DStructure) dodsV.elemType;
          java.util.Enumeration nestedVariables = dcon.getVariables();
          parseDataVariables(dodsV, nestedVariables);
        }
      } else {
        dodsV.makeAllDimensions();
      }

    }
  }
static private void parseDataVariables(DodsV parent, Enumeration children) throws NoSuchVariableException {
    while (children.hasMoreElements()) {
      opendap.dap.BaseType bt = (opendap.dap.BaseType) children.nextElement();
      DodsV dodsV = new DodsV(parent, bt);
      parent.children.add(dodsV);

      if (bt instanceof DGrid) {
        DGrid dgrid = (DGrid) bt;
        if (dodsV.parent.bt == null) { // is top level
          // top level grids are replaced by their "data array"
          dodsV.darray = (DArray) dgrid.getVar(0);
          processDArray(dodsV);
        } else {
          // nested grids are made into Structures
          dodsV.makeAllDimensions();
        }

        java.util.Enumeration enumerate2 = dgrid.getVariables();
        parseDataVariables(dodsV, enumerate2);

      } else if (bt instanceof DSequence) {
        DSequence dseq = (DSequence) bt;
        int seqlen = dseq.getRowCount();
        if (seqlen > 0) {
          DArrayDimension ddim = new DArrayDimension(seqlen, null);
          dodsV.dimensions.add(ddim);
        }
        dodsV.makeAllDimensions();

        java.util.Enumeration enumerate2 = dseq.getVariables();
        parseDataVariables(dodsV, enumerate2);

      } else if (bt instanceof DConstructor) {
        DStructure dcon = (DStructure) bt; // LOOK DConstructor != DStructure?
        dodsV.makeAllDimensions();
        java.util.Enumeration enumerate2 = dcon.getVariables();
        parseDataVariables(dodsV, enumerate2);

      } else if (bt instanceof DArray) {
        dodsV.darray = (DArray) bt;
        processDArray(dodsV);

        dodsV.bt = dodsV.elemType;
        if (dodsV.elemType instanceof DStructure) {
          DStructure dcon = (DStructure) dodsV.elemType;
          java.util.Enumeration nestedVariables = dcon.getVariables();
          parseDataVariables(dodsV, nestedVariables);
        }
      } else {
        dodsV.makeAllDimensions();
      }

    }
  }
static private void parseDataVariables ( DodsV parent , Enumeration children ) throws NoSuchVariableException { while ( children . hasMoreElements ( ) ) { opendap . dap . BaseType bt = ( opendap . dap . BaseType ) children . nextElement ( ) ; DodsV dodsV = new DodsV ( parent , bt ) ; parent . children . add ( dodsV ) ; if ( bt instanceof DGrid ) { DGrid dgrid = ( DGrid ) bt ; if ( dodsV . parent . bt == null ) { // is top level
 // top level grids are replaced by their "data array"
 dodsV . darray = ( DArray ) dgrid . getVar ( 0 ) ; processDArray ( dodsV ) ; } else { // nested grids are made into Structures
 dodsV . makeAllDimensions ( ) ; } java . util . Enumeration enumerate2 = dgrid . getVariables ( ) ; parseDataVariables ( dodsV , enumerate2 ) ; } else if ( bt instanceof DSequence ) { DSequence dseq = ( DSequence ) bt ; int seqlen = dseq . getRowCount ( ) ; if ( seqlen > 0 ) { DArrayDimension ddim = new DArrayDimension ( seqlen , null ) ; dodsV . dimensions . add ( ddim ) ; } dodsV . makeAllDimensions ( ) ; java . util . Enumeration enumerate2 = dseq . getVariables ( ) ; parseDataVariables ( dodsV , enumerate2 ) ; } else if ( bt instanceof DConstructor ) { DStructure dcon = ( DStructure ) bt ; // LOOK DConstructor != DStructure?
 dodsV . makeAllDimensions ( ) ; java . util . Enumeration enumerate2 = dcon . getVariables ( ) ; parseDataVariables ( dodsV , enumerate2 ) ; } else if ( bt instanceof DArray ) { dodsV . darray = ( DArray ) bt ; processDArray ( dodsV ) ; dodsV . bt = dodsV . elemType ; if ( dodsV . elemType instanceof DStructure ) { DStructure dcon = ( DStructure ) dodsV . elemType ; java . util . Enumeration nestedVariables = dcon . getVariables ( ) ; parseDataVariables ( dodsV , nestedVariables ) ; } } else { dodsV . makeAllDimensions ( ) ; } } }
Recursively build the dodsV tree.
1) put all Variables into a DodsV
2) unravel DConstructors (DSequence, DStructure, DGrid)
3) for Darray, we put Variable = elemType, and store the darray seperately, not in the heirarchy.

@param parent   of the tree
@param children list of BaseType
@throws opendap.dap.NoSuchVariableException if children and parent are inconsistent
Recursively build the dodsV tree . 1 ) put all Variables into a DodsV 2 ) unravel DConstructors ( DSequence DStructure DGrid ) 3 ) for Darray we put Variable = elemType and store the darray seperately not in the heirarchy .