コード例 #1
0
ファイル: XML.java プロジェクト: JakubValtar/processing
 /**
  * Internal helper function for getChild(String).
  *
  * @param items result of splitting the query on slashes
  * @param offset where in the items[] array we're currently looking
  * @return matching element or null if no match
  * @author processing.org
  */
 protected XML getChildRecursive(String[] items, int offset) {
   // if it's a number, do an index instead
   if (Character.isDigit(items[offset].charAt(0))) {
     XML kid = getChild(Integer.parseInt(items[offset]));
     if (offset == items.length - 1) {
       return kid;
     } else {
       return kid.getChildRecursive(items, offset + 1);
     }
   }
   int childCount = getChildCount();
   for (int i = 0; i < childCount; i++) {
     XML kid = getChild(i);
     String kidName = kid.getName();
     if (kidName != null && kidName.equals(items[offset])) {
       if (offset == items.length - 1) {
         return kid;
       } else {
         return kid.getChildRecursive(items, offset + 1);
       }
     }
   }
   return null;
 }