public abstract class AbstractEplModule extends ErlModule implements IEplModule
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
AbstractEplModule.LazyAdvancedRoleInstancesInitializer |
protected static interface |
AbstractEplModule.LazyBasicRoleInstancesInitializer |
| Modifier and Type | Field and Description |
|---|---|
protected ArrayList<Pattern> |
declaredPatterns |
static int |
INFINITE |
protected int |
maxLoops |
protected String |
patternMatchModelName |
protected List<Pattern> |
patterns |
protected boolean |
repeatWhileMatchesFound |
declaredPost, declaredPre, post, precompilationContext, context, declaredModelDeclarations, declaredOperations, imports, main, modelDeclarations, operations, postOperationStatementsparseProblems, parser, sourceFile, sourceUri| Constructor and Description |
|---|
AbstractEplModule() |
AbstractEplModule(IEplContext context) |
| Modifier and Type | Method and Description |
|---|---|
ModuleElement |
adapt(AST cst,
ModuleElement parentAst) |
void |
build(AST cst,
IModule module) |
protected org.antlr.runtime.Lexer |
createLexer(org.antlr.runtime.ANTLRInputStream inputStream) |
protected PatternMatchModel |
createModel()
PatternMatchModel factory method.
|
EpsilonParser |
createParser(org.antlr.runtime.TokenStream tokenStream) |
protected PatternMatch |
createPatternMatch(Pattern pattern,
Collection<? extends Iterable<?>> combination)
Converts all roles of the pattern into a PatternMatch with the specified bindings.
|
protected Object |
executeDoBlock(ExecutableBlock<?> doBlock,
Map<String,Object> roleBindings)
Executes the do block with the specified variables.
|
protected Collection<?> |
filterElements(ExecutableBlock<Boolean> guard,
String roleName,
Collection<?> currentInstances)
Executes the guard block when called by
getAllRoleInstances(Role, String, Collection) |
protected static Collection<Variable> |
flatMapRoleBindings(Collection<Role> roles,
Collection<? extends Iterable<?>> combination)
This method simply flatmaps the results of calling getVariables(Iterable, Role)
for each role in the pattern.
|
protected abstract Iterator<? extends Collection<? extends Iterable<?>>> |
getCandidates(Pattern pattern)
The dimensions of the returned nested Iterables are as follows:
Outer: The number of roles in the pattern (i.e. |
IEplContext |
getContext() |
List<Pattern> |
getDeclaredPatterns() |
HashMap<String,Class<?>> |
getImportConfiguration() |
String |
getMainRule() |
protected boolean |
getMatchResult(Pattern pattern)
Gets the result of the match block for the specified pattern.
|
int |
getMaxLoops() |
List<Pattern> |
getPatterns() |
protected Collection<?> |
getRoleInstances(Role role,
String roleName)
Executes the role, returning applicable model elements which satisfy the conditions specified
in the role.
|
protected static Collection<Variable> |
getVariables(Iterable<?> bindings,
Role role)
Binds role names to the objects returned by the bindings iterator.
|
boolean |
isRepeatWhileMatches() |
protected boolean |
isValidCombination(Pattern pattern,
List<? extends Iterable<?>> combination)
Validates whether the given combination matches the constraints imposed by the pattern.
|
Collection<PatternMatch> |
match(Pattern pattern)
This method provides the main high-level execution logic for EPL.
|
protected Optional<PatternMatch> |
matchCombination(Collection<? extends Iterable<?>> combination,
Pattern pattern)
Executes the match, onmatch and/or nomatch blocks.
|
PatternMatchModel |
matchPatterns() |
protected Set<PatternMatch> |
matchPatterns(int level,
PatternMatchModel model)
Adds all matches returned by
IEplModule#match() to the match model
for all patterns at the specified level. |
protected boolean |
negativeGuard(ExecutableBlock<Boolean> guard,
String roleName,
Collection<?> currentInstances)
Executes the guard block when called by
getNegativeRoleInstances(Role, String, Collection) |
protected void |
postProcessMatches(int level,
Collection<PatternMatch> matches)
Executes the do block for all matched patterns at the specified level.
|
protected void |
preMatch(PatternMatchModel model)
Pre-processes the model.
|
protected Object |
processRules()
Main rule processing logic.
|
protected static int |
putRoleBindingsIntoFrame(Collection<Role> roles,
Collection<? extends Iterable<?>> combination,
Frame frame)
Puts the result of
#flatMapRoleBindings(Pattern, Collection) into the frame. |
void |
setMaxLoops(int maxLoops) |
void |
setRepeatWhileMatches(boolean repeatWhileMatches) |
protected abstract Collection<?> |
wrapAdvancedRoleInstances(Role role,
String roleName,
Collection<?> currentInstances,
AbstractEplModule.LazyAdvancedRoleInstancesInitializer initializer) |
protected abstract Collection<?> |
wrapBasicRoleInstances(Role role,
String roleName,
AbstractEplModule.LazyBasicRoleInstancesInitializer initializer)
Wraps the result of
preprocessRoleInstances(Role, String) into the specified collection. |
calculateSuperRules, execute, execute, executeImpl, getDeclaredPost, getDeclaredPre, getPost, getPre, postExecution, prepareExecutioncheckImports, clearCache, compile, execute, getCompilationContext, getDeclaredModelDeclarations, getDeclaredOperations, getImports, getImportsByExtension, getMain, getModelDelcarations, getOperations, getParentModule, getPostOperationStatements, prepareContext, setContext, setMain, setParentModule, toStringassignAnnotations, assignComment, assignComments, createAst, extractComments, getParseProblems, getSourceFile, getSourceUri, invokeMainRule, parse, parseequals, getChildren, getComments, getDebugInfo, getFile, getModule, getParent, getRegion, getUri, hashCode, setModule, setParent, setRegion, setUriclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetMaximumLevelgetDeclaredPost, getDeclaredPre, getPost, getPreconfigure, execute, getCompilationContext, getConfigurationProperties, getDeclaredModelDeclarations, getDeclaredOperations, getImports, getMain, getModelDelcarations, getOperations, getParentModule, getParseProblems, getPostOperationStatements, parse, setContext, setParentModulepublic static final int INFINITE
protected boolean repeatWhileMatchesFound
protected int maxLoops
protected String patternMatchModelName
public AbstractEplModule()
public AbstractEplModule(IEplContext context)
public IEplContext getContext()
getContext in interface IEolModulegetContext in interface IErlModulegetContext in class ErlModuleprotected org.antlr.runtime.Lexer createLexer(org.antlr.runtime.ANTLRInputStream inputStream)
createLexer in class ErlModulepublic EpsilonParser createParser(org.antlr.runtime.TokenStream tokenStream)
createParser in class ErlModulepublic String getMainRule()
getMainRule in class ErlModulepublic HashMap<String,Class<?>> getImportConfiguration()
getImportConfiguration in class ErlModulepublic ModuleElement adapt(AST cst, ModuleElement parentAst)
public void build(AST cst, IModule module)
build in interface ModuleElementbuild in class ErlModuleprotected Object processRules() throws EolRuntimeException
ErlModuleprocessRules in class ErlModuleEolRuntimeExceptionpublic List<Pattern> getDeclaredPatterns()
getDeclaredPatterns in interface IEplModulepublic List<Pattern> getPatterns()
getPatterns in interface IEplModulepublic int getMaxLoops()
getMaxLoops in interface IEplModulepublic void setMaxLoops(int maxLoops)
setMaxLoops in interface IEplModulepublic boolean isRepeatWhileMatches()
isRepeatWhileMatches in interface IEplModulepublic void setRepeatWhileMatches(boolean repeatWhileMatches)
setRepeatWhileMatches in interface IEplModulepublic final PatternMatchModel matchPatterns() throws EolRuntimeException
matchPatterns in interface IEplModuleEolRuntimeExceptionpublic Collection<PatternMatch> match(Pattern pattern) throws EolRuntimeException
matchPatterns(int, PatternMatchModel)) and the low-level ones (e.g.
getRoleInstances(Role, String)). matchCombination(Collection, Pattern), and so the sole responsibility
of this method is to loop through the combinations returned by getCandidates(Pattern)
and collect all the results. Subclasses may override this method to alter the type of collection
returned and/or alter the looping mechanism.match in interface IEplModuleEolRuntimeExceptionprotected final Optional<PatternMatch> matchCombination(Collection<? extends Iterable<?>> combination, Pattern pattern) throws EolRuntimeException
combination - The values to use for role bindings.pattern - EolRuntimeExceptionprotected PatternMatchModel createModel() throws EolRuntimeException
EolRuntimeExceptionprotected void preMatch(PatternMatchModel model) throws EolRuntimeException
EolRuntimeExceptionprotected Set<PatternMatch> matchPatterns(int level, PatternMatchModel model) throws EolRuntimeException
IEplModule#match() to the match model
for all patterns at the specified level.EolRuntimeExceptionprotected final void postProcessMatches(int level,
Collection<PatternMatch> matches)
throws EolRuntimeException
executeDoBlock(ExecutableBlock, Map) method.EolRuntimeExceptionprotected Object executeDoBlock(ExecutableBlock<?> doBlock, Map<String,Object> roleBindings) throws EolRuntimeException
doBlock - The block to execute.roleBindings - The effective collection of variables.null.EolRuntimeExceptionprotected final boolean getMatchResult(Pattern pattern) throws EolRuntimeException
pattern - the pattern being executedcontext - the contexttrue
if the pattern does not define a match block.EolRuntimeException - if the result is not a boolean.protected PatternMatch createPatternMatch(Pattern pattern, Collection<? extends Iterable<?>> combination)
#flatMapRoleBindings(Pattern, Iterable)protected static final Collection<Variable> flatMapRoleBindings(Collection<Role> roles, Collection<? extends Iterable<?>> combination)
pattern.getRoles()
and combination collections first.roles - The roles of a pattern.combination - The instances for each binding. Note that the inner iterable's size must
be equal to the number of names in the role. However the outer size (that is,
combination.size()) need not necessarily be equal to the number of roles in the pattern.protected static Collection<Variable> getVariables(Iterable<?> bindings, Role role)
bindings - The elements to map to each role name. Note that the number
of objects returned by the iterator must be equal to the number of role names.role - protected static final int putRoleBindingsIntoFrame(Collection<Role> roles, Collection<? extends Iterable<?>> combination, Frame frame)
#flatMapRoleBindings(Pattern, Collection) into the frame.roles - combinations - frame - protected boolean isValidCombination(Pattern pattern, List<? extends Iterable<?>> combination) throws EolRuntimeException
pattern - combination - EolRuntimeExceptionprotected abstract Iterator<? extends Collection<? extends Iterable<?>>> getCandidates(Pattern pattern) throws EolRuntimeException
pattern.getRoles().size())
RoleExecutor#getRoleInstances(Role, String) multiplied by
the number of names for that role (i.e. getRoleInstances(role).size()*role.getNames().size()).
pattern - EolRuntimeExceptionprotected final Collection<?> getRoleInstances(Role role, String roleName) throws EolRuntimeException
#negativeGuard(ExecutableBlock, Collection)
and/or #filterElements(ExecutableBlock, Collection) methods as these involve executing guard
blocks for each element. If even greater control is desired (e.g. to change the return type of the
collection), subclasses can override the intermediate methods, which are:
role - roleName - The name to which instances will be bound when executing the guard block. This
will always come from role.getNames()EolRuntimeExceptionprotected abstract Collection<?> wrapBasicRoleInstances(Role role, String roleName, AbstractEplModule.LazyBasicRoleInstancesInitializer initializer) throws EolRuntimeException
preprocessRoleInstances(Role, String) into the specified collection.role - roleName - initializer - Method reference to preprocessRoleInstances(Role, String).EolRuntimeExceptionprotected abstract Collection<?> wrapAdvancedRoleInstances(Role role, String roleName, Collection<?> currentInstances, AbstractEplModule.LazyAdvancedRoleInstancesInitializer initializer) throws EolRuntimeException
role - roleName - currentInstances - The values returned from wrapBasicRoleInstances(Role, String, LazyBasicRoleInstancesInitializer).initializer - Method reference to getNegativeRoleInstances(Role, String, Collection)
or getAllRoleInstances(Role, String, Collection).EolRuntimeExceptionprotected boolean negativeGuard(ExecutableBlock<Boolean> guard, String roleName, Collection<?> currentInstances) throws EolRuntimeException
getNegativeRoleInstances(Role, String, Collection)guard - currentInstances - The model elements of the negative role.EolRuntimeExceptionprotected Collection<?> filterElements(ExecutableBlock<Boolean> guard, String roleName, Collection<?> currentInstances) throws EolRuntimeException
getAllRoleInstances(Role, String, Collection)guard - currentInstances - The model elements of the role.EolRuntimeExceptionCopyright © 2020. All rights reserved.