Class Both.NoBacktrack<A>
- Type Parameters:
A- the target type of objects to match against
- All Implemented Interfaces:
Pattern<A>,Serializable,Cloneable
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.paisley.Both
Both.Backtrack<A>, Both.NoBacktrack<A> -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionNoBacktrack(Pattern<? super A> left, Pattern<? super A> right) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcut(boolean recursively) Disposes of all temporary internal state related to nondeterminism.booleanChecks whether this pattern is deterministic.booleanAttempts to match this pattern against a given object.booleanAttempts to re-match this pattern against a previously matched object.Methods inherited from class eu.bandm.tools.paisley.Binary
clear, fork, getLeft, getRight, toString, toStringOperatorMethods inherited from class eu.bandm.tools.paisley.AbstractPattern
clone, doclone
-
Constructor Details
-
NoBacktrack
Creates a new instance.The left subpattern must be deterministic.
- Parameters:
left- the deterministic left subpatternright- the right subpattern- Throws:
NullPointerException- ifleftorrightis null
-
-
Method Details
-
match
Attempts to match this pattern against a given object.If the class of this pattern imposes a specific order on matches, the first one is chosen.
The
nulltarget is generally allowed.- Parameters:
target- the object to match against- Returns:
trueif the matching is successful,falseif it fails. WhichVariables are bound by a successful or failed match depends.- See Also:
-
matchAgain
public boolean matchAgain()Attempts to re-match this pattern against a previously matched object.If the class of this pattern imposes a specific order on matches, they are chosen in that order, beginning with the second one. The behaviour of this method is unspecified if the last matching attempt of this pattern has not been successful.
Patterns classes that do not override this method are deterministic. Pattern classes that overwrite this method to provide additional matches should also override
Pattern.isDeterministic().- Returns:
trueif the matching is successful,falseif it fails. WhichVariables are bound by a successful match depends. The default implementation always returnsfalse.- See Also:
-
cut
public void cut(boolean recursively) Disposes of all temporary internal state related to nondeterminism.The default implementation does nothing. Subclasses that override this method should also override
Pattern.clear(boolean)and ensure that it implies the effect ofcut(false).This implementation delegates to
leftandrightifrecursivelyistrue. -
isDeterministic
public boolean isDeterministic()Checks whether this pattern is deterministic.The default implementation returns
false.- Returns:
trueif this pattern is guaranteed to match any object at most once,falseotherwise.- See Also:
-