cdm/src/main/java/ucar/nc2/CDMNode.java
static public CDMNode
    unwrap(CDMNode node)
    {
        if(!(node instanceof Variable))
            return node;
        Variable inner = (Variable) node;
        for(; ; ) {
            if(inner instanceof VariableDS) {
                VariableDS vds = (VariableDS) inner;
                inner = vds.getOriginalVariable();
                if(inner == null) {
                    inner = vds;
                    break;
                }
            } else if(inner instanceof StructureDS) {
                StructureDS sds = (StructureDS) inner;
                inner = sds.getOriginalVariable();
                if(inner == null) {
                    inner = sds;
                    break;
                }
            } else break; // base case we have straight Variable or Stucture
        }
        return inner;
    }
static public CDMNode
    unwrap(CDMNode node)
    {
        if(!(node instanceof Variable))
            return node;
        Variable inner = (Variable) node;
        for(; ; ) {
            if(inner instanceof VariableDS) {
                VariableDS vds = (VariableDS) inner;
                inner = vds.getOriginalVariable();
                if(inner == null) {
                    inner = vds;
                    break;
                }
            } else if(inner instanceof StructureDS) {
                StructureDS sds = (StructureDS) inner;
                inner = sds.getOriginalVariable();
                if(inner == null) {
                    inner = sds;
                    break;
                }
            } else break; // base case we have straight Variable or Stucture
        }
        return inner;
    }
static public CDMNode unwrap ( CDMNode node ) { if ( ! ( node instanceof Variable ) ) return node ; Variable inner = ( Variable ) node ; for ( ; ; ) { if ( inner instanceof VariableDS ) { VariableDS vds = ( VariableDS ) inner ; inner = vds . getOriginalVariable ( ) ; if ( inner == null ) { inner = vds ; break ; } } else if ( inner instanceof StructureDS ) { StructureDS sds = ( StructureDS ) inner ; inner = sds . getOriginalVariable ( ) ; if ( inner == null ) { inner = sds ; break ; } } else break ; // base case we have straight Variable or Stucture } return inner ; }
NetcdfDataset can end up wrapping a variable
in multiple wrapping classes (e.g. VariableDS).
Goal of this procedure is to get down to the
lowest level Variable instance

@param node possibly wrapped ode
@return the lowest level node instance
NetcdfDataset can end up wrapping a variable in multiple wrapping classes ( e . g . VariableDS ) . Goal of this procedure is to get down to the lowest level Variable instance