in bval-jsr/src/main/java/org/apache/bval/jsr/util/PathNavigation.java [250:281]
private static void handleIndex(CharSequence path, PathPosition pos) throws Exception {
final int len = path.length();
final int start = pos.getIndex();
if (start < len) {
final char first = path.charAt(pos.getIndex());
if (first == '"' || first == '\'') {
final String s = QUOTED_STRING_PARSER.parseQuotedString(path, pos);
if (s != null && path.charAt(pos.getIndex()) == ']') {
pos.handleIndexOrKey(s);
pos.next();
return;
}
}
// no quoted string; match ] greedily
while (pos.getIndex() < len) {
final int here = pos.getIndex();
try {
if (path.charAt(here) == ']') {
if (here == start) {
pos.handleGenericInIterable();
} else {
pos.handleIndexOrKey(path.subSequence(start, here).toString());
}
return;
}
} finally {
pos.next();
}
}
}
Exceptions.raise(IllegalStateException::new, "Position %s: unparsable index", start);
}