예제 #1
0
  /**
   * 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;
  }
예제 #2
0
  /**
   * This method looks for an element in this DataObject. Why does this method exist? No external
   * class uses this! --Brian
   *
   * @param name Name of an element
   * @return boolean true if there is an element by that name, else false
   */
  protected boolean elementExists(String name) {
    //		int n = this.countChildren();
    boolean result = false;

    for (DataObject currentChild : this.getChildren()) {
      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.elementExists(name);
        }
        if (result) { // did we find it?
          break; // then stop here
        }
      }
    }
    return result;
  }