JavaMethodGenerator methodGenerator = JavaMethodGenerator.getInstance();
JavaInvokerGenerator invokerGenerator = JavaInvokerGenerator.getInstance();
SemanticRule component = null;
SemanticCondition condition = null;
SemanticConsequence consequence = null;
/* needs to be LinkedHashSet() to ensure the order is the same */
Set usedApplicationData = new LinkedHashSet();
List methods = new ArrayList();
List invokers = new ArrayList();
for ( int i = 0; i < components.length; i++ )
{
usedApplicationData.clear();
component = (SemanticRule) components[i];
if ( component instanceof Condition )
{
condition = (SemanticCondition) component;
StringBuffer conditionBuffer = methodGenerator.generateMethod( condition.getName(),
"boolean",
condition.getThrownException(),
condition.getText(),
imports,
usedApplicationData,
null,
applicationData,
((Condition) condition).getRequiredTupleMembers(),
4 );
String name = condition.getName();
StringBuffer invokerBuffer = invokerGenerator.generateInvoker( className,
name.toUpperCase().charAt( 0 ) + name.substring( 1 ),
name,
"boolean",
null,
applicationData,
usedApplicationData,
((Condition) condition).getRequiredTupleMembers(),
4 );
methods.add( conditionBuffer );
invokers.add( invokerBuffer );
}
else if ( component instanceof Consequence )
{
consequence = (SemanticConsequence) component;
String name = consequence.getName();
StringBuffer consequenceBuffer = methodGenerator.generateMethod( consequence.getName(),
"void",
consequence.getThrownException(),
consequence.getText(),
imports,
usedApplicationData,
knowledgeHelper,
applicationData,
declarations,