001: package org.drools.compiler;
002:
003: import java.util.List;
004: import java.util.Map;
005:
006: import org.drools.base.ClassFieldExtractorCache;
007: import org.drools.base.TypeResolver;
008: import org.drools.lang.descr.BaseDescr;
009: import org.drools.lang.descr.FunctionDescr;
010: import org.drools.lang.descr.RuleDescr;
011: import org.drools.rule.Package;
012: import org.drools.rule.builder.AccumulateBuilder;
013: import org.drools.rule.builder.ConsequenceBuilder;
014: import org.drools.rule.builder.FromBuilder;
015: import org.drools.rule.builder.PatternBuilder;
016: import org.drools.rule.builder.PredicateBuilder;
017: import org.drools.rule.builder.QueryBuilder;
018: import org.drools.rule.builder.ReturnValueBuilder;
019: import org.drools.rule.builder.RuleBuildContext;
020: import org.drools.rule.builder.RuleClassBuilder;
021: import org.drools.rule.builder.RuleConditionBuilder;
022: import org.drools.rule.builder.SalienceBuilder;
023:
024: /**
025: * A Dialect implementation handles the building and execution of code expressions and blocks for a rule.
026: * This api is considered unstable, and subject to change. Those wishing to implement their own dialects
027: * should look ove the MVEL and Java dialect implementations.
028: *
029: */
030: public interface Dialect {
031: String getId();
032:
033: void init(PackageBuilder builder);
034:
035: // this is needed because some dialects use other dialects
036: // to build complex expressions. Example: java dialect uses MVEL
037: // to execute complex expressions
038: String getExpressionDialectName();
039:
040: Map getBuilders();
041:
042: TypeResolver getTypeResolver();
043:
044: ClassFieldExtractorCache getClassFieldExtractorCache();
045:
046: SalienceBuilder getSalienceBuilder();
047:
048: PatternBuilder getPatternBuilder();
049:
050: QueryBuilder getQueryBuilder();
051:
052: RuleConditionBuilder getEvalBuilder();
053:
054: AccumulateBuilder getAccumulateBuilder();
055:
056: PredicateBuilder getPredicateBuilder();
057:
058: ReturnValueBuilder getReturnValueBuilder();
059:
060: ConsequenceBuilder getConsequenceBuilder();
061:
062: RuleClassBuilder getRuleClassBuilder();
063:
064: FromBuilder getFromBuilder();
065:
066: RuleConditionBuilder getBuilder(Class clazz);
067:
068: AnalysisResult analyzeExpression(final RuleBuildContext context,
069: final BaseDescr descr, final Object content);
070:
071: AnalysisResult analyzeBlock(final RuleBuildContext context,
072: final BaseDescr descr, final String text);
073:
074: void compileAll();
075:
076: void addRule(final RuleBuildContext context);
077:
078: void addFunction(final FunctionDescr functionDescr,
079: TypeResolver typeResolver);
080:
081: public void addImport(String importEntry);
082:
083: public void addStaticImport(String importEntry);
084:
085: List getResults();
086:
087: void init(Package pkg);
088:
089: void init(RuleDescr ruleDescr);
090:
091: /**
092: * An interface with the results from the expression/block analysis
093: *
094: * @author etirelli
095: */
096: public static interface AnalysisResult {
097:
098: /**
099: * Returns the list<String> of all used identifiers
100: * @return
101: */
102: public List getIdentifiers();
103:
104: /**
105: * Returns the array of lists<String> of bound identifiers
106: * @return
107: */
108: public List[] getBoundIdentifiers();
109:
110: /**
111: * Returns the list<String> of not bounded identifiers
112: * @return
113: */
114: public List getNotBoundedIdentifiers();
115:
116: /**
117: * Returns the list<String> of declared local variables
118: *
119: * @return
120: */
121: public List getLocalVariables();
122:
123: }
124:
125: }
|