Package org.destecs.tools.jprotocolgenerator.ast

Examples of org.destecs.tools.jprotocolgenerator.ast.Field


    m.parameters.add(param);
    SuppressWarningAnnotation swa = new SuppressWarningAnnotation();
    m.annotation = swa;
    for (String p : map.possibleEntries.keySet())
    {
      Field f = new Field();
      f.setName(p);
      returnClass.fields.add(f);

      ITypeNode type = map.possibleEntries.get(p);
      if (type instanceof ListType)
      {
        if (((ListType) type).type instanceof MapType)
        {
          swa.warnings.add(WarningTypes.unchecked);
          ClassDefinition newRet = new ClassDefinition();
          newRet.setName(m.name + p + appendName);
          newRet.packageName = packageName2;
          newRet.imports.add(new Type(Map.class));
          newRet.imports.add(new Type(List.class));
          newRet.implemented.add(stryctInterface);
          returnClass.imports.add(new Type(Vector.class));

          defs.addAll(generateStructs(newRet, packageName2, (MapType) ((ListType) type).type, isParameter));
          defs.add(newRet);
          f.type = new ListType(newRet);
          m.body += f.type.getName() + " tmp" + count
              + " = new Vector<" + newRet.getName()
              + ">();\n\t\t";

          m.body += "if( value.keySet().contains(\"" + f.getName()
              + "\" ))\n\t\t";
          m.body += "{\n\t\t\t";

          if (map.valueType instanceof List
              || map.valueType instanceof ListType)
          {
            m.body += "Object tmpL" + count + " = value.get(\""
                + f.getName() + "\");\n\t\t\t";
            m.body += "for( Object m : (Object[])tmpL" + count
                + ")\n\t\t\t";

          } else
          {
            m.body += "for( Object m : (Object[])value.get(\""
                + f.getName() + "\"))\n\t\t\t";
          }

          m.body += "{\n\t\t\t\t";

          m.body += "tmp" + count + ".add( new " + newRet.getName()
              + "( (" + ((ListType) type).type + ") m)";
          m.body += ");\n\t\t\t";

          m.body += "}\n\t\t";

          m.body += "}\n\t\t";

          m.body += "this." + f.getName() + " = tmp" + count
              + ";\n\n\n\t\t\t";

        } else
        {
          f.type = map.possibleEntries.get(p);
          // m.body += "this." + f.getName() + " = (" + f.type.getName()
          // + ") value.get(value.keySet().toArray()[" + count
          // + "]);\n\t\t";
          m.body += "if( value.keySet().contains(\"" + f.getName()
              + "\" ))\n\t\t";
          m.body += "{\n\t\t\t";

          if (map.valueType instanceof List
              || map.valueType instanceof ListType)
          {
            m.body += "Object tmpL" + count + " = value.get(\""
                + f.getName() + "\");\n\t\t\t";
            m.body += "for( Object m : (Object[])tmpL" + count
                + ")\n\t\t\t";

          } else
          {
            m.body += "for( Object m : (Object[])value.get(\""
                + f.getName() + "\"))\n\t\t\t";
          }

          m.body += "{\n\t\t\t\t";

          m.body += "this." + f.getName() + ".add(("
              + ((ListType) type).type + ") m";
          m.body += ");\n\t\t\t";

          m.body += "}\n\t\t";

          m.body += "}\n\t\t";

        }
      } else if (type instanceof MapType)
      {
        ClassDefinition newRet = new ClassDefinition();
        newRet.setName(m.name + p + appendName);
        newRet.packageName = packageName2;
        newRet.imports.add(new Type(Map.class));
        newRet.imports.add(new Type(List.class));
        newRet.implemented.add(stryctInterface);

        defs.addAll(generateStructs(newRet, packageName2, (MapType) type, isParameter));
        defs.add(newRet);
        f.type = newRet;
        m.body += "this." + f.getName() + " = new " + newRet.getName()
            + "( (" + f.type.getName() + ") value.get(" + count
            + "));\n\t\t";
      } else
      {
        f.type = map.possibleEntries.get(p);
        m.body += "this." + f.getName() + " = (" + f.type.getName()
            + ") value.get(\"" + f.getName() + "\");\n\t\t";
      }
      count++;
    }
    returnClass.definitions.add(m);
View Full Code Here

TOP

Related Classes of org.destecs.tools.jprotocolgenerator.ast.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.