Package org.codehaus.jam

Examples of org.codehaus.jam.JProperty


out.println(""+className+"::"+className+"()");
out.println("{");

    List properties = getProperties();
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
          String value = toCppDefaultValue(property.getType());
          String propertyName = property.getSimpleName();
          String parameterName = decapitalize(propertyName);
out.println("    this->"+parameterName+" = "+value+" ;");
    }
out.println("}");
out.println("");
out.println(""+className+"::~"+className+"()");
out.println("{");
out.println("}");
out.println("");
out.println("unsigned char "+className+"::getDataStructureType()");
out.println("{");
out.println("    return "+className+"::TYPE ; ");
out.println("}");
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
          String type = toCppType(property.getType());
          String propertyName = property.getSimpleName();
          String parameterName = decapitalize(propertyName);
out.println("");
out.println("        ");
out.println(""+type+" "+className+"::get"+propertyName+"()");
out.println("{");
out.println("    return "+parameterName+" ;");
out.println("}");
out.println("");
out.println("void "+className+"::set"+propertyName+"("+type+" "+parameterName+")");
out.println("{");
out.println("    this->"+parameterName+" = "+parameterName+" ;");
out.println("}");
      }
out.println("");
out.println("int "+className+"::marshal(p<IMarshaller> marshaller, int mode, p<IOutputStream> ostream) throw (IOException)");
out.println("{");
out.println("    int size = 0 ;");
out.println("");
out.println("    size += "+baseClass+"::marshal(marshaller, mode, ostream) ; ");

    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
          String marshalMethod = toMarshalMethodName(property.getType());
          String propertyName = decapitalize(property.getSimpleName());
out.println("    size += marshaller->"+marshalMethod+"("+propertyName+", mode, ostream) ; ");
      }
out.println("    return size ;");
out.println("}");
out.println("");
out.println("void "+className+"::unmarshal(p<IMarshaller> marshaller, int mode, p<IInputStream> istream) throw (IOException)");
out.println("{");
out.println("    "+baseClass+"::unmarshal(marshaller, mode, istream) ; ");
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
          String cast = toUnmarshalCast(property.getType());
          String unmarshalMethod = toUnmarshalMethodName(property.getType());
          String propertyName = decapitalize(property.getSimpleName());
out.println("    "+propertyName+" = "+cast+"(marshaller->"+unmarshalMethod+"(mode, istream)) ; ");
      }
out.println("}");
  }
View Full Code Here


    protected int generateMarshal1Body(PrintWriter out) {
        List properties = getProperties();
        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() + "()";

            out.print(indent);
            if (type.equals("boolean")) {
                out.println("bs.writeBoolean(" + getter + ");");
            }
View Full Code Here

    }

    protected void generateMarshal2Body(PrintWriter out) {
        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() + "()";

            out.print(indent);
            if (type.equals("boolean")) {
                out.println("bs.readBoolean();");
            }
View Full Code Here

out.println("#include <string>");
out.println("#include \"activemq/command/"+baseClass+".hpp\"");

    List properties = getProperties();
    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
        if( !property.getType().isPrimitiveType() &&
            !property.getType().getSimpleName().equals("String") &&
            !property.getType().getSimpleName().equals("ByteSequence") )
        {
            String includeName = toCppType(property.getType());
            if( property.getType().isArrayType() )
            {
                JClass arrayType = property.getType().getArrayComponentType();
                if( arrayType.isPrimitiveType() )
                    continue ;
            }
            if( includeName.startsWith("array<") )
                includeName = includeName.substring(6, includeName.length()-1);
            else if( includeName.startsWith("p<") )
                includeName = includeName.substring(2, includeName.length()-1);
   
            if( includeName.equals("IDataStructure") ) {
out.println("#include \"activemq/"+includeName+".hpp\"");
        else {
out.println("#include \"activemq/command/"+includeName+".hpp\"");
        }
        }
    }
out.println("");
out.println("#include \"activemq/protocol/IMarshaller.hpp\"");
out.println("#include \"ppr/io/IOutputStream.hpp\"");
out.println("#include \"ppr/io/IInputStream.hpp\"");
out.println("#include \"ppr/io/IOException.hpp\"");
out.println("#include \"ppr/util/ifr/array\"");
out.println("#include \"ppr/util/ifr/p\"");
out.println("");
out.println("namespace apache");
out.println("{");
out.println("  namespace activemq");
out.println("  {");
out.println("    namespace command");
out.println("    {");
out.println("      using namespace ifr;");
out.println("      using namespace std;");
out.println("      using namespace apache::activemq;");
out.println("      using namespace apache::activemq::protocol;");
out.println("      using namespace apache::ppr::io;");
out.println("");
out.println("/*");
out.println(" *");
out.println(" *  Command and marshalling code for OpenWire format for "+className+"");
out.println(" *");
out.println(" *");
out.println(" *  NOTE!: This file is autogenerated - do not modify!");
out.println(" *         if you need to make a change, please see the Groovy scripts in the");
out.println(" *         activemq-core module");
out.println(" *");
out.println(" */");
out.println("class "+className+" : public "+baseClass+"");
out.println("{");
out.println("protected:");

    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
          String type = toCppType(property.getType());
          String name = decapitalize(property.getSimpleName());
out.println("    "+type+" "+name+" ;");
      }
out.println("");
out.println("public:");
out.println("    const static unsigned char TYPE = "+getOpenWireOpCode(jclass)+";");
out.println("");
out.println("public:");
out.println("    "+className+"() ;");
out.println("    virtual ~"+className+"() ;");
out.println("");
out.println("    virtual unsigned char getDataStructureType() ;");

    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      JProperty property = (JProperty) iter.next();
          String type = toCppType(property.getType());
          String propertyName = property.getSimpleName();
          String parameterName = decapitalize(propertyName);
out.println("");
out.println("    virtual "+type+" get"+propertyName+"() ;");
out.println("    virtual void set"+propertyName+"("+type+" "+parameterName+") ;");
      }
View Full Code Here

  }

  protected void generateTightUnmarshalBody(PrintWriter out) {
    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[]")) {
        generateTightUnmarshalBodyForArrayProperty(out, property, size);
      } else {
View Full Code Here

  protected int generateTightMarshal1Body(PrintWriter out) {
    List properties = getProperties();
    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;
View Full Code Here

  }

  protected void generateTightMarshal2Body(PrintWriter out) {
    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 + ");");
View Full Code Here

  }

  protected void generateLooseMarshalBody(PrintWriter out) {
    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 + ");");
View Full Code Here

  }

  protected void generateLooseUnmarshalBody(PrintWriter out) {
    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 {
View Full Code Here

        }

        ArrayList properties = new ArrayList();
        jclass.getDeclaredProperties();
        for (int i = 0; i < jclass.getDeclaredProperties().length; i++) {
            JProperty p = jclass.getDeclaredProperties()[i];
            if (isValidProperty(p)) {
                properties.add(p);
            }
        }
        for (Iterator iter = properties.iterator(); iter.hasNext();) {
            JProperty property = (JProperty) iter.next();
            JAnnotation annotation = property.getGetter().getAnnotation("openwire:property");
            JAnnotationValue size = annotation.getValue("size");
            String name = toPropertyCase(property.getSimpleName());
            boolean cached = isCachedProperty(property);

            String type = property.getType().getQualifiedName();
            if (type.equals("boolean")) {
                out.println("   ow_"+type+" "+name+";");
            } else if (type.equals("byte")) {
                out.println("   ow_"+type+" "+name+";");
            } else if (type.equals("char")) {
                out.println("   ow_"+type+" "+name+";");
            } else if (type.equals("short")) {
                out.println("   ow_"+type+" "+name+";");
            } else if (type.equals("int")) {
                out.println("   ow_"+type+" "+name+";");
            } else if (type.equals("long")) {
                out.println("   ow_"+type+" "+name+";");
            } else if (type.equals("byte[]")) {
                out.println("   ow_byte_array *"+name+";");
            } else if (type.equals("org.apache.activeio.packet.ByteSequence")) {
                out.println("   ow_byte_array *"+name+";");
            } else if (type.equals("org.apache.activeio.packet.ByteSequence")) {
                out.println("   ow_byte_array *"+name+";");
            } else if (type.equals("java.lang.String")) {
                out.println("   ow_string *"+name+";");
            } else {
                if (property.getType().isArrayType()) {
                    out.println("   ow_DataStructure_array *"+name+";");
                } else if (isThrowable(property.getType())) {
                    out.println("   ow_throwable *"+name+";");
                } else {
                    out.println("   struct ow_" + property.getType().getSimpleName() + " *"+name+";");
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jam.JProperty

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.