* @param od
* @throws IOException
* @throws ResultException
*/
private void dumpDmcTypes(String od) throws IOException, ResultException {
DmcUncheckedObject go;
String cn;
for (int i = 0; i < origOrderClasses.size(); i++) {
go = (DmcUncheckedObject) classDefs.get(origOrderClasses.get(i));
// System.out.prdumpEnumClintln("*** Formatting DmcAttribute for: "
// + origOrderClasses.get(i));
if ((cn = go.getSV("name")) == null) {
System.out.println("Couldn't get name for class definition:\n"
+ go);
} else {
// We only generate the type ref for objects that are named -
// otherwise,
// we just dump the DmcType for the object
if (go.getSV("isNamedBy") == null) {
continue;
}
BufferedWriter out = null;
// out = new BufferedWriter(new FileWriter(od + "/DmcType" + cn
// + "REF.java"));
out = FileUpdateManager.instance().getWriter(od,
"DmcType" + cn + "REF.java");
out.write(LGPL.toString());
out.write("package org.dmd.dms.generated.types;\n\n");
out.write("import java.io.Serializable;\n");
out.write("import org.dmd.dmc.DmcAttributeInfo;\n");
out.write("import org.dmd.dmc.DmcValueException;\n");
out.write("import org.dmd.dmc.DmcObjectName;\n");
out.write("import org.dmd.dmc.DmcOutputStreamIF;\n");
out.write("import org.dmd.dmc.DmcInputStreamIF;\n");
out.write("import org.dmd.dmc.types.DmcTypeNamedObjectREF;\n");
out.write("import org.dmd.dms.generated.dmo.*;\n");
out.write("import org.dmd.dmc.types.StringName;\n");
out.write("/**\n * The DmcType" + cn + "REF class.\n");
out.write(" * This code was auto-generated by the createmeta utility and shouldn't be alterred\n");
out.write(" * manually.\n");
out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
out.write(" */\n");
out.write("@SuppressWarnings(\"serial\")\n");
out.write("abstract public class DmcType" + cn
+ "REF extends DmcTypeNamedObjectREF<" + cn
+ "REF, StringName> implements Serializable {\n\n");
out.write(" /**\n");
out.write(" * Default constructor.\n");
out.write(" */\n");
out.write(" public DmcType" + cn + "REF(){\n");
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Default constructor.\n");
out.write(" */\n");
out.write(" public DmcType" + cn
+ "REF(DmcAttributeInfo ai){\n");
out.write(" super(ai);\n");
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Checks that we have a " + cn + "REF or " + cn
+ "DMO.\n");
out.write(" */\n");
out.write(" public "
+ cn
+ "REF typeCheck(Object value) throws DmcValueException {\n");
out.write(" " + cn + "REF rc = null;\n");
out.write(" if (value instanceof " + cn + "REF)\n");
out.write(" rc = (" + cn + "REF)value;\n");
out.write(" else if (value instanceof " + cn + "DMO)\n");
out.write(" rc = new " + cn + "REF((" + cn
+ "DMO)value);\n");
out.write(" else if (value instanceof DmcObjectName){\n");
out.write(" rc = new " + cn + "REF();\n");
out.write(" rc.setName((DmcObjectName)value);\n");
out.write(" }\n");
out.write(" else if (value instanceof String){\n");
out.write(" rc = new " + cn + "REF();\n");
out.write(" rc.setName(new StringName((String)value));\n");
out.write(" }\n");
out.write(" else\n");
out.write(" throw(new DmcValueException(\"Object of class:\" + value.getClass().getName() + \" passed where a "
+ cn + "REF/DMO or DmcObjectName expected.\"));\n");
out.write(" return(rc);\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" protected " + cn + "REF " + "getNewHelper(){\n");
out.write(" return( new " + cn + "REF());\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" protected StringName " + "getNewName(){\n");
out.write(" return( new StringName());\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" protected String getDMOClassName(){\n");
out.write(" return( " + cn + "DMO.class.getName());\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" protected boolean isDMO(Object value){\n");
out.write(" if (value instanceof " + cn + "DMO)\n");
out.write(" return(true);\n");
out.write(" return(false);\n");
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Returns a clone of a value associated with this type.\n");
out.write(" */\n");
out.write(" @Override\n");
out.write(" public " + cn + "REF cloneValue(" + cn
+ "REF val){\n");
out.write(" " + cn + "REF rc = new " + cn
+ "REF(val);\n");
out.write(" return(rc);\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" public void serializeValue(DmcOutputStreamIF dos, "
+ cn + "REF value) throws Exception {\n");
out.write(" value.serializeIt(dos);\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" public "
+ cn
+ "REF deserializeValue(DmcInputStreamIF dis) throws Exception {\n");
out.write(" " + cn + "REF rc = new " + cn + "REF();\n");
out.write(" rc.deserializeIt(dis);\n");
out.write(" return(rc);\n");
out.write(" }\n\n");
out.write("}\n");
out.close();
// Generate the reference container
String nameType = "StringName";
if (cn.equals("RuleData"))
nameType = "RuleName";
// out = new BufferedWriter(new FileWriter(od + File.separator +
// cn + "REF.java"));
out = FileUpdateManager.instance().getWriter(od,
cn + "REF.java");
out.write(LGPL.toString());
out.write("package org.dmd.dms.generated.types;\n\n");
out.write("import java.io.Serializable;\n");
out.write("import org.dmd.dmc.DmcAttribute;\n");
// out.write("import org.dmd.dmc.DmcAttributeInfo;\n");
out.write("import org.dmd.dmc.DmcValueException;\n");
out.write("import org.dmd.dmc.DmcObjectName;\n");
out.write("import org.dmd.dmc.DmcOutputStreamIF;\n");
out.write("import org.dmd.dmc.DmcInputStreamIF;\n");
out.write("import org.dmd.dmc.DmcNamedObjectNontransportableREF;\n");
out.write("import org.dmd.dmc.types.DmcType" + nameType + ";\n");
out.write("import org.dmd.dms.generated.dmo.*;\n");
// out.write("import org.dmd.dms.generated.enums.ValueTypeEnum;\n");
// out.write("import org.dmd.dms.generated.enums.DataTypeEnum;\n");
if (cn.equals("ClassDefinition")) {
out.write("import org.dmd.dmc.DmcOmni;\n");
out.write("import org.dmd.dmc.DmcClassInfo;\n");
}
out.write("/**\n * The " + cn + "REF class.\n");
out.write(" * This code was auto-generated by the createmeta utility and shouldn't be alterred\n");
out.write(" * manually.\n");
out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow()
+ "\n");
out.write(" */\n");
out.write("@SuppressWarnings(\"serial\")\n");
out.write("public class " + cn
+ "REF extends DmcNamedObjectNontransportableREF<" + cn
+ "DMO> implements Serializable {\n\n");
// writeAttributeInfo(out, "name", "2", "StringName", null,
// "false");
// out.write("\n");
if (cn.equals("ClassDefinition")) {
out.write(" transient DmcClassInfo info;\n\n");
}
out.write(" DmcType" + nameType + " myName;\n\n");
out.write(" /**\n");
out.write(" * Default constructor.\n");
out.write(" */\n");
out.write(" public " + cn + "REF(){\n");
out.write(" myName = null;\n");
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Copy constructor.\n");
out.write(" */\n");
out.write(" public " + cn + "REF(" + cn + "REF original){\n");
out.write(" myName = original.myName;\n");
out.write(" object = original.object;\n");
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Wrapper constructor.\n");
out.write(" */\n");
out.write(" public " + cn + "REF(" + cn + "DMO dmo){\n");
out.write(" myName = (DmcType" + nameType + ") dmo.getObjectNameAttribute();\n");
out.write(" object = dmo;\n");
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Sets our object.\n");
out.write(" */\n");
out.write(" @Override\n");
out.write(" public void setObject(" + cn + "DMO o){\n");
out.write(" object = o;\n");
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Clones this reference.\n");
out.write(" */\n");
out.write(" public " + cn + "REF cloneMe(){\n");
out.write(" " + cn + "REF rc = new " + cn + "REF();\n");
out.write(" rc.myName = myName;\n");
out.write(" rc.object = object;\n");
out.write(" return(rc);\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" public void setName(DmcObjectName n) throws DmcValueException {\n");
out.write(" if (myName == null);\n");
out.write(" myName = new DmcType" + nameType
+ "SV(MetaDMSAG.__name);\n");
out.write(" myName.set(n);\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" public DmcAttribute<?> getObjectNameAttribute(){\n");
out.write(" return(myName);\n");
out.write(" }\n\n");
out.write(" @Override\n");
out.write(" public DmcObjectName getObjectName(){\n");
out.write(" return(myName.getSV());\n");
out.write(" }\n\n");
out.write(" public void serializeIt(DmcOutputStreamIF dos) throws Exception {\n");
out.write(" myName.serializeIt(dos);\n");
out.write(" // the object goes nowhere\n");
out.write(" }\n\n");
out.write(" public void deserializeIt(DmcInputStreamIF dis) throws Exception {\n");
out.write(" myName = (DmcType" + nameType
+ ") dis.getAttributeInstance();\n");
out.write(" myName.deserializeIt(dis);\n");
out.write(" }\n\n");
if (cn.equals("ClassDefinition")) {
out.write(" public DmcClassInfo getClassInfo() {\n");
out.write(" if (info == null){\n");
out.write(" if (myName == null)\n");
out.write(" throw(new IllegalStateException(\"No name set for a ClassDefinitionREF\"));\n");
out.write(" info = DmcOmni.instance().getClassInfo(myName.getSV().getNameString());\n");
out.write(" if (info == null)\n");
out.write(" throw(new IllegalStateException(\"Unable to retrive class info for class: \" + myName.getSV().getNameString() + \" ensure that you have loaded the DmcOmni with the appropriate schemas.\"));\n");
out.write(" }\n");
out.write(" return(info);\n");
out.write(" }\n\n");
}
out.write("}\n");
out.close();
}
}
for (int i = 0; i < origOrderEnums.size(); i++) {
go = (DmcUncheckedObject) enumDefs.get(origOrderEnums.get(i));
// System.out.println("*** Formatting mediator for: " +
// origOrderEnums.get(i));
if ((cn = go.getSV("name")) == null) {
System.out.println("Couldn't get name for enum definition:\n"
+ go);
} else {
dumpDmcType(od, cn, true);
}