Package org.codehaus.jam

Examples of org.codehaus.jam.JProperty


    }

    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

    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 + ");");
            } else if (type.equals("byte")) {
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();");
            } else if (type.equals("byte")) {
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

        }

        ArrayList<JProperty> properties = new ArrayList<JProperty>();
        jclass.getDeclaredProperties();
        for (int i = 0; i < jclass.getDeclaredProperties().length; i++) {
            JProperty p = jclass.getDeclaredProperties()[i];
            if (isValidProperty(p)) {
                properties.add(p);
            }
        }
        for (Iterator<JProperty> iter = properties.iterator(); iter.hasNext();) {
            JProperty property = 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

     */
    public List<JProperty> getProperties() {
        List<JProperty> answer = new ArrayList<JProperty>();
        JProperty[] properties = jclass.getDeclaredProperties();
        for (int i = 0; i < properties.length; i++) {
            JProperty property = properties[i];
            if (isValidProperty(property)) {
                answer.add(property);
            }
        }
        return answer;
View Full Code Here

            StringWriter buffer = new StringWriter();
            PrintWriter out = new PrintWriter(buffer);
            out.println("            int answer = 0;");
            Iterator iter = getProperties().iterator();
            while (iter.hasNext()) {
                JProperty property = (JProperty)iter.next();
                out.println("            answer = (answer * 37) + HashCode(" + property.getSimpleName() + ");");
            }
            out.println("            return answer;");
            return buffer.toString();
        }
        return null;
View Full Code Here

            StringWriter buffer = new StringWriter();
            PrintWriter out = new PrintWriter(buffer);

            Iterator iter = getProperties().iterator();
            while (iter.hasNext()) {
                JProperty property = (JProperty)iter.next();
                String name = property.getSimpleName();
                out.println("            if (! Equals(this." + name + ", that." + name + ")) return false;");
            }
            out.println("            return true;");
            return buffer.toString();
        }
View Full Code Here

        StringWriter buffer = new StringWriter();
        PrintWriter out = new PrintWriter(buffer);
        out.println("            return GetType().Name + \"[\"");
        Iterator iter = getProperties().iterator();
        while (iter.hasNext()) {
            JProperty property = (JProperty)iter.next();
            String name = property.getSimpleName();
            out.println("                + \" " + name + "=\" + " + name);
        }
        out.println("                + \" ]\";");
        return buffer.toString();
    }
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.