opendap/src/main/java/opendap/dap/DStructure.java
public int elementCount(boolean leaves) {
        if (!leaves)
            return vars.size();
        else {
            int count = 0;
            for (Enumeration e = vars.elements(); e.hasMoreElements();) {
                BaseType bt = (BaseType) e.nextElement();
                count += bt.elementCount(leaves);
            }
            return count;
        }
    }
public int elementCount(boolean leaves) {
        if (!leaves)
            return vars.size();
        else {
            int count = 0;
            for (Enumeration e = vars.elements(); e.hasMoreElements();) {
                BaseType bt = (BaseType) e.nextElement();
                count += bt.elementCount(leaves);
            }
            return count;
        }
    }
Returns the number of variables contained in this object. For simple and
vector type variables, it always returns 1. To count the number
of simple-type variable in the variable tree rooted at this variable, set
<code>leaves</code> to <code>true</code>.

@param leaves If true, count all the simple types in the `tree' of
variables rooted at this variable.
@return the number of contained variables.