Package org.codehaus.jam

Examples of org.codehaus.jam.JClass


      out.println("        info." + setter + "((" + property.getType().getQualifiedName() + ") tightUnmarsalNestedObject(wireFormat, dataIn, bs));");
    }
  }

  protected void generateTightUnmarshalBodyForArrayProperty(PrintWriter out, JProperty property, JAnnotationValue size) {
    JClass propertyType = property.getType();
    String arrayType = propertyType.getArrayComponentType().getQualifiedName();
    String setter = property.getSetter().getSimpleName();
    out.println();
    if (size != null) {
      out.println("        {");
      out.println("            " + arrayType + " value[] = new " + arrayType + "[" + size.asInt() + "];");
View Full Code Here


    int baseSize = 0;
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
      JAnnotation annotation = property.getAnnotation("openwire:property");
      JAnnotationValue size = annotation.getValue("size");
      JClass propertyType = property.getType();
      String type = propertyType.getSimpleName();
      String getter = "info." + property.getGetter().getSimpleName() + "()";

      if (type.equals("boolean")) {
        out.println("        bs.writeBoolean(" + getter + ");");
      } else if (type.equals("byte")) {
        baseSize += 1;
      } else if (type.equals("char")) {
        baseSize += 2;
      } else if (type.equals("short")) {
        baseSize += 2;
      } else if (type.equals("int")) {
        baseSize += 4;
      } else if (type.equals("long")) {
        out.println("        rc+=tightMarshalLong1(wireFormat, " + getter + ", bs);");
      } else if (type.equals("String")) {
        out.println("        rc += tightMarshalString1(" + getter + ", bs);");
      } else if (type.equals("byte[]")) {
        if (size == null) {
          out.println("        rc += tightMarshalByteArray1(" + getter + ", bs);");
        } else {
          out.println("        rc += tightMarshalConstByteArray1(" + getter + ", bs, " + size.asInt() + ");");
        }
      } else if (type.equals("ByteSequence")) {
        out.println("        rc += tightMarshalByteSequence1(" + getter + ", bs);");
      } else if (propertyType.isArrayType()) {
        if (size != null) {
          out.println("        rc += tightMarshalObjectArrayConstSize1(wireFormat, " + getter + ", bs, " + size.asInt() + ");");
        } else {
          out.println("        rc += tightMarshalObjectArray1(wireFormat, " + getter + ", bs);");
        }
View Full Code Here

    List properties = getProperties();
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
      JAnnotation annotation = property.getAnnotation("openwire:property");
      JAnnotationValue size = annotation.getValue("size");
      JClass propertyType = property.getType();
      String type = propertyType.getSimpleName();
      String getter = "info." + property.getGetter().getSimpleName() + "()";

      if (type.equals("boolean")) {
        out.println("        bs.readBoolean();");
      } else if (type.equals("byte")) {
        out.println("        dataOut.writeByte(" + getter + ");");
      } else if (type.equals("char")) {
        out.println("        dataOut.writeChar(" + getter + ");");
      } else if (type.equals("short")) {
        out.println("        dataOut.writeShort(" + getter + ");");
      } else if (type.equals("int")) {
        out.println("        dataOut.writeInt(" + getter + ");");
      } else if (type.equals("long")) {
        out.println("        tightMarshalLong2(wireFormat, " + getter + ", dataOut, bs);");
      } else if (type.equals("String")) {
        out.println("        tightMarshalString2(" + getter + ", dataOut, bs);");
      } else if (type.equals("byte[]")) {
        String mandatory = getMandatoryFlag(annotation);
        if (size != null) {
          out.println("        tightMarshalConstByteArray2(" + getter + ", dataOut, bs, " + size.asInt() + ");");
        } else {
          out.println("        tightMarshalByteArray2(" + getter + ", dataOut, bs);");
        }
      } else if (type.equals("ByteSequence")) {
        out.println("        tightMarshalByteSequence2(" + getter + ", dataOut, bs);");
      } else if (propertyType.isArrayType()) {
        if (size != null) {
          out.println("        tightMarshalObjectArrayConstSize2(wireFormat, " + getter + ", dataOut, bs, " + size.asInt() + ");");
        } else {
          out.println("        tightMarshalObjectArray2(wireFormat, " + getter + ", dataOut, bs);");
        }
View Full Code Here

    List properties = getProperties();
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
      JAnnotation annotation = property.getAnnotation("openwire:property");
      JAnnotationValue size = annotation.getValue("size");
      JClass propertyType = property.getType();
      String type = propertyType.getSimpleName();
      String getter = "info." + property.getGetter().getSimpleName() + "()";

      if (type.equals("boolean")) {
        out.println("        dataOut.writeBoolean(" + getter + ");");
      } else if (type.equals("byte")) {
        out.println("        dataOut.writeByte(" + getter + ");");
      } else if (type.equals("char")) {
        out.println("        dataOut.writeChar(" + getter + ");");
      } else if (type.equals("short")) {
        out.println("        dataOut.writeShort(" + getter + ");");
      } else if (type.equals("int")) {
        out.println("        dataOut.writeInt(" + getter + ");");
      } else if (type.equals("long")) {
        out.println("        looseMarshalLong(wireFormat, " + getter + ", dataOut);");
      } else if (type.equals("String")) {
        out.println("        looseMarshalString(" + getter + ", dataOut);");
      } else if (type.equals("byte[]")) {
        if (size != null) {
          out.println("        looseMarshalConstByteArray(wireFormat, " + getter + ", dataOut, " + size.asInt() + ");");
        } else {
          out.println("        looseMarshalByteArray(wireFormat, " + getter + ", dataOut);");
        }
      } else if (type.equals("ByteSequence")) {
        out.println("        looseMarshalByteSequence(wireFormat, " + getter + ", dataOut);");
      } else if (propertyType.isArrayType()) {
        if (size != null) {
          out.println("        looseMarshalObjectArrayConstSize(wireFormat, " + getter + ", dataOut, " + size.asInt() + ");");
        } else {
          out.println("        looseMarshalObjectArray(wireFormat, " + getter + ", dataOut);");
        }
View Full Code Here

    List properties = getProperties();
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
      JAnnotation annotation = property.getAnnotation("openwire:property");
      JAnnotationValue size = annotation.getValue("size");
      JClass propertyType = property.getType();
      String propertyTypeName = propertyType.getSimpleName();

      if (propertyType.isArrayType() && !propertyTypeName.equals("byte[]")) {
        generateLooseUnmarshalBodyForArrayProperty(out, property, size);
      } else {
        generateLooseUnmarshalBodyForProperty(out, property, size);
      }
    }
View Full Code Here

      out.println("        info." + setter + "((" + property.getType().getQualifiedName() + ") looseUnmarsalNestedObject(wireFormat, dataIn));");
    }
  }

  protected void generateLooseUnmarshalBodyForArrayProperty(PrintWriter out, JProperty property, JAnnotationValue size) {
    JClass propertyType = property.getType();
    String arrayType = propertyType.getArrayComponentType().getQualifiedName();
    String setter = property.getSetter().getSimpleName();
    out.println();
    if (size != null) {
      out.println("        {");
      out.println("            " + arrayType + " value[] = new " + arrayType + "[" + size.asInt() + "];");
View Full Code Here

    protected List sort(List source) {
        LinkedHashMap rc = new LinkedHashMap();
      ArrayList classes = new ArrayList(source);
        Collections.sort(classes, new Comparator(){
      public int compare(Object o1, Object o2) {
        JClass c1 = (JClass) o1;
        JClass c2 = (JClass) o2;
        return c1.getSimpleName().compareTo(c2.getSimpleName());
      }});
     
        // lets make a map of all the class names
        HashMap classNames = new HashMap();
        for (Iterator iter = classes.iterator(); iter.hasNext();) {
            JClass c = (JClass) iter.next();
            classNames.put(c, c);
        }

        // Add all classes that have no parent first
        for (Iterator iter = classes.iterator(); iter.hasNext();) {
            JClass c = (JClass) iter.next();
            if (!classNames.containsKey(c.getSuperclass()))
                rc.put(c, c);
        }

        // now lets add the rest
        for (Iterator iter = classes.iterator(); iter.hasNext();) {
            JClass c = (JClass) iter.next();
            if (!rc.containsKey(c))
                rc.put(c,c);
        }

        return new ArrayList(rc.keySet());
View Full Code Here

out.println("#define OW_WIREFORMAT_TCP_NO_DELAY_MASK    0x00000002;");
out.println("#define OW_WIREFORMAT_CACHE_MASK           0x00000004;");
out.println("#define OW_WIREFORMAT_COMPRESSION_MASK     0x00000008;");

    for (Iterator iterator = sortedClasses.iterator(); iterator.hasNext();) {
      JClass jclass = (JClass) iterator.next();
        String name = jclass.getSimpleName();
        String type = ("ow_"+name).toUpperCase()+"_TYPE";
        if( !isAbstract(jclass) ) {
          out.println("#define "+type+" "+getOpenWireOpCode(jclass));
        }
     }
View Full Code Here

out.println("    /// </summary>");
  out.print("    public class "+jclass.getSimpleName()+" : "+baseClass);


    for (int i = 0; i < jclass.getInterfaces().length; i++) {
    JClass intf = jclass.getInterfaces()[i];
    out.print(", "+intf.getSimpleName());
  }
   
out.println("");
out.println("    {");
out.println("        public const byte ID_"+jclass.getSimpleName()+" = "+getOpenWireOpCode(jclass)+";");
View Full Code Here

    mJoust = joust;
  }

  public void doCodegen() throws IOException {
    while(mClassesLeftTodo.size() > 0) {
      JClass clazz = (JClass)mClassesLeftTodo.get(0);
      mClassesLeftTodo.remove(0);
      mClassesDone.add(clazz);
      doCodegen(clazz);
    }
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jam.JClass

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.