public void ruleHandler(RuleDescr ruleDescr) { setModuleName(ruleDescr); PackageDescr pkg = createPackageDescr(ruleDescr.getNamespace()); pkg.addRule(ruleDescr); this.packageBuilder.addPackage(pkg); this.session.fireAllRules(); }
public void templateHandler(TypeDeclarationDescr typeDescr) { setModuleName(typeDescr); PackageDescr pkg = createPackageDescr(typeDescr.getNamespace()); pkg.addTypeDeclaration(typeDescr); this.packageBuilder.addPackage(pkg); }
public void functionHandler(FunctionDescr functionDescr) { // for now all functions are in MAIN // setModuleName( functionDescr ); functionDescr.setNamespace("MAIN"); Appendable builder = new StringBuilderAppendable(); // strip lead/trailing quotes String name = functionDescr.getName().trim(); if (name.charAt(0) == '"') { name = name.substring(1); } if (name.charAt(name.length() - 1) == '"') { name = name.substring(0, name.length() - 1); } builder.append("function " + name + "("); for (int i = 0, length = functionDescr.getParameterNames().size(); i < length; i++) { builder.append(functionDescr.getParameterNames().get(i)); if (i < length - 1) { builder.append(", "); } } builder.append(") {\n"); // TODO: fix this // List list = (List) functionDescr.getBody(); // for ( Iterator it = list.iterator(); it.hasNext(); ) { // FunctionHandlers.dump( (LispForm) it.next(), // builder, // true ); // } builder.append("}"); System.out.println("mvel expr:" + builder.toString()); functionDescr.setText(builder.toString()); functionDescr.setDialect("clips"); PackageDescr pkgDescr = createPackageDescr(functionDescr.getNamespace()); pkgDescr.addFunction(functionDescr); this.packageBuilder.addPackage(pkgDescr); }
public void visitPackageDescr(final PackageDescr packageDescr) { final String packageName = packageDescr.getName(); final String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " + XmlDumper.eol + " <package name=\"" + packageName + "\" " + XmlDumper.eol + "\txmlns=\"http://drools.org/drools-3.0\" " + XmlDumper.eol + "\txmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\" " + XmlDumper.eol + "\txs:schemaLocation=\"http://drools.org/drools-3.0 drools-3.0.xsd\"> " + XmlDumper.eol; appendXmlDump(xmlString); appendXmlDump(processImportsList(packageDescr.getImports())); appendXmlDump(processGlobalsMap(packageDescr.getGlobals())); appendXmlDump(processFunctionsList(packageDescr.getFunctions())); appendXmlDump(processRules(packageDescr.getRules())); appendXmlDump("</package>"); }
private PackageDescr createPackageDescr(String moduleName) { PackageDescr pkg = new PackageDescr(moduleName); pkg.addAttribute(new AttributeDescr("dialect", "clips")); return pkg; }
public void importHandler(ImportDescr descr) { // use the current focus as the default namespace for these imports PackageDescr pkgDescr = createPackageDescr(this.session.getAgenda().getFocusName()); pkgDescr.addImport(descr); this.packageBuilder.addPackage(pkgDescr); }