opendap/src/main/java/opendap/servers/parsers/AST.java
Stack collect(Stack components)
        throws DAP2ServerSideException, DAP2Exception,
        NoSuchFunctionException, NoSuchVariableException
    {
        BaseType bt = null;
        ServerArrayMethods sam = null;
        components = getSdds().search(name, components);
        if(slices != null && slices.size() > 0) {
            try {
                bt = (BaseType) components.peek();
            } catch (ClassCastException cce) {
                String msg = "Attempt to treat the variable `" + name
                    + "' as if it is an array.";
                throw new DAP2Exception(DAP2Exception.MALFORMED_EXPR, msg);
            }
            if(bt instanceof DGrid) {// project the grid and the coordinate variable
                DGrid grid = ((DGrid) bt);
                bt = grid.getArray();
                sam = (ServerArrayMethods) bt;
                for(int i = 0;i < slices.size();i++) {
                    ASTslice slice = slices.get(i);
                    slice.walk(sam, i);
                }
                // walk the coordinate variables also
                for(int i = 0;i < slices.size();i++) {
                    ASTslice slice = slices.get(i);
                    bt = grid.getVar(i + 1);
                    sam = (ServerArrayMethods) bt;
                    slice.walk(sam, 0);
                }
            } else if(bt instanceof ServerArrayMethods) {
                sam = (ServerArrayMethods) bt;
                for(int i = 0;i < slices.size();i++) {
                    ASTslice slice = slices.get(i);
                    slice.walk(sam, i);
                }
            }
        }
        return components;
    }
Stack collect(Stack components)
        throws DAP2ServerSideException, DAP2Exception,
        NoSuchFunctionException, NoSuchVariableException
    {
        BaseType bt = null;
        ServerArrayMethods sam = null;
        components = getSdds().search(name, components);
        if(slices != null && slices.size() > 0) {
            try {
                bt = (BaseType) components.peek();
            } catch (ClassCastException cce) {
                String msg = "Attempt to treat the variable `" + name
                    + "' as if it is an array.";
                throw new DAP2Exception(DAP2Exception.MALFORMED_EXPR, msg);
            }
            if(bt instanceof DGrid) {// project the grid and the coordinate variable
                DGrid grid = ((DGrid) bt);
                bt = grid.getArray();
                sam = (ServerArrayMethods) bt;
                for(int i = 0;i < slices.size();i++) {
                    ASTslice slice = slices.get(i);
                    slice.walk(sam, i);
                }
                // walk the coordinate variables also
                for(int i = 0;i < slices.size();i++) {
                    ASTslice slice = slices.get(i);
                    bt = grid.getVar(i + 1);
                    sam = (ServerArrayMethods) bt;
                    slice.walk(sam, 0);
                }
            } else if(bt instanceof ServerArrayMethods) {
                sam = (ServerArrayMethods) bt;
                for(int i = 0;i < slices.size();i++) {
                    ASTslice slice = slices.get(i);
                    slice.walk(sam, i);
                }
            }
        }
        return components;
    }
/*
public String toString()
{
StringBuilder buf = new StringBuilder();
buf.append(name);
if (slices != null)
for(ASTslice slice : slices) {
buf.append(slice.toString());
}
return buf.toString();
}