private int[] getPathParameterBounds(String name) {
Iterator<UriTemplate> iTemplate = templates.iterator();
Iterator<MatchResult> iMatchResult = matchResults.iterator();
while (iTemplate.hasNext()) {
MatchResult mr = iMatchResult.next();
// Find the index of path parameter
int pIndex = getLastPathParameterIndex(name, iTemplate.next());
if (pIndex != -1) {
int pathLength = mr.group().length();
int segmentIndex = mr.end(pIndex + 1);
int groupLength = segmentIndex - mr.start(pIndex + 1);
// Find the absolute position of the end of the
// capturing group in the request path
while (iMatchResult.hasNext()) {
mr = iMatchResult.next();
segmentIndex += mr.group().length() - pathLength;
pathLength = mr.group().length();
}
int[] bounds = {segmentIndex - groupLength, segmentIndex};
return bounds;
}
}