}
}
void dumpMetaSchema(String od) throws IOException, ResultException {
BufferedWriter out = null;
PrintfFormat pf = null;
// out = new BufferedWriter(new FileWriter(od + "/MetaSchemaAG.java"));
out = FileUpdateManager.instance().getWriter(od, "MetaSchemaAG.java");
// Strip the nameAttribute from all name types so that we don't cause
// problems
// when loading the meta schema
for (DmcUncheckedObject type : typeDefs.values()) {
type.rem("nameAttributeDef");
type.rem("filterAttributeDef");
}
out.write(LGPL.toString());
out.write("package org.dmd.dms;\n\n");
out.write("import org.dmd.dmc.DmcValueException;\n");
out.write("import org.dmd.dms.generated.enums.*;\n");
out.write("\n");
out.write("/**\n");
out.write(" * This class creates the basic definitions that allow for the definition of schemas.\n");
out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
out.write(" */\n");
out.write("abstract public class MetaSchemaAG extends SchemaDefinition {\n");
out.write(" public static SchemaDefinition _metaSchema;\n\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
for (int i = 0; i < origOrderClasses.size(); i++) {
out.write(" public static ClassDefinition _"
+ origOrderClasses.get(i) + ";\n");
}
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
for (int i = 0; i < origOrderEnums.size(); i++)
out.write(" public static EnumDefinition _"
+ origOrderEnums.get(i) + ";\n");
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
for (int i = 0; i < origOrderTypes.size(); i++)
out.write(" public static TypeDefinition _"
+ origOrderTypes.get(i) + ";\n");
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
for (int i = 0; i < origOrderAttrs.size(); i++)
out.write(" public static AttributeDefinition _"
+ origOrderAttrs.get(i) + ";\n");
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
for (int i = 0; i < origOrderCategories.size(); i++)
out.write(" public static RuleCategory _"
+ origOrderCategories.get(i) + ";\n");
out.write("\n");
out.write(" // Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
for (int i = 0; i < origOrderRules.size(); i++)
out.write(" public static RuleDefinition _"
+ origOrderRules.get(i) + ";\n");
out.write("\n");
// METASCHEMA START
out.write(" public MetaSchemaAG() throws DmcValueException {\n\n");
// out.write(" super(\"metaSchema\");\n\n");
// DebugInfo.debug("META SCHEMA NAME CHANGE!!!!");
out.write(" super(\"meta\");\n\n");
out.write(" staticRefName = new String(\"MetaSchema._\");\n\n");
pf = new PrintfFormat("%-28s");
out.write(" // We only ever want to initialize the schema once, so check\n");
out.write(" // to see if we've initialized the first class definition\n");
// START INIT METASCHEMA
out.write(" if (_metaSchema == null){\n");
out.write(" try{\n");
out.write(" _metaSchema = this;\n");
out.write(" // Create the class definitions\n");
out.write(" // Generated from: "
+ DebugInfo.getWhereWeAreNow() + "\n");
for (int i = 0; i < origOrderClasses.size(); i++) {
String defn = origOrderClasses.get(i);
out.write(" _" + pf.sprintf(defn));
out.write("= new ClassDefinition(\"" + defn + "\");\n");
}
out.write("\n");
out.write(" // Create the enum definitions\n");
out.write(" // Generated from: "
+ DebugInfo.getWhereWeAreNow() + "\n");
for (int i = 0; i < origOrderEnums.size(); i++) {
String defn = origOrderEnums.get(i);
out.write(" _" + pf.sprintf(defn));
out.write("= new EnumDefinition(\"" + defn + "\");\n");
}
out.write("\n");
out.write(" // Create the type definitions\n");
out.write(" // Generated from: "
+ DebugInfo.getWhereWeAreNow() + "\n");
for (int i = 0; i < origOrderTypes.size(); i++) {
String defn = origOrderTypes.get(i);
String predefname = origOrderTypes.get(i);
if (predefname.indexOf("Enum") != -1) {
if (predefname.equals("EnumValue")
|| predefname.equals("EnumDefinitionREF")) {
} else
predefname = predefname.replace("REF", "");
// predefname = origOrderTypes.get(i) + "REF";
}
DmcUncheckedObject typeObj = typeDefs.get(defn);
String typeClassName = typeObj.getSV("typeClassName");
String wrapperClassName = typeObj.getSV("wrapperClassName");
out.write(" _" + pf.sprintf(defn));
if (wrapperClassName == null)
out.write("= new TypeDefinition(\"" + predefname + "\", "
+ typeClassName + ".class);\n");
else
out.write("= new TypeDefinition(\"" + predefname + "\", "
+ typeClassName + ".class, " + wrapperClassName
+ ".class);\n");
}
out.write("\n");
out.write(" // Create the attribute definitions\n");
out.write(" // Generated from: "
+ DebugInfo.getWhereWeAreNow() + "\n");
for (int i = 0; i < origOrderAttrs.size(); i++) {
String attrName = origOrderAttrs.get(i);
String mediatorName = null;
DmcUncheckedObject attrDef = attributeDefs.get(attrName);
String typeName = attrDef.getSV("type");
DmcUncheckedObject typeDef = typeDefs.get(typeName);
// If we couldn't find the type by its name, it's because its a
// reference
// to a class or enum, and the actual TypeDefinition name will be
// _<ClassName>Reference
if (typeDef == null) {
mediatorName = typeName + "REF";
} else {
mediatorName = typeName;
}
out.write(" _" + pf.sprintf(attrName));
out.write("= new AttributeDefinition(\"" + attrName + "\", _"
+ mediatorName + ");\n");
}
out.write("\n");
out.write(" // Create the rule category definitions\n");
out.write(" // Generated from: "
+ DebugInfo.getWhereWeAreNow() + "\n");
for (int i = 0; i < origOrderCategories.size(); i++) {
String defn = origOrderCategories.get(i);
out.write(" _" + pf.sprintf(defn));
out.write("= new RuleCategory(\"" + defn + "\");\n");
}
out.write("\n");
out.write(" // Create the rule definitions\n");
out.write(" // Generated from: "
+ DebugInfo.getWhereWeAreNow() + "\n");
for (int i = 0; i < origOrderRules.size(); i++) {
String defn = origOrderRules.get(i);
out.write(" _" + pf.sprintf(defn));
out.write("= new RuleDefinition(\"" + defn + "\");\n");
}
out.write("\n");
// Set the attribute values on all objects