Package org.dmd.dms.generated.types

Examples of org.dmd.dms.generated.types.Field


       
        // Determine if we have any reference fields
        boolean hasRefs = false;
        ArrayList<String> refFields = new ArrayList<String>();
        while(fields.hasNext()){
          Field field = fields.next();
          TypeDefinitionDMO type = field.getType().getObject();
         
          if (type == null){
            DebugInfo.debug("Unknown type in ExtendedReferenceTypeDefinition: " + field.getType().getObjectName());
            System.exit(1);
          }

          if (type.getIsRefType()){
            hasRefs = true;
            refFields.add(field.getName());
          }
        }
       
        out.write(header);
       
        out.write("package " + ertd.getDefinedIn().getSchemaPackage() + ".generated.types;\n\n");
       
        String nameBaseImport = ertd.getExtendedReferenceClass().getIsNamedBy().getType().getDefinedIn().getSchemaPackage() + ".generated.types.DmcType";
        String nameImport = ertd.getExtendedReferenceClass().getIsNamedBy().getType().getName().getNameString() + "SV";
        String staticNameType = ertd.getExtendedReferenceClass().getIsNamedBy().getType().getName().getNameString() + "STATIC";

        imports.addImport(nameBaseImport + nameImport, "Name type");
        imports.addImport(ertd.getExtendedReferenceClass().getIsNamedBy().getType().getPrimitiveType(), "Name type");
       
        imports.addImport(nameBaseImport + staticNameType, "Static type for name");
       
        imports.addImport(ertd.getExtendedReferenceClass().getDmoImport(), "Object based constructor");

        imports.addImport("org.dmd.dmc.DmcExtendedReferenceIF", "Marker interface for extended references");

//        out.write("import java.io.Serializable;\n");
//        out.write("import org.dmd.dmc.DmcInputStreamIF;\n");
//        out.write("import org.dmd.dmc.DmcOutputStreamIF;\n");
//        out.write("import org.dmd.dmc.types.IntegerVar;\n");
       
        imports.addImport("java.io.Serializable", "Serialization support");
        imports.addImport("org.dmd.dmc.DmcInputStreamIF", "Serialization support");
        imports.addImport("org.dmd.dmc.DmcOutputStreamIF", "Serialization support");
        imports.addImport("org.dmd.dmc.types.IntegerVar", "Parsing support");
       
        if (hasRefs){
//            out.write("import org.dmd.dmc.DmcNameResolverIF;\n");
//            out.write("import org.dmd.dmc.DmcNamedObjectIF;\n");
//            out.write("import org.dmd.dmc.DmcNamedObjectREF;\n");
//            out.write("import org.dmd.dmc.DmcContainerIF;\n");
           
            imports.addImport("org.dmd.dmc.DmcNameResolverIF", "Object reference support");
            imports.addImport("org.dmd.dmc.DmcNamedObjectIF", "Object reference support");
            imports.addImport("org.dmd.dmc.DmcNamedObjectREF", "Object reference support");
            imports.addImport("org.dmd.dmc.DmcContainerIF", "Object reference support");
        }

//        out.write("import org.dmd.dmc.DmcValueException;\n\n");
       
        imports.addImport("org.dmd.dmc.DmcValueException", "Value exceptions");
       
//        out.write(getComplexTypeImports(ertd));
       
        getComplexTypeImports(ertd, imports);
       
        out.write(imports.getFormattedImports() + "\n\n");
       
        out.write("@SuppressWarnings(\"serial\")\n");

        out.write("/**\n * The " + ctn + " class.\n");
        out.write(" * This code was auto-generated and shouldn't be alterred manually.\n");
        out.write(" * \n");
        out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write(" */\n");

        out.write("public class " + ctn + " extends " + ertd.getExtendedReferenceClass().getName() + "REF implements Serializable, DmcExtendedReferenceIF {\n\n");
       
        out.write(getComplexTypeFieldInstances(ertd));
         
        out.write("    /**\n");
        out.write("     * Default constructor.\n");
        out.write("     */\n");
        out.write("    public " + ctn + "(){\n");
      out.write("    }\n\n");
                 
      ///////////////////////////////////////////////////////////////////////
      // Copy constructor
     
        out.write("    /**\n");
        out.write("     * Copy constructor.\n");
        out.write("     * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("     */\n");
        out.write("    public " + ctn + "(" + ctn + " original){\n");
        out.write("        myName = original.myName;\n");
        out.write("        object = original.object;\n");
        fields = ertd.getField();
        while(fields.hasNext()){
          Field field = fields.next();
          out.write("        _" + field.getName() + " = original._" + field.getName() + ";\n");
        }
      out.write("    }\n\n");
       
      ///////////////////////////////////////////////////////////////////////
      // All fields constructor with name
     
      String nametype = ertd.getExtendedReferenceClass().getIsNamedBy().getType().getName().getNameString();
      String attrName = ertd.getExtendedReferenceClass().getIsNamedBy().getName().getNameString();
     
        out.write("    /**\n");
        out.write("     * All fields constructor.\n");
        out.write("     * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("     */\n");
        out.write("    public " + ctn + "(" + nametype + " name, ");
        int 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("        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");
          out.write("    }\n\n");
         
        }
       
        if (hasRefs){
          out.write("    @SuppressWarnings(\"unchecked\")\n");
            out.write("    public void resolve(DmcNameResolverIF resolver, String attrName) throws DmcValueException {\n");
          out.write("        DmcNamedObjectIF  obj = null;\n\n");
           
            for(String fn: refFields){
              out.write("        obj = resolver.findNamedObject(" + fn + ".getObjectName());\n");
              out.write("        if (obj == null)\n");
              out.write("            throw(new DmcValueException(\"Could not resolve reference to: \" + " + fn + ".getObjectName() + \" via attribute: \" + attrName));\n");
              out.write("        \n");
              out.write("        if (obj instanceof DmcContainerIF)\n");
              out.write("            ((DmcNamedObjectREF)" + fn + ").setObject((DmcNamedObjectIF) ((DmcContainerIF)obj).getDmcObject());\n");
              out.write("        else\n");
              out.write("            ((DmcNamedObjectREF)" + fn + ").setObject(obj);\n");
              out.write("        \n");
            }

          out.write("    }\n\n");
        }
     
      ///////////////////////////////////////////////////////////////////////
      // Parsing support
     
      out.write("    String getNextField(String input, IntegerVar seppos, String fn, boolean last) throws DmcValueException {\n");
      out.write("         String rc = null;\n");
      out.write("         int start = seppos.intValue();\n");
      out.write("\n");
      out.write("         if ( (start+1) >= input.length())\n");
      out.write("           throw (new DmcValueException(\"Missing value for field: \" + fn + \" in complex type: " + ctn + "\"));\n");
      out.write("\n");
      out.write("         if (last){\n");
      out.write("             rc = input.substring(start+1);\n");
      out.write("         }\n");
      out.write("         else{\n");
      out.write("             int pos = -1;\n");
      out.write("             if (start > 0)\n");
      out.write("               pos = input.indexOf(\"" + fieldSeparator + "\", start+1);\n");
      out.write("             else\n");
      out.write("               pos = input.indexOf(\"" + fieldSeparator + "\");\n");
      out.write("\n");
      out.write("             if (pos == -1)\n");
      out.write("               throw (new DmcValueException(\"Missing value for field: \" + fn + \" in complex type: " + ctn + "\"));\n");
      out.write("\n");
      out.write("           while(pos < (input.length()-1)){\n");
      out.write("               if ( input.charAt(pos+1) == '" + fieldSeparator + "')\n");
      out.write("                   pos++;\n");
      out.write("               else\n");
      out.write("                   break;\n");
      out.write("           }\n");
      out.write("\n");
      out.write("             rc = input.substring(start+1, pos).trim();\n");
      out.write("\n");
      out.write("             seppos.set(pos);\n");
      out.write("        }\n");
      out.write("\n");
      out.write("        return(rc);\n");
      out.write("    }\n\n");

     
      ///////////////////////////////////////////////////////////////////////
      // Overload equals to support adapters
     
      out.write("    @Override\n");
      out.write("    public boolean equals(Object obj){\n");
      out.write("        boolean rc = false;\n");
      out.write("\n");
      out.write("        if (obj instanceof " + ctn + "){\n");
      out.write("            " + ctn + " other = (" + ctn + ")obj;\n");
      out.write("            rc = myName.equals(other.myName);\n");
      out.write("\n");

        fields = ertd.getField();
        while(fields.hasNext()){
          Field field = fields.next();
         
          out.write("            if(rc)\n");
          out.write("                rc = _" + field.getName() + ".equals(other._" + field.getName() + ");\n");
        }
       
      out.write("        }\n");
      out.write("\n");
      out.write("        return(rc);\n");
View Full Code Here


    static String getComplexTypeFieldInstances(ComplexTypeDefinition ctd){
      StringBuffer sb = new StringBuffer();
     
      Iterator<Field> fields = ctd.getField();
      while(fields.hasNext()){
        Field field = fields.next();
          TypeDefinition  type = (TypeDefinition) field.getType().getObject().getContainer();
        sb.append("    // " + field.getDescription() + "\n");
       
        if (type.getIsRefType())
            sb.append("    " + field.getType().getObjectName() + "REF _" + field.getName() + ";\n\n");
        else
          sb.append("    " + field.getType().getObjectName() + " _" + field.getName() + ";\n\n");
      }
     
      return(sb.toString());
    }
View Full Code Here

      // Key:   import
      // Value: comment
      TreeMap<String,String>  uniqueImports = new TreeMap<String, String>();
     
      while(fields.hasNext()){
        Field field = fields.next();
//        DebugInfo.debug("field type = " + field.getType().getObjectName());
       
          TypeDefinition  type = (TypeDefinition) field.getType().getObject().getContainer();
         
          String primitiveType = type.getPrimitiveType();
         
          if (type.getInternallyGenerated()){
            if (type.getIsEnumType()){
View Full Code Here

      // Key:   import
      // Value: comment
//      TreeMap<String,String>  uniqueImports = new TreeMap<String, String>();
     
      while(fields.hasNext()){
        Field field = fields.next();
//        DebugInfo.debug("field type = " + field.getType().getObjectName());
       
          TypeDefinition  type = (TypeDefinition) field.getType().getObject().getContainer();
         
          String primitiveType = type.getPrimitiveType();
         
          if (type.getInternallyGenerated()){
            if (type.getIsEnumType()){
View Full Code Here

    }
   
    @Override
    // org.dmd.dms.util.GenUtility.dumpSVType(GenUtility.java:2010)
    public Field set(Object v) throws DmcValueException {
        Field rc = typeCheck(v);
        // We only return a value if the value actually changed. This supports
        // the applyModifier() mechanism on DmcObject where we only return true
        // if something changed as a result of the modifier
        if (value == null)
            value = rc;
View Full Code Here

       
        // Determine if we have any reference fields
        boolean hasRefs = false;
        ArrayList<String> refFields = new ArrayList<String>();
        while(fields.hasNext()){
          Field field = fields.next();
          TypeDefinitionDMO type = field.getType().getObject();
         
          if (type == null){
            DebugInfo.debug("Unknown type in ComplexTypeDefinition: " + field.getType().getObjectName());
            System.exit(1);
          }

          if (type.getIsRefType()){
            hasRefs = true;
            refFields.add(field.getName());
          }
        }
       
        if (header != null)
          out.write(header);
       
        out.write("package " + ctd.getDefinedIn().getSchemaPackage() + ".generated.types;\n\n");

    ImportManager imports = new ImportManager();

    imports.addImport("java.io.Serializable", "To prevent serialization warnings");
    imports.addImport("org.dmd.dmc.DmcInputStreamIF", "Standard serialization techniques");
    imports.addImport("org.dmd.dmc.DmcOutputStreamIF", "Standard serialization techniques");
    imports.addImport("org.dmd.dmc.types.IntegerVar", "To support getNextField()");
//    out.write("import java.io.Serializable;\n");
//        out.write("import org.dmd.dmc.DmcInputStreamIF;\n");
//        out.write("import org.dmd.dmc.DmcOutputStreamIF;\n");
//        out.write("import org.dmd.dmc.types.IntegerVar;\n");
       
        if (hasRefs){
        imports.addImport("org.dmd.dmc.DmcNameResolverIF", "To support object references");
        imports.addImport("org.dmd.dmc.DmcNamedObjectIF", "To support object references");
        imports.addImport("org.dmd.dmc.DmcNamedObjectREF", "To support object references");
        imports.addImport("org.dmd.dmc.DmcContainerIF", "To support object references");

//        out.write("import org.dmd.dmc.DmcNameResolverIF;\n");
//            out.write("import org.dmd.dmc.DmcNamedObjectIF;\n");
//            out.write("import org.dmd.dmc.DmcNamedObjectREF;\n");
//            out.write("import org.dmd.dmc.DmcContainerIF;\n");
        }

//        out.write("import org.dmd.dmc.DmcAttribute;\n");
//        out.write("import org.dmd.dmc.DmcAttributeInfo;\n");
       
    imports.addImport("org.dmd.dmc.DmcValueException", "Standard value exception");

//        out.write("import org.dmd.dmc.DmcValueException;\n\n");
       
    getComplexTypeImports(ctd, imports);
//        out.write(getComplexTypeImports(ctd));
   
    out.write(imports.getFormattedImports());
       
        out.write("@SuppressWarnings(\"serial\")\n");

        out.write("/**\n * The " + ctn + " class.\n");
        out.write(" * This code was auto-generated and shouldn't be alterred manually.\n");
        out.write(" * \n");
        out.write(" * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write(" */\n");

        out.write("public class " + ctn + " implements Serializable {\n\n");
       
        out.write(getComplexTypeFieldInstances(ctd));
         
        out.write("    /**\n");
        out.write("     * Default constructor.\n");
        out.write("     */\n");
        out.write("    public " + ctn + "(){\n");
      out.write("    }\n\n");
                         
        out.write("    /**\n");
        out.write("     * Copy constructor.\n");
        out.write("     */\n");
        out.write("    public " + ctn + "(" + ctn + " original){\n");
        fields = ctd.getField();
        while(fields.hasNext()){
          Field field = fields.next();
          out.write("        " + field.getName() + " = original." + field.getName() + ";\n");
        }
      out.write("    }\n\n");
       
     
        out.write("    /**\n");
        out.write("     * All fields constructor.\n");
        out.write("     * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("     */\n");
        out.write("    public " + ctn + "(");
        int fnum = 1;
        fields = ctd.getField();
        while(fields.hasNext()){
          Field field = fields.next();
          TypeDefinition  type = (TypeDefinition) field.getType().getObject().getContainer();

          if (type.getIsRefType()){
            out.write(field.getType().getObjectName() + "REF f" + fnum);
          }
          else{
            out.write(field.getType().getObjectName() + " f" + fnum);
          }

          fnum++;
          if (fnum <= ctd.getFieldSize())
            out.write(", ");
        }
       
        out.write(") throws DmcValueException {\n");
        fnum = 1;
        fields = ctd.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");
          }
          else{
            out.write("        " + field.getName() + " = DmcType" + field.getType().getObjectName() + "STATIC.instance.typeCheck(f" + fnum + ");\n");
          }
          fnum++;
        }
      out.write("    }\n\n");
     
        out.write("    /**\n");
        out.write("     * String based constructor.\n");
        out.write("     * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("     */\n");
        out.write("    public " + ctn + "(String initialInput) throws DmcValueException {\n");
        out.write("        IntegerVar seppos = new IntegerVar(-1);\n");
    if (whiteSpaceSeparator){
      out.write("        String input = initialInput.trim();\n");
      out.write("        input = input.replaceAll(\"(\\\\s)+\", \" \");\n");
    }
    else{
      out.write("        String input = initialInput.trim();\n");
    }
        fnum = 1;
        fields = ctd.getField();
        while(fields.hasNext()){
          Field field = fields.next();
          TypeDefinition  type = (TypeDefinition) field.getType().getObject().getContainer();
          String REF = "";
          if (type.getIsRefType())
            REF = "REF";
         
          if (fnum == ctd.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");
     
     
        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");
        fields = ctd.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");
        fields = ctd.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");
     
        out.write("    /**\n");
        out.write("     * String form.\n");
        out.write("     */\n");
        out.write("    public String toString(){\n");
        fnum = 1;
        out.write("        return(");
        fields = ctd.getField();
        while(fields.hasNext()){
          Field field = fields.next();
          out.write(field.getName() + ".toString()");
          if (fnum < ctd.getFieldSize())
            out.write(" + \"" + fieldSeparator + "\" + ");
          fnum++;
        }
        out.write(");\n");
      out.write("    }\n\n");
     
        fields = ctd.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 (hasRefs){
          out.write("    @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n");
View Full Code Here

    static String getComplexTypeFieldInstances(ComplexTypeDefinition ctd){
      StringBuffer sb = new StringBuffer();
     
      Iterator<Field> fields = ctd.getField();
      while(fields.hasNext()){
        Field field = fields.next();
          TypeDefinition  type = (TypeDefinition) field.getType().getObject().getContainer();
        sb.append("    // " + field.getDescription() + "\n");
       
        if (type.getIsRefType())
            sb.append("    " + field.getType().getObjectName() + "REF " + field.getName() + ";\n\n");
        else
          sb.append("    " + field.getType().getObjectName() + " " + field.getName() + ";\n\n");
      }
     
      return(sb.toString());
    }
View Full Code Here

      // Key:   import
      // Value: comment
//      TreeMap<String,String>  uniqueImports = new TreeMap<String, String>();
     
      while(fields.hasNext()){
        Field field = fields.next();
//        DebugInfo.debug("field type = " + field.getType().getObjectName());
       
          TypeDefinition  type = (TypeDefinition) field.getType().getObject().getContainer();
         
          String primitiveType = type.getPrimitiveType();
         
          if (type.getInternallyGenerated()){
            if (type.getIsEnumType()){
View Full Code Here

         
          // The usual resolution mechanisms don't work for the fields, we have to
          // handle that manually.
          Iterator<Field> fields = ctd.getField();
          while(fields.hasNext()){
            Field field = fields.next();
            DmcNamedObjectREF ref = (DmcNamedObjectREF)field.getType();
           
              // It might be a "real" type, so try that first
              TypeDefinition td = tdef(ref.getObjectName().getNameString());
             
              if( td == null){
                ClassDefinition cd = cdef(ref.getObjectName().getNameString());
                if (cd == null){
                  ResultException ex = new ResultException();
                  ex.addError("The type: " + ref.getObjectName() + " referred to in ComplexTypeDefinition " + ctd.getName() + " is invalid.");
                  ex.result.lastResult().fileName(ctd.getFile());
                  ex.result.lastResult().lineNumber(ctd.getLineNumber());
                  throw(ex);
                }
                else{
                    ref.setObject((DmcNamedObjectIF) cd.getInternalTypeRef().getDmcObject());
                }
              }
              else{
                ref.setObject((DmcNamedObjectIF) td.getDmcObject());
              }

          }
         
          // And finally, the complex type def has to have it object class resolved so that
          // we don't run into problems later when generating the DMW schema
          try {
          ctd.resolveReferences(this);
        } catch (DmcValueExceptionSet e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        }
      }
     
      // And more of the same kind of magic with extended references types - we have to
      // preresolve the type references in the same way as with attributes
      Iterator<ExtendedReferenceTypeDefinition> ertdl = sd.getExtendedReferenceTypeDefList();
      if (ertdl != null){
        while(ertdl.hasNext()){
          ExtendedReferenceTypeDefinition ertd = ertdl.next();
         
              DmcTypeClassDefinitionREFSV attr = (DmcTypeClassDefinitionREFSV) ertd.getDMO().get(MetaDMSAG.__extendedReferenceClass);
          if (attr == null){
          ResultException ex = new ResultException();
          ex.addError("Missing extendedReferenceClass for ExtendedReferenceTypeDefinition: " + ertd.getName());
          ex.result.lastResult().fileName(ertd.getFile());
          ex.result.lastResult().lineNumber(ertd.getLineNumber());
          throw(ex);           
          }
         
          try {
          attr.resolveReferences(this);
        } catch (DmcValueException e) {
          ResultException ex = new ResultException();
          ex.addError("Unknown class referred to by extendedReferenceClass: " + attr.getSV().getObjectName().getNameString());
          ex.result.lastResult().fileName(ertd.getFile());
          ex.result.lastResult().lineNumber(ertd.getLineNumber());
          throw(ex);
        }
       
        try {
          ertd.getInternalType().setOriginalClass(ertd.getExtendedReferenceClass());
        } catch (DmcValueException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
       

//        ClassDefinition cd = cdef(attr.getName());
//        if (cd == null){
//          ResultException ex = new ResultException();
//          ex.addError("Missing extendedReferenceClass for ExtendedReferenceTypeDefinition: " + ertd.getName());
//          ex.result.lastResult().fileName(ertd.getFile());
//          ex.result.lastResult().lineNumber(ertd.getLineNumber());
//          throw(ex);
//        }
         
         
        if (ertd.getExtendedReferenceClass().getIsNamedBy() == null){
          ResultException ex = new ResultException();
          ex.addError("The class: " + ertd.getExtendedReferenceClass().getObjectName().getNameString() + " referred to in ExtendedReferenceTypeDefinition " + ertd.getName() + " is not a named object.");
          ex.result.lastResult().fileName(ertd.getFile());
          ex.result.lastResult().lineNumber(ertd.getLineNumber());
          throw(ex);
        }

          Iterator<Field> fields = ertd.getField();
          while(fields.hasNext()){
            Field field = fields.next();
            DmcNamedObjectREF ref = (DmcNamedObjectREF)field.getType();
           
              // It might be a "real" type, so try that first
              TypeDefinition td = tdef(ref.getObjectName().getNameString());
             
              if( td == null){
View Full Code Here

   
    @Override
    // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2659)
    public Field add(Object v) throws DmcValueException {
        synchronized(this){
            Field rc = typeCheck(v);
            if (value == null)
                initValue();
       
            // If false is returned, we didn't modify the set, so return null
            if (!value.add(rc))
View Full Code Here

TOP

Related Classes of org.dmd.dms.generated.types.Field

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.