if (ruleType.equals("ATTRIBUTE"))
isAttributeRule = true;
NamedStringArray categories = category.get("ruleParam");
ImportManager baseImports = new ImportManager();
baseImports.addImport("org.dmd.dmc.rules.DmcRuleExceptionSet", "Rule type");
baseImports.addImport("org.dmd.dmc.rules.RuleIF", "All rules implement this");
StringBuffer params = new StringBuffer();
StringBuffer args = new StringBuffer();
StringBuffer argValues = new StringBuffer();
boolean first = true;
for(String p : categories){
RuleParam param;
try {
param = new RuleParam(p);
baseImports.addImport(param.getImportStatement(), "Required for " + param.getName());
int lastDot = param.getImportStatement().lastIndexOf(".");
String ptype = param.getImportStatement().substring(lastDot + 1);
if (!first){
// params.append(", ");
args.append(", ");
argValues.append(", ");
}
params.append(" * @param " + param.getName() + " " + param.getDescription() + "\n");
args.append(ptype + param.getGenericArgs() + " " + param.getName());
argValues.append(param.getName());
first = false;
} catch (DmcValueException e) {
System.err.println(e.toString());
e.printStackTrace();
System.err.println(category.toOIF());
System.exit(1);
}
}
BufferedWriter out = FileUpdateManager.instance().getWriter(rulesDir, name + "IF.java");
out.write("package " + schemaPackage + ".generated.rulesdmo;\n\n");
out.write(baseImports.getFormattedImports() + "\n\n");
out.write("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
out.write("public interface " + name + "IF extends RuleIF {\n\n");
out.write(" /**\n");
out.write(params.toString());
out.write(" */\n");
out.write(" public void execute(" + args + ") throws DmcRuleExceptionSet;\n\n");
out.write("}\n\n");
out.close();
///////////////////////////////////////////////////////////////////
// baseImports = new ImportManager();
baseImports.addImport("org.dmd.dmc.rules.DmcRuleExceptionSet", "Rule type");
baseImports.addImport("org.dmd.dmc.rules.RuleIF", "All rules implement this");
// baseImports.addImport("org.dmd.dmc.rules.RuleList", "Rules with flag to indicate that we've gathered info up the class hierarchy");
// baseImports.addImport("org.dmd.dms.generated.enums.RuleTypeEnum", "To determine the type of a rule");
// baseImports.addImport("org.dmd.dmc.rules.ClassRuleKey", "To determine the type of a rule");
// baseImports.addImport("org.dmd.dmc.rules.AttributeRuleKey", "To determine the type of a rule");
baseImports.addImport("java.util.ArrayList", "Storage for the rules");
// baseImports.addImport("java.util.TreeMap", "Storage for the rules");
// baseImports.addImport("org.dmd.dmc.rules.RuleKey", "Generic rule key");
baseImports.addImport("org.dmd.dmc.DmcOmni", "Rule tracing support");
baseImports.addImport("org.dmd.dmc.DmcClassInfo", "Handle to class info");
if (ruleImports != null){
for(String ri: ruleImports)
baseImports.addImport(ri, "Additional rule import");
}
if (isAttributeRule){
baseImports.addImport("org.dmd.dmc.rules.AttributeRuleCollection", "Attribute rule");
baseImports.addImport("org.dmd.dmc.DmcAttributeInfo", "Organizing global attribute rules");
// baseImports.addImport("java.util.HashMap", "Storage for the rules");
}
else
baseImports.addImport("org.dmd.dmc.rules.ClassRuleCollection", "Class rule");
out = FileUpdateManager.instance().getWriter(rulesDir, name + "RuleCollection.java");
out.write("package " + schemaPackage + ".generated.rulesdmo;\n\n");
out.write(baseImports.getFormattedImports() + "\n");
if (isAttributeRule){
out.write("public class " + name + "RuleCollection extends AttributeRuleCollection<" + name + "IF> {" + "\n\n");
out.write(" public " + name + "RuleCollection(){\n");
// out.write(" globalRules = new HashMap<DmcAttributeInfo, ArrayList<" + name + "IF>>();\n");