dap4/d4core/src/main/java/dap4/core/dmr/DapDataset.java
public void
    sortR(DapNode node, List<DapNode> sortlist)
    {
        DapVariable var = null;
        Map<String, DapAttribute> attrs = null;
        sortlist.add(node);
        switch (node.getSort()) {
        case DATASET:
        case GROUP:
            // Walk the decls in this group in order
            // attributes, dimensions, enums, variables, groups
            DapGroup group = (DapGroup) node;
            attrs = group.getAttributes();
            for(Map.Entry<String, DapAttribute> entry : attrs.entrySet()) {
                sortR(entry.getValue(), sortlist);
            }
            List<DapDimension> dims = group.getDimensions();
            if(dims != null)
                for(int i = 0; i < dims.size(); i++) {
                    sortR(dims.get(i), sortlist);
                }
            List<DapEnumeration> enums = group.getEnums();
            if(enums != null)
                for(int i = 0; i < enums.size(); i++) {
                    sortR(enums.get(i), sortlist);
                }
            List<DapVariable> vars = group.getVariables();
            if(vars != null)
                for(int i = 0; i < vars.size(); i++) {
                    sortR(vars.get(i), sortlist);
                }
            List<DapGroup> groups = group.getGroups();
            if(groups != null)
                for(int i = 0; i < groups.size(); i++) {
                    sortR(groups.get(i), sortlist);
                }
            break;
        case VARIABLE:
            var = (DapVariable) node;
            attrs = var.getAttributes();
            if(attrs != null)
                for(Map.Entry<String, DapAttribute> entry : attrs.entrySet()) {
                    sortR(entry.getValue(), sortlist);
                }
            List<DapMap> maps = var.getMaps();
            if(maps != null)
                for(int i = 0; i < maps.size(); i++) {
                    sortR(maps.get(i), sortlist);
                }
            dims = var.getDimensions();
            if(dims != null)
                for(int i = 0; i < dims.size(); i++) {
                    sortR(dims.get(i), sortlist);
                }
            break;

        case ATTRIBUTE:
            attrs = node.getAttributes();
            if(attrs != null)
                for(String name : attrs.keySet()) {
                    sortR(attrs.get(name), sortlist);
                }
            break;

        default:
            break;
        }
    }
public void
    sortR(DapNode node, List<DapNode> sortlist)
    {
        DapVariable var = null;
        Map<String, DapAttribute> attrs = null;
        sortlist.add(node);
        switch (node.getSort()) {
        case DATASET:
        case GROUP:
            // Walk the decls in this group in order
            // attributes, dimensions, enums, variables, groups
            DapGroup group = (DapGroup) node;
            attrs = group.getAttributes();
            for(Map.Entry<String, DapAttribute> entry : attrs.entrySet()) {
                sortR(entry.getValue(), sortlist);
            }
            List<DapDimension> dims = group.getDimensions();
            if(dims != null)
                for(int i = 0; i < dims.size(); i++) {
                    sortR(dims.get(i), sortlist);
                }
            List<DapEnumeration> enums = group.getEnums();
            if(enums != null)
                for(int i = 0; i < enums.size(); i++) {
                    sortR(enums.get(i), sortlist);
                }
            List<DapVariable> vars = group.getVariables();
            if(vars != null)
                for(int i = 0; i < vars.size(); i++) {
                    sortR(vars.get(i), sortlist);
                }
            List<DapGroup> groups = group.getGroups();
            if(groups != null)
                for(int i = 0; i < groups.size(); i++) {
                    sortR(groups.get(i), sortlist);
                }
            break;
        case VARIABLE:
            var = (DapVariable) node;
            attrs = var.getAttributes();
            if(attrs != null)
                for(Map.Entry<String, DapAttribute> entry : attrs.entrySet()) {
                    sortR(entry.getValue(), sortlist);
                }
            List<DapMap> maps = var.getMaps();
            if(maps != null)
                for(int i = 0; i < maps.size(); i++) {
                    sortR(maps.get(i), sortlist);
                }
            dims = var.getDimensions();
            if(dims != null)
                for(int i = 0; i < dims.size(); i++) {
                    sortR(dims.get(i), sortlist);
                }
            break;

        case ATTRIBUTE:
            attrs = node.getAttributes();
            if(attrs != null)
                for(String name : attrs.keySet()) {
                    sortR(attrs.get(name), sortlist);
                }
            break;

        default:
            break;
        }
    }
public void sortR ( DapNode node , List < DapNode > sortlist ) { DapVariable var = null ; Map < String , DapAttribute > attrs = null ; sortlist . add ( node ) ; switch ( node . getSort ( ) ) { case DATASET : case GROUP : // Walk the decls in this group in order // attributes, dimensions, enums, variables, groups DapGroup group = ( DapGroup ) node ; attrs = group . getAttributes ( ) ; for ( Map . Entry < String , DapAttribute > entry : attrs . entrySet ( ) ) { sortR ( entry . getValue ( ) , sortlist ) ; } List < DapDimension > dims = group . getDimensions ( ) ; if ( dims != null ) for ( int i = 0 ; i < dims . size ( ) ; i ++ ) { sortR ( dims . get ( i ) , sortlist ) ; } List < DapEnumeration > enums = group . getEnums ( ) ; if ( enums != null ) for ( int i = 0 ; i < enums . size ( ) ; i ++ ) { sortR ( enums . get ( i ) , sortlist ) ; } List < DapVariable > vars = group . getVariables ( ) ; if ( vars != null ) for ( int i = 0 ; i < vars . size ( ) ; i ++ ) { sortR ( vars . get ( i ) , sortlist ) ; } List < DapGroup > groups = group . getGroups ( ) ; if ( groups != null ) for ( int i = 0 ; i < groups . size ( ) ; i ++ ) { sortR ( groups . get ( i ) , sortlist ) ; } break ; case VARIABLE : var = ( DapVariable ) node ; attrs = var . getAttributes ( ) ; if ( attrs != null ) for ( Map . Entry < String , DapAttribute > entry : attrs . entrySet ( ) ) { sortR ( entry . getValue ( ) , sortlist ) ; } List < DapMap > maps = var . getMaps ( ) ; if ( maps != null ) for ( int i = 0 ; i < maps . size ( ) ; i ++ ) { sortR ( maps . get ( i ) , sortlist ) ; } dims = var . getDimensions ( ) ; if ( dims != null ) for ( int i = 0 ; i < dims . size ( ) ; i ++ ) { sortR ( dims . get ( i ) , sortlist ) ; } break ; case ATTRIBUTE : attrs = node . getAttributes ( ) ; if ( attrs != null ) for ( String name : attrs . keySet ( ) ) { sortR ( attrs . get ( name ) , sortlist ) ; } break ; default : break ; } }
Sort helper

@param node the current node we are traversing
Sort helper