MatchResultImplpublic class MatchResultImpl extends Object implements MatchResultHolds the results of a successful match of a regular expression against a
given string. Only used internally, thus sparsely documented (though the
defining public interface has full documentation). |
Fields Summary |
---|
private String | textHolds the original input text. | private int[] | offsetsHolds the offsets of the groups in the input text. The first two
elements specifiy start and end of the zero group, the next two specify
group 1, and so on. |
Constructors Summary |
---|
MatchResultImpl(String text, int[] offsets)
this.text = text;
this.offsets = offsets.clone();
|
Methods Summary |
---|
public int | end()
return end(0);
| public int | end(int group)
return offsets[2 * group + 1];
| public java.lang.String | group()
return text.substring(start(), end());
| public java.lang.String | group(int group)
int from = offsets[group * 2];
int to = offsets[(group * 2) + 1];
if (from == -1 || to == -1) {
return null;
} else {
return text.substring(from, to);
}
| public int | groupCount()
return (offsets.length / 2) - 1;
| public int | start()
return start(0);
| public int | start(int group)
return offsets[2 * group];
|
|