Package net.sf.saxon.regex
Class Operation
- java.lang.Object
-
- net.sf.saxon.regex.Operation
-
- Direct Known Subclasses:
Operation.OpAtom
,Operation.OpBackReference
,Operation.OpBOL
,Operation.OpCapture
,Operation.OpCharClass
,Operation.OpChoice
,Operation.OpEndProgram
,Operation.OpEOL
,Operation.OpNothing
,Operation.OpRepeat
,Operation.OpSequence
,Operation.OpTrace
public abstract class Operation extends java.lang.Object
Represents an operation or instruction in the regular expression program. The class Operation is abstract, and has concrete subclasses for each kind of operation/instruction
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Operation.OpAtom
A match against a fixed string of any lengthstatic class
Operation.OpBackReference
Back-referencestatic class
Operation.OpBOL
Beginning of Line (^)static class
Operation.OpCapture
Open paren (captured group)static class
Operation.OpCharClass
A match of a single character in the input against a set of permitted charactersstatic class
Operation.OpChoice
A choice of several branchesstatic class
Operation.OpEndProgram
End of programstatic class
Operation.OpEOL
End of Line ($)static class
Operation.OpGreedyFixed
Handle a greedy repetition (with possible min and max) where the size of the repeated unit is fixed.static class
Operation.OpNothing
Match empty stringstatic class
Operation.OpReluctantFixed
Handle a reluctant repetition (with possible min and max) where the size of the repeated unit is fixed.static class
Operation.OpRepeat
Handle a repetition (with possible min and max) where the size of the repeated unit is variable.static class
Operation.OpSequence
A sequence of multiple piecesstatic class
Operation.OpTrace
Operation that wraps a base operation and traces its executionstatic class
Operation.OpUnambiguousRepeat
Handle a repetition where there is no ambiguity; if the repeated term is matched in the string, then it cannot match anything other than the repeated term.
-
Constructor Summary
Constructors Constructor Description Operation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
containsCapturingExpressions()
Ask whether the expression contains any capturing sub-expressionsabstract java.lang.String
display()
Display the operation as a regular expression, possibly in abbreviated formCharacterClass
getInitialCharacterClass(boolean caseBlind)
Get a CharacterClass identifying the set of characters that can appear as the first character of a non-empty string that matches this term.int
getMatchLength()
Get the length of the matches returned by this operation if they are fixed-lengthint
getMinimumMatchLength()
Get the minimum length of the matches returned by this operationabstract IntIterator
iterateMatches(REMatcher matcher, int position)
Get an iterator returning all the matches for this operationabstract int
matchesEmptyString()
Ask whether the regular expression is known, after static analysis, to match a zero-length stringOperation
optimize(REProgram program, REFlags flags)
Optimize the operation
-
-
-
Method Detail
-
iterateMatches
public abstract IntIterator iterateMatches(REMatcher matcher, int position)
Get an iterator returning all the matches for this operation- Parameters:
matcher
- supplies the context for the matching; may be updated with information about captured groupsposition
- the start position to seek a match- Returns:
- an iterator returning the endpoints of all matches starting at the supplied position
-
getMatchLength
public int getMatchLength()
Get the length of the matches returned by this operation if they are fixed-length- Returns:
- the length of the matches, or -1 if the length is variable
-
getMinimumMatchLength
public int getMinimumMatchLength()
Get the minimum length of the matches returned by this operation- Returns:
- the length of the shortest string that will match the operation
-
matchesEmptyString
public abstract int matchesEmptyString()
Ask whether the regular expression is known, after static analysis, to match a zero-length string- Returns:
- a value indicating whether the regex is statically known to match
a zero-length string. Specifically:
- returns
MATCHES_ZLS_AT_START
if the expression is statically known to match a zero-length string at the start of the supplied input; - returns
MATCHES_ZLS_AT_END
if it is statically known to return a zero-length string at the end of the supplied input; - returns
MATCHES_ZLS_ANYWHERE
if it is statically known to match a zero-length string anywhere in the input. - returns
MATCHES_ZLS_NEVER
if it is statically known that the regex will never match a zero length string.
- returns
-
containsCapturingExpressions
public boolean containsCapturingExpressions()
Ask whether the expression contains any capturing sub-expressions- Returns:
- true if the expression contains any capturing sub-expressions (but not if it is a capturing expression itself, unless it contains nested capturing expressions)
-
getInitialCharacterClass
public CharacterClass getInitialCharacterClass(boolean caseBlind)
Get a CharacterClass identifying the set of characters that can appear as the first character of a non-empty string that matches this term. This is allowed to be an over-estimate (that is, the returned Character class must match every character that can legitimately appear at the start of the matched string, but it can also match other characters).- Parameters:
caseBlind
- true if case-blind matching is in force ("i" flag)
-
optimize
public Operation optimize(REProgram program, REFlags flags)
Optimize the operation- Parameters:
program
- the program being optimizedflags
- the regular expression flags- Returns:
- the optimized operation
-
display
public abstract java.lang.String display()
Display the operation as a regular expression, possibly in abbreviated form- Returns:
- the operation in a form that is recognizable as a regular expression or abbreviated regular expression
-
-