System.out.println("Couldn't get enumValues from:\n" + enumObj);
return;
}
for (String enumValName : al) {
EnumValue ev = new EnumValue(enumValName);
if (byId.get(ev.getId()) != null) {
ResultException ex = new ResultException();
ex.addError("Duplicate enum id: " + ev.getId());
ex.result.lastResult().lineNumber(enumObj.lineNumber);
throw (ex);
}
byId.put(ev.getId(), ev);
if (byName.get(ev.getName()) != null) {
ResultException ex = new ResultException();
ex.addError("Duplicate enum name: " + ev.getName());
ex.result.lastResult().lineNumber(enumObj.lineNumber);
throw (ex);
}
byName.put(ev.getName(), ev);
}
// DebugInfo.debug("Generating: " + od + File.separator + cn + ".java");
// enumClassDef = new BufferedWriter(new FileWriter(od + File.separator
// + cn + ".java"));
enumClassDef = FileUpdateManager.instance().getWriter(od, cn + ".java");
enumClassDef.write(LGPL.toString());
enumClassDef.write("package " + cp + ".generated.enums;\n\n");
enumClassDef.write("import java.util.*;\n\n");
enumClassDef.write("/**\n * The " + cn + " enumeration.\n");
enumClassDef
.write(" * This code was auto-generated by the createmeta utility and shouldn't be alterred\n");
enumClassDef.write(" * manually.\n");
enumClassDef.write(" * Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
enumClassDef.write(" */\n");
enumClassDef.write("public enum " + cn + "\n{\n");
Iterator<EnumValue> enumit = byId.values().iterator();
while (enumit.hasNext()) {
EnumValue ev = enumit.next();
enumClassDef.write(" /**\n");
this.dumpCodeComment(ev.getDescription(), enumClassDef, " * ");
enumClassDef.write(" */\n");
enumClassDef.write(" " + ev.getName() + "(" + ev.getId() + ")");
if (enumit.hasNext())
enumClassDef.write(",\n\n");
else
enumClassDef.write(";\n\n");
}