public class PatternMatcher
extends java.lang.Object
| Constructor and Description |
|---|
PatternMatcher(Pattern pattern) |
| Modifier and Type | Method and Description |
|---|---|
<T> java.util.Set<T> |
findAll(PatternObject patternObject)
Retrieves the matches for the given pattern object.
|
<T> T |
findOne(PatternObject patternObject)
Attempts to retrieve exactly one unique match for the given pattern object.
|
java.util.List<DebugEvent> |
getDebugEvents() |
ObjectTable |
getMatchTable(PatternObject pattern) |
java.util.LinkedHashMap<PatternObject,ObjectTable> |
getObject2TableMap()
Deprecated.
since 1.2; for internal use only
|
java.util.List<java.lang.Object> |
getRootObjects() |
java.util.List<PatternObject> |
getRootPatternObjects() |
boolean |
isDebugLogging() |
void |
match()
Matches the pattern against the structure of objects that can be discovered from the root objects
|
ObjectTable |
match(PatternObject rootPatternObject,
java.lang.Object... rootObjects)
Matches the pattern against the structure of objects that can be discovered from the root objects,
and returns the table of matched values corresponding to the given pattern object.
|
ObjectTable |
match(java.lang.String rootPatternObjectName,
java.lang.Object... rootObjects)
Matches the pattern against the structure of objects that can be discovered from the root objects,
and returns the table of matched values corresponding to the named pattern object.
|
void |
setDebugLogging(boolean eventLogging) |
PatternMatcher |
withRootObjects(java.util.Collection<?> objects) |
PatternMatcher |
withRootObjects(java.lang.Object... objects) |
PatternMatcher |
withRootObjects(java.lang.Object object) |
PatternMatcher |
withRootPatternObjects(java.util.Collection<? extends PatternObject> patternObjects) |
PatternMatcher |
withRootPatternObjects(PatternObject... patternObjects) |
PatternMatcher |
withRootPatternObjects(PatternObject patternObject) |
public PatternMatcher(Pattern pattern)
pattern - the pattern@Deprecated public java.util.LinkedHashMap<PatternObject,ObjectTable> getObject2TableMap()
public boolean isDebugLogging()
true if debug logging is enabledpublic void setDebugLogging(boolean eventLogging)
eventLogging - determines whether debug logging is on (true) or off (false)public java.util.List<DebugEvent> getDebugEvents()
match() or its variants have not been called yet.public java.util.List<PatternObject> getRootPatternObjects()
public PatternMatcher withRootPatternObjects(PatternObject patternObject)
patternObject - the root pattern object to addpublic PatternMatcher withRootPatternObjects(PatternObject... patternObjects)
patternObjects - the root pattern objects to addpublic PatternMatcher withRootPatternObjects(java.util.Collection<? extends PatternObject> patternObjects)
patternObjects - the root pattern objects to addpublic java.util.List<java.lang.Object> getRootObjects()
public PatternMatcher withRootObjects(java.lang.Object object)
object - the root object to addpublic PatternMatcher withRootObjects(java.lang.Object... objects)
objects - the root objects to addpublic PatternMatcher withRootObjects(java.util.Collection<?> objects)
objects - the root objects to addpublic ObjectTable match(java.lang.String rootPatternObjectName, java.lang.Object... rootObjects)
Equivalent to:
this.match(pattern.getObject(rootPatternObjectName), rootObjects);
rootPatternObjectName - the name of the root pattern object, and for which the results are requested forrootObjects - the root objects for object structure discoveryNoApplicableConstraintException - if there were unmatched constraints, possibly due to disconnected pattern objectsmatch(PatternObject, Object...)public ObjectTable match(PatternObject rootPatternObject, java.lang.Object... rootObjects)
Equivalent to:
this.withRootPatternObjects(rootPatternObject);
this.withRootObjects(rootObjects);
this.match();
return this.getMatchTable(rootPatternObject);
rootPatternObject - the root pattern object, and for which the results are requested forrootObjects - the root objects for object structure discoveryNoApplicableConstraintException - if there were unmatched constraints, possibly due to disconnected pattern objectspublic void match()
NoApplicableConstraintException - if there were unmatched constraints, possibly due to disconnected pattern objectspublic ObjectTable getMatchTable(PatternObject pattern)
pattern - the pattern objectnull if the pattern object was not reachedpublic <T> T findOne(PatternObject patternObject)
match() or its variants.T - the expected type of the resultpatternObject - the pattern object results are requested forNoMatchException - if no objects matchAmbiguousMatchException - if more than one distinct objects matchpublic <T> java.util.Set<T> findAll(PatternObject patternObject)
match() or its variants.T - the expected type of the resultspatternObject - the pattern object results are requested for