private ActionRuntime lookupFrom(final RouteChunk chunk, final String[] path) { // matched, scan children RouteChunk[] children = chunk.children(); if (children == null) { return null; } for (RouteChunk child : children) { ActionRuntime matched = match(child, path, 0); if (matched != null) { return matched; } } return null; }
private ActionRuntime match(final RouteChunk chunk, final String[] path, final int ndx) { final int maxDeep = path.length - 1; if (ndx > maxDeep) { // too deep, don't go any further return null; } if (!chunk.match(path[ndx])) { // no match, continue return null; } if (ndx == maxDeep) { // end of the path if (chunk.isEndpoint()) { return chunk.value(); } return null; } // matched, scan children RouteChunk[] children = chunk.children(); if (children == null) { return null; } for (RouteChunk child : children) { ActionRuntime matched = match(child, path, ndx + 1); if (matched != null) { return matched; } } return null; }