@Override protected void marshalRuleHeader(final RuleModel model, final StringBuilder buf) { //Append Template header TemplateModel templateModel = (TemplateModel) model; buf.append("template header\n"); InterpolationVariable[] interpolationVariables = templateModel.getInterpolationVariablesList(); if (interpolationVariables.length == 0) { buf.append("test_var").append('\n'); } else { for (InterpolationVariable var : interpolationVariables) { buf.append(var.getVarName()).append('\n'); } } buf.append("\n"); //Append Package header super.marshalPackageHeader(model, buf); //Append Template definition buf.append("\ntemplate \"").append(super.marshalRuleName(templateModel)).append("\"\n\n"); super.marshalRuleHeader(model, buf); }
protected String marshalRule(final RuleModel model) { boolean isDSLEnhanced = model.hasDSLSentences(); bindingsPatterns = new HashMap<String, IFactPattern>(); bindingsFields = new HashMap<String, FieldConstraint>(); fixActionInsertFactBindings(model.rhs); StringBuilder buf = new StringBuilder(); //Build rule this.marshalPackageHeader(model, buf); this.marshalRuleHeader(model, buf); this.marshalMetadata(buf, model); this.marshalAttributes(buf, model); buf.append("\twhen\n"); this.marshalLHS(buf, model, isDSLEnhanced, new LHSGeneratorContextFactory()); buf.append("\tthen\n"); this.marshalRHS(buf, model, isDSLEnhanced, new RHSGeneratorContextFactory()); this.marshalFooter(buf); return buf.toString(); }