/** * This method looks for an element in this DataObject. * * @param name Name of an element * @return boolean true if there is an element by that name, else false */ public boolean existsElement(String name) { int n = this.countChildren(); boolean result = false; if (n > 0) { Vector children = this.getChildren(); for (int i = 0; i < n; i++) { DataObject currentChild = (DataObject) children.elementAt(i); String currentName = currentChild.getName(); if (currentName.equals(name)) { // sounds like we've found it result = true; } if (result == false) { // carry on searching the children if (currentChild.countChildren() > 0) { result = currentChild.existsElement(name); } if (result) { // did we find it? break; // then stop here } } } // for } return result; }