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
(String[] items, int offset)
| 484 | * @author processing.org |
| 485 | */ |
| 486 | protected XML getChildRecursive(String[] items, int offset) { |
| 487 | // if it's a number, do an index instead |
| 488 | if (Character.isDigit(items[offset].charAt(0))) { |
| 489 | XML kid = getChild(Integer.parseInt(items[offset])); |
| 490 | if (offset == items.length-1) { |
| 491 | return kid; |
| 492 | } else { |
| 493 | return kid.getChildRecursive(items, offset+1); |
| 494 | } |
| 495 | } |
| 496 | int childCount = getChildCount(); |
| 497 | for (int i = 0; i < childCount; i++) { |
| 498 | XML kid = getChild(i); |
| 499 | String kidName = kid.getName(); |
| 500 | if (kidName != null && kidName.equals(items[offset])) { |
| 501 | if (offset == items.length-1) { |
| 502 | return kid; |
| 503 | } else { |
| 504 | return kid.getChildRecursive(items, offset+1); |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | return null; |
| 509 | } |
| 510 | |
| 511 | |
| 512 | /** |