Package eu.bandm.tools.paisley
Class Unary<A,B>
java.lang.Object
eu.bandm.tools.paisley.Pattern<B>
eu.bandm.tools.paisley.Unary<A,B>
- Type Parameters:
A
- the target type of the contained subpatternB
- the target type of the containing pattern
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
FlatMultiTransform
,Proxy
,Transform
Abstract base class for patterns that contain one subpattern.
Methods have default implementations that delegate to the
subpattern.
Subclasses must implement the Pattern.match(A)
method.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.paisley.Pattern
Pattern.Either<A>
-
Field Summary
Fields inherited from class eu.bandm.tools.paisley.Pattern
_left_matched, _target_save, none
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether a variable is bound by this pattern.void
clear
(boolean recursively) Disposes of all internal state related to results and nondeterminism.clone()
Makes a matching-state copy if this pattern.protected void
compileClear
(CompilationContext context, boolean recursively) protected void
compileCut
(CompilationContext context, boolean recursively) void
cut
(boolean recursively) Disposes of all internal state related to nondeterminism.getBody()
boolean
Checks whether this pattern is deterministic.boolean
Attempts to re-match this pattern against a previously matched object.boolean
Checks whether a variable is preserved by this pattern, unconditionally.boolean
Checks whether a variable is preserved by this pattern, conditionally on success or failure.protected void
toString()
Methods inherited from class eu.bandm.tools.paisley.Pattern
all, all, all, all, all, and, andThen, andThen, any, aside, both, clear, compile, compileClear, compileCut, compileIsDeterministic, compileMatch, compileMatchAgain, compileSubPattern, compileThis, compileUpTo, cut, DEBUG, either, enPassant, flatten, limit, main, match, matchOnce, matchVar, narrow, newAll, noMatch, none, of, or, orElse, orElse, repeat, some, some, some, some, someMatch, startCompile, uniquely, variable, variable
-
Constructor Details
-
Unary
Creates a new pattern.- Parameters:
body
-- Throws:
IllegalArgumentException
- ifbody
isnull
.
-
Unary
protected Unary()
-
-
Method Details
-
getBody
-
setBody
-
clone
Description copied from class:Pattern
Makes a matching-state copy if this pattern.Subclasses must override this method if necessary to honour the following rules for all transitively reachable patterns:
- Subpatterns that are instances of
Variable
must be shared. This implies thatVariable.clone()
must returnthis
. - Fields that do not refer to
subpatterns, but to matching state (changed by invocations of
Pattern.match(A)
,Pattern.matchAgain()
,Pattern.cut()
orPattern.clear()
) must be duplicated. If matching state changes are effected by modification of other objects, these must be duplicated. In summary, matching operations on this pattern and its copy must not interfere, with the exception of variable bindings. - Fields neither referring to subpatterns nor to matching state may be either shared or duplicated. The usage of such fields in a modifiable way (such that the distinction is relevant) is strongly deprecated.
- Patterns whose
fields need not be duplicated need not be duplicated themselves,
but may return
this
.
- Subpatterns that are instances of
-
matchAgain
public boolean matchAgain()Description copied from class:Pattern
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()
.- Overrides:
matchAgain
in classPattern<B>
- Returns:
true
if the matching is successful,false
if it fails. WhichVariable
s are bound by a successful match depends. The default implementation always returnsfalse
.- See Also:
-
cut
public void cut(boolean recursively) Description copied from class:Pattern
Disposes of all 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)
. -
clear
public void clear(boolean recursively) Description copied from class:Pattern
Disposes of all internal state related to results and nondeterminism.The default implementation does nothing.
-
binds
Description copied from class:Pattern
Checks whether a variable is bound by this pattern.The default implementation returns
false
. -
preserves
Description copied from class:Pattern
Checks whether a variable is preserved by this pattern, conditionally on success or failure.The default implementation returns
false
. -
preserves
Description copied from class:Pattern
Checks whether a variable is preserved by this pattern, unconditionally.The default implementation returns
false
. -
isDeterministic
public boolean isDeterministic()Description copied from class:Pattern
Checks whether this pattern is deterministic.The default implementation returns
true
.- Overrides:
isDeterministic
in classPattern<B>
- Returns:
true
if this pattern is guaranteed to match any object at most once,false
otherwise.- See Also:
-
toString
-
compileCut
- Overrides:
compileCut
in classPattern<B>
-
compileClear
- Overrides:
compileClear
in classPattern<B>
-