Package net.loomchild.segment.srx
Class RuleMatcher
- java.lang.Object
-
- net.loomchild.segment.srx.RuleMatcher
-
public class RuleMatcher extends java.lang.Object
Represents matcher finding subsequent occurrences of one rule.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.regex.Matcher
afterMatcher
private java.util.regex.Matcher
beforeMatcher
private SrxDocument
document
(package private) boolean
found
private Rule
rule
private java.lang.CharSequence
text
-
Constructor Summary
Constructors Constructor Description RuleMatcher(SrxDocument document, Rule rule, java.lang.CharSequence text)
Creates matcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
find()
Finds next rule match after previously found.boolean
find(int start)
Finds next rule match after given start position.int
getBreakPosition()
int
getEndPosition()
Rule
getRule()
int
getStartPosition()
boolean
hitEnd()
-
-
-
Field Detail
-
document
private SrxDocument document
-
rule
private Rule rule
-
text
private java.lang.CharSequence text
-
beforeMatcher
private java.util.regex.Matcher beforeMatcher
-
afterMatcher
private java.util.regex.Matcher afterMatcher
-
found
boolean found
-
-
Constructor Detail
-
RuleMatcher
public RuleMatcher(SrxDocument document, Rule rule, java.lang.CharSequence text)
Creates matcher.- Parameters:
rule
- rule which will be searched in the texttext
-
-
-
Method Detail
-
find
public boolean find()
Finds next rule match after previously found.- Returns:
- true if rule has been matched
-
find
public boolean find(int start)
Finds next rule match after given start position.- Parameters:
start
- start position- Returns:
- true if rule has been matched
-
hitEnd
public boolean hitEnd()
- Returns:
- true if end of text has been reached while searching
-
getStartPosition
public int getStartPosition()
- Returns:
- position in text where the last matching starts
-
getBreakPosition
public int getBreakPosition()
- Returns:
- position in text where text should be splitted according to last matching
-
getEndPosition
public int getEndPosition()
- Returns:
- position in text where the last matching ends
-
getRule
public Rule getRule()
- Returns:
- matcher rule
-
-