Package net.sf.saxon.regex
Class Operation
java.lang.Object
net.sf.saxon.regex.Operation
- Direct Known Subclasses:
OpAtom,OpBackReference,OpBOL,OpBoundaryAssertion,OpCapture,OpCharClass,OpChoice,OpEndProgram,OpEOL,OpLookahead,OpLookbehind,OpNothing,OpRepeat,OpSequence,OpTrace
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 ClassesModifier and TypeClassDescriptionprotected static classThe ForceProgressIterator is used to protect against non-termination; specifically, iterators that return an infinite number of zero-length matches. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAsk whether the expression contains any capturing sub-expressionsabstract Stringdisplay()Display the operation as a regular expression, possibly in abbreviated formgetInitialCharacterClass(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.intGet the length of the matches returned by this operation if they are fixed-lengthintGet the maximum depth of looping within this operationintGet the minimum length of the matches returned by this operationbooleanAsk whether the expression is allowed within a lookbehindbooleanAsk whether the expression is a zero-width assertionabstract IntIteratoriterateMatches(REMatcher matcher, int position) Get an iterator returning all the matches for this operationabstract intAsk whether the regular expression is known, after static analysis, to match a zero-length stringOptimize the operation
-
Field Details
-
MATCHES_ZLS_AT_START
protected static final int MATCHES_ZLS_AT_START- See Also:
-
MATCHES_ZLS_AT_END
protected static final int MATCHES_ZLS_AT_END- See Also:
-
MATCHES_ZLS_ANYWHERE
protected static final int MATCHES_ZLS_ANYWHERE- See Also:
-
MATCHES_ZLS_NEVER
protected static final int MATCHES_ZLS_NEVER- See Also:
-
-
Constructor Details
-
Operation
public Operation()
-
-
Method Details
-
iterateMatches
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_STARTif the expression is statically known to match a zero-length string at the start of the supplied input; - returns
MATCHES_ZLS_AT_ENDif it is statically known to match a zero-length string at the end of the supplied input; - returns
MATCHES_ZLS_ANYWHEREif it is statically known to match a zero-length string anywhere in the input. - returns
MATCHES_ZLS_NEVERif 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)
-
isAssertion
public boolean isAssertion()Ask whether the expression is a zero-width assertion -
isAllowedWithinLookbehind
public boolean isAllowedWithinLookbehind()Ask whether the expression is allowed within a lookbehind -
getInitialCharacterClass
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
Optimize the operation- Parameters:
program- the program being optimizedflags- the regular expression flags- Returns:
- the optimized operation
-
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
-
getMaxLoopingDepth
public int getMaxLoopingDepth()Get the maximum depth of looping within this operation- Returns:
- the maximum number of nested iterations
-