out.write(" setName(name);\n");
fnum = 1;
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
TypeDefinition type = (TypeDefinition) field.getType().getObject().getContainer();
if (type.getIsRefType()){
// out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + "REFSTATIC.instance.typeCheck(f" + fnum + ");\n");
out.write(" _" + field.getName() + " = " + field.getName() + ";\n");
}
else{
// out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + "STATIC.instance.typeCheck(f" + fnum + ");\n");
out.write(" _" + field.getName() + " = " + field.getName() + ";\n");
}
fnum++;
}
out.write(" }\n\n");
///////////////////////////////////////////////////////////////////////
// All fields constructor with object
out.write(" /**\n");
out.write(" * All fields constructor.\n");
out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
out.write(" */\n");
out.write(" public " + ctn + "(" + ertd.getExtendedReferenceClass().getName().getNameString() + "DMO obj, ");
fnum = 1;
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
// out.write(field.getType().getObjectName() + " f" + fnum);
out.write(field.getType().getObjectName() + " " + field.getName());
fnum++;
if (fnum <= ertd.getFieldSize())
out.write(", ");
}
// out.write(") throws DmcValueException {\n");
out.write(") {\n");
out.write(" super(obj);\n");
fnum = 1;
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
TypeDefinition type = (TypeDefinition) field.getType().getObject().getContainer();
if (type.getIsRefType()){
// out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + "REFSTATIC.instance.typeCheck(f" + fnum + ");\n");
out.write(" _" + field.getName() + " = " + field.getName() + ";\n");
}
else{
// out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + "STATIC.instance.typeCheck(f" + fnum + ");\n");
out.write(" _" + field.getName() + " = " + field.getName() + ";\n");
}
fnum++;
}
out.write(" }\n\n");
///////////////////////////////////////////////////////////////////////
// String based constructor
out.write(" /**\n");
out.write(" * String based constructor.\n");
out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
out.write(" */\n");
out.write(" public " + ctn + "(String input) throws DmcValueException {\n");
out.write(" IntegerVar seppos = new IntegerVar(-1);\n");
out.write(" " + nametype + " n = DmcType" + nametype + "STATIC.instance.typeCheck(getNextField(input,seppos,\"object name\",false));\n");
out.write(" myName = new DmcType" + nametype + "SV(__" + attrName + ");\n");
out.write(" myName.set(n);\n\n");
// StringName n = DmcTypeStringNameSTATIC.instance.typeCheck(getNextField(input,seppos,"object name",false));
// myName = new DmcTypeStringNameSV(__name);
// myName.set(n);
fnum = 1;
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
TypeDefinition type = (TypeDefinition) field.getType().getObject().getContainer();
String REF = "";
if (type.getIsRefType())
REF = "REF";
if (fnum == ertd.getFieldSize())
out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + REF + "STATIC.instance.typeCheck(getNextField(input,seppos,\"" + field.getName() + "\",true));\n");
else
out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + REF + "STATIC.instance.typeCheck(getNextField(input,seppos,\"" + field.getName() + "\",false));\n");
fnum++;
}
out.write(" }\n\n");
///////////////////////////////////////////////////////////////////////
// Serialization
out.write(" /**\n");
out.write(" * Serialization.\n");
out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
out.write(" */\n");
out.write(" public void serializeIt(DmcOutputStreamIF dos) throws Exception {\n");
out.write(" DmcType" + nametype + "STATIC.instance.serializeValue(dos, myName.getSV());\n");
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
TypeDefinition type = (TypeDefinition) field.getType().getObject().getContainer();
if (type.getIsRefType())
out.write(" DmcType" + field.getType().getObjectName() + "REFSTATIC.instance.serializeValue(dos, _" + field.getName() + ");\n");
else
out.write(" DmcType" + field.getType().getObjectName() + "STATIC.instance.serializeValue(dos, _" + field.getName() + ");\n");
}
out.write(" }\n\n");
out.write(" /**\n");
out.write(" * Deserialization.\n");
out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
out.write(" */\n");
out.write(" public void deserializeIt(DmcInputStreamIF dis) throws Exception {\n");
out.write(" " + nametype + " n = DmcType" + nametype + "STATIC.instance.deserializeValue(dis);\n");
out.write(" myName = new DmcType" + nametype + "SV(__" + attrName + ");\n");
out.write(" myName.set(n);\n\n");
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
TypeDefinition type = (TypeDefinition) field.getType().getObject().getContainer();
if (type.getIsRefType())
out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + "REFSTATIC.instance.deserializeValue(dis);\n");
else
out.write(" _" + field.getName() + " = DmcType" + field.getType().getObjectName() + "STATIC.instance.deserializeValue(dis);\n");
}
out.write(" }\n\n");
///////////////////////////////////////////////////////////////////////
// String form
out.write(" /**\n");
out.write(" * String form.\n");
out.write(" */\n");
out.write(" public String toString(){\n");
fnum = 1;
out.write(" return(");
out.write("myName.getSV().getNameString()");
if (ertd.getFieldSize() > 0)
out.write(" + \"" + fieldSeparator + "\" + ");
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
out.write("_" + field.getName() + ".toString()");
if (fnum < ertd.getFieldSize())
out.write(" + \"" + fieldSeparator + "\" + ");
fnum++;
}
out.write(");\n");
out.write(" }\n\n");
///////////////////////////////////////////////////////////////////////
// Getter/setters
out.write(" public void setName(" + nametype + " name){\n");
out.write(" try{\n");
out.write(" super.setName(name);\n");
out.write(" object = null;\n");
out.write(" } catch (DmcValueException e) {\n");
out.write(" throw new IllegalStateException(\"Setting name with a specific type shouldn't throw an exception.\",e);\n");
out.write(" }\n\n");
out.write(" }\n\n");
out.write(" public void setObject(" + ertd.getExtendedReferenceClass().getName().getNameString() + "DMO obj){\n");
out.write(" super.setObject(obj);\n");
out.write(" }\n\n");
fields = ertd.getField();
while(fields.hasNext()){
Field field = fields.next();
TypeDefinition type = (TypeDefinition) field.getType().getObject().getContainer();
if (type.getIsRefType())
out.write(" public " + field.getType().getObjectName() + "REF get" + GenUtility.capTheName(field.getName()) + "(){\n");
else
out.write(" public " + field.getType().getObjectName() + " get" + GenUtility.capTheName(field.getName()) + "(){\n");
out.write(" return(_" + field.getName() + ");\n");
out.write(" }\n\n");
if (type.getIsRefType())
out.write(" public void set" + GenUtility.capTheName(field.getName()) + "(" + field.getType().getObjectName() + " " + field.getName() + "){\n");
else
out.write(" public void set" + GenUtility.capTheName(field.getName()) + "(" + field.getType().getObjectName() + " " + field.getName() + "){\n");
out.write(" _" + field.getName() + " = " + field.getName() + ";\n");