mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
Prepare the Matcher class for multiple groups
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
e6ad10de04
commit
2073d4bffb
@ -87,4 +87,33 @@ public abstract class Matcher {
|
||||
public int end() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public String group() {
|
||||
return input.subSequence(start, end).toString();
|
||||
}
|
||||
|
||||
public int start(int group) {
|
||||
if (group == 0) {
|
||||
return start();
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int end(int group) {
|
||||
if (group == 0) {
|
||||
return end();
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String group(int group) {
|
||||
if (group == 0) {
|
||||
return group();
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int groupCount() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,25 @@ public class RegexMatcher extends Matcher {
|
||||
public boolean find(int offset) {
|
||||
throw new UnsupportedOperationException("TODO");
|
||||
}
|
||||
|
||||
public int start(int group) {
|
||||
return groupStart[group];
|
||||
}
|
||||
|
||||
public int end(int group) {
|
||||
return groupEnd[group];
|
||||
}
|
||||
|
||||
public String group(int group) {
|
||||
int offset = start(group);
|
||||
if (offset < 0) {
|
||||
return null;
|
||||
}
|
||||
int length = end(group) - offset;
|
||||
return new String(array, offset, length);
|
||||
}
|
||||
|
||||
public int groupCount() {
|
||||
return groupStart.length - 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user