opendap/src/main/java/opendap/dap/DGrid.java
public void addVariable(BaseType v, int part) {

        if (!(v instanceof DArray)) throw new IllegalArgumentException(
                "Grid `" + getEncodedName() +
                        "'s' member `" + arrayVar.getEncodedName() +
                        "' must be an array");

        v.setParent(this);

        switch (part) {

            case ARRAY:
                arrayVar = (DArray) v;
                return;

            case MAPS:
                mapVars.addElement(v);
                return;

            default:
                throw new IllegalArgumentException("addVariable(): Unknown Grid part");
        }
    }
public void addVariable(BaseType v, int part) {

        if (!(v instanceof DArray)) throw new IllegalArgumentException(
                "Grid `" + getEncodedName() +
                        "'s' member `" + arrayVar.getEncodedName() +
                        "' must be an array");

        v.setParent(this);

        switch (part) {

            case ARRAY:
                arrayVar = (DArray) v;
                return;

            case MAPS:
                mapVars.addElement(v);
                return;

            default:
                throw new IllegalArgumentException("addVariable(): Unknown Grid part");
        }
    }
Adds a variable to the container.

@param v    the variable to add.
@param part the part of the <code>DGrid</code> to be modified.  Allowed
values are <code>ARRAY</code> or <code>MAPS</code>.
@throws IllegalArgumentException if an invalid part was given.