| Method from java.util.regex.AbstractSet Detail: |
public int find(int stringIndex,
CharSequence testString,
MatchResultImpl matchResult) {
int length = matchResult.getRightBound();
while (stringIndex < = length) {
if (matches(stringIndex, testString, matchResult) >= 0) {
return stringIndex;
} else {
stringIndex++;
}
}
return -1;
}
Attempts to apply pattern starting from this set/stringIndex; returns
index this search was started from, if value is negative, this means that
this search didn't succeed, additional information could be obtained via
matchResult;
Note: this is default implementation for find method, it's based on
matches, subclasses do not have to override find method unless
more effective find method exists for a particular node type
(sequence, i.e. substring, for example). Same applies for find back
method. |
public int findBack(int stringIndex,
int startSearch,
CharSequence testString,
MatchResultImpl matchResult) {
while (startSearch >= stringIndex) {
if (matches(startSearch, testString, matchResult) >= 0) {
return startSearch;
} else {
startSearch--;
}
}
return -1;
}
|
public boolean first(AbstractSet set) {
return true;
}
Returns true if the given node intersects with this one,
false otherwise.
This method is being used for quantifiers construction,
lets consider the following regular expression (a|b)*ccc.
(a|b) does not intersects with "ccc" and thus can be quantified
greedily (w/o kickbacks), like *+ instead of *. |
abstract protected String getName()
Returns name for the particular node type.
Used for debugging purposes. |
public AbstractSet getNext() {
return next;
}
|
protected String getQualifiedName() {
return "< " + index + ":" + getName() + " >"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
|
public int getType() {
return this.type;
}
|
abstract public boolean hasConsumed(MatchResultImpl matchResult)
Returns true, if this node has consumed any characters during
positive match attempt, for example node representing character always
consumes one character if it matches. If particular node matches
empty sting this method will return false; |
abstract public int matches(int stringIndex,
CharSequence testString,
MatchResultImpl matchResult)
Checks if this node matches in given position and recursively call
next node matches on positive self match. Returns positive integer if
entire match succeed, negative otherwise |
public JointSet processBackRefReplacement() {
return null;
}
This method is used for replacement backreferenced
sets. |
public void processSecondPass() {
this.isSecondPassVisited = true;
if (next != null) {
if (!next.isSecondPassVisited) {
/*
* Add here code to do during the pass
*/
JointSet set = next.processBackRefReplacement();
if (set != null) {
next.isSecondPassVisited = true;
next =(AbstractSet) set;
}
/*
* End code to do during the pass
*/
next.processSecondPass();
} else {
/*
* We reach node through next but it is already traversed.
* You can see this situation for AltGroupQuantifierSet.next
* when we reach this node through
* AltGroupQuantifierSet.innerset. ... .next
*/
/*
* Add here code to do during the pass
*/
if (next instanceof SingleSet
&& ((FSet) ((JointSet) next).fSet).isBackReferenced) {
next = next.next;
}
/*
* End code to do during the pass
*/
}
}
}
This method is used for traversing nodes after the
first stage of compilation. |
public void setNext(AbstractSet next) {
this.next = next;
}
|
protected void setType(int type) {
this.type = type;
}
|
public String toString() {
return getQualifiedName();
}
|