Package org.dmd.dms

Examples of org.dmd.dms.TypeDefinition


        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");
View Full Code Here


      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");
      }
     
View Full Code Here

     
      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()){
//              System.out.println(type);
//              DebugInfo.debug("Need enum code");
//              System.exit(1);
            }
            else{
//              System.out.println("ORIGINAL CLASS:\n" + type.getOriginalClass());
             
              uniqueImports.put(type.getOriginalClass().getJavaClass(), "Object reference");
              uniqueImports.put(type.getOriginalClass().getDmtREFImport(), "Object reference");
             
             
//              DebugInfo.debug("Need object reference code");
//              System.exit(1);
            }
          }
         
//          DebugInfo.debug("\n" + type.toOIF());
         
          if (primitiveType == null){
//          DebugInfo.debug("Couldn't get primitive type");
//          System.exit(1);
          }
          else{
            if (!type.getIsRefType())
              uniqueImports.put(primitiveType, "Primitive type");
          }
         
          if (type.getTypeClassName() != null){
            String sp = type.getDefinedIn().getSchemaPackage();
            String imp = null;
            String comment = "";
//            String imp = sp + ".generated.types.DmcType" + type.getName() + "STATIC";
            if (type.getInternallyGenerated()){
              imp = type.getTypeClassName() + "STATIC";
              comment = "Internally generated type";
            }
            else{
              imp = sp + ".generated.types.DmcType" + type.getName() + "STATIC";
              comment = "Standard type";
            }
           
            uniqueImports.put(imp,comment);
          }
View Full Code Here

     
      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()){
//              System.out.println(type);
//              DebugInfo.debug("Need enum code");
//              System.exit(1);
            }
            else{
//              System.out.println("ORIGINAL CLASS:\n" + type.getOriginalClass());
             
//              uniqueImports.put(type.getOriginalClass().getJavaClass(), "Object reference");
//              uniqueImports.put(type.getOriginalClass().getDmtREFImport(), "Object reference");
             
                imports.addImport(type.getOriginalClass().getJavaClass(), "References to " + type.getOriginalClass().getName());
                imports.addImport(type.getOriginalClass().getDmtREFImport(), "References to " + type.getOriginalClass().getName());
                           
             
//              DebugInfo.debug("Need object reference code");
//              System.exit(1);
            }
          }
         
//          DebugInfo.debug("\n" + type.toOIF());
         
          if (primitiveType == null){
//          DebugInfo.debug("Couldn't get primitive type");
//          System.exit(1);
          }
          else{
            if (!type.getIsRefType()){
              imports.addImport(primitiveType, "Primitive type");
//              uniqueImports.put(primitiveType, "Primitive type");
            }
          }
         
          if (type.getTypeClassName() != null){
            String sp = type.getDefinedIn().getSchemaPackage();
            String imp = null;
            String comment = "";
//            String imp = sp + ".generated.types.DmcType" + type.getName() + "STATIC";
            if (type.getInternallyGenerated()){
              imp = type.getTypeClassName() + "STATIC";
              comment = "Internally generated type";
            }
            else{
              imp = sp + ".generated.types.DmcType" + type.getName() + "STATIC";
              comment = "Standard type";
            }
           
//            uniqueImports.put(imp,comment);
            imports.addImport(imp, comment);
View Full Code Here

        }
       
        Iterator<TypeDefinition> tds = sd.getTypeDefList();
    if (tds != null){
      while(tds.hasNext()){
        TypeDefinition td = tds.next();
        if (td.getIsNameType()){
          if (td.getNameAttributeDef() == null)
            throw(new IllegalStateException("TypeDefinition " + td.getName() + "  does not have a designated naming attribute."));
         
          String adn = td.getName().getNameString();
          nameBuilders.append("        _NmAp.put(DmcType" + adn + "STATIC.instance.getNameClass(),DmcType" + adn + "STATIC.instance);\n");
        }
      }
    }
   
View Full Code Here

        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");
View Full Code Here

      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");
      }
     
View Full Code Here

     
      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()){
//              System.out.println(type);
//              DebugInfo.debug("Need enum code");
//              System.exit(1);
            }
            else{
//              System.out.println("ORIGINAL CLASS:\n" + type.getOriginalClass());
             
//              imports.addImport(type.getOriginalClass().getJavaClass(), "Object reference");
              imports.addImport(type.getOriginalClass().getDmtREFImport(), "Object reference");
             
//              uniqueImports.put(type.getOriginalClass().getJavaClass(), "Object reference");
//              uniqueImports.put(type.getOriginalClass().getDmtREFImport(), "Object reference");
             
             
//              DebugInfo.debug("Need object reference code");
//              System.exit(1);
            }
          }
         
//          DebugInfo.debug("\n" + type.toOIF());
         
          if (primitiveType == null){
//          DebugInfo.debug("Couldn't get primitive type");
//          System.exit(1);
          }
          else{
            if (!type.getIsRefType())
              imports.addImport(primitiveType, "Primitive type");
//              uniqueImports.put(primitiveType, "Primitive type");
          }
         
          if (type.getTypeClassName() != null){
            String sp = type.getDefinedIn().getSchemaPackage();
            String imp = null;
            String comment = "";
//            String imp = sp + ".generated.types.DmcType" + type.getName() + "STATIC";
            if (type.getInternallyGenerated()){
              imp = type.getTypeClassName() + "STATIC";
              comment = "Internally generated type";
            }
            else{
              imp = sp + ".generated.types.DmcType" + type.getName() + "STATIC";
              comment = "Standard type";
            }
           
          imports.addImport(imp, comment);
//            uniqueImports.put(imp,comment);
View Full Code Here

    if (cd.getDerivedFrom() != null){
      collectAllAttributes(cd.getDerivedFrom(),allAttr,types,needJavaUtil);
    }
   
    if (cd.getIsNamedBy() != null){
      TypeDefinition td = cd.getIsNamedBy().getType();
      types.put(td.getName(), td);
    }
   
    Iterator<AttributeDefinition> may = cd.getMay();
    if (may != null){
      while(may.hasNext()){
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          break;
        case MULTI:
          needJavaUtil.set(true);
          break;
        case HASHMAPPED:
          break;
        case TREEMAPPED:
          break;
        }
       
//        if (ad.getIsMultiValued())
//          needJavaUtil.set(true);
       
        allAttr.put(ad.getName(),ad);
      }
    }
   
    Iterator<AttributeDefinition> must = cd.getMust();
    if (must != null){
      while(must.hasNext()){
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
        types.put(td.getName(), td);
       
        switch(ad.getValueType()){
        case SINGLE:
          break;
        case MULTI:
View Full Code Here

    }
   
    Iterator<TypeDefinition> types = sd.getTypeDefList();
    if (types != null){
      while(types.hasNext()){
        TypeDefinition td = types.next();
        String genericArgs = td.getGenericArgs();
        if (genericArgs == null)
          genericArgs = "";
       
        GenUtility.dumpIterable(dmwdir, sd.getDmwPackage(), td.getPrimitiveType(), td.getName().getNameString(), genericArgs, fileHeader, progress);
      }
    }
   
    Iterator<EnumDefinition>  enums = sd.getEnumDefList();
    if (enums != null){
View Full Code Here

TOP

Related Classes of org.dmd.dms.TypeDefinition

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.