Package org.codehaus.jam

Examples of org.codehaus.jam.JProperty


out.println("");
out.println("#include <activemq/connector/openwire/commands/"+baseClass+".h>");

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("std::vector") ) {
            includeName = includeName.substring(12, includeName.length()-2);
        }

        out.println("#include <activemq/connector/openwire/commands/"+includeName+".h>");
    }
}

out.println("#include <vector>");
out.println("#include <string>");
out.println("");
out.println("namespace activemq{");
out.println("namespace connector{");
out.println("namespace openwire{");
out.println("namespace commands{");
out.println("");
out.println("    /*");
out.println("     *");
out.println("     *  Command and marshaling 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 Java Classes");
out.println("     *         in the activemq-openwire-generator module");
out.println("     *");
out.println("     */");
out.println("    class "+className+" : public "+getProperBaseClassName( className, baseClass ) );
out.println("    {");
out.println("    protected:");
out.println("");

       for (Iterator iter = properties.iterator(); iter.hasNext();) {
            JProperty property = (JProperty) iter.next();
            String type = toCppType(property.getType());
            String name = decapitalize(property.getSimpleName());

            if( !property.getType().isPrimitiveType() &&
                !property.getType().getSimpleName().equals("ByteSequence") &&
                !property.getType().getSimpleName().equals("String") &&
                !type.startsWith("std::vector") ) {

                type = type + "*";
            }

            out.println("        "+type+" "+name+";");

       }

        String typeName = className.toUpperCase();

out.println("");
out.println("    public:");
out.println("");
out.println("        const static unsigned char ID_"+typeName+" = "+getOpenWireOpCode(jclass)+";");
out.println("");
out.println("    public:");
out.println("");
out.println("        "+className+"();");
out.println("        virtual ~"+className+"();");
out.println("");
out.println("        /**");
out.println("         * Get the unique identifier that this object and its own");
out.println("         * Marshaller share.");
out.println("         * @returns new DataStructure type copy.");
out.println("         */");
out.println("        virtual unsigned char getDataStructureType() const;");
out.println("");
out.println("        /**");
out.println("         * Clone this object and return a new instance that the");
out.println("         * caller now owns, this will be an exact copy of this one");
out.println("         * @returns new copy of this object.");
out.println("         */");
out.println("        virtual DataStructure* cloneDataStructure() const;");
out.println("");
out.println("        /**");
out.println("         * Copy the contents of the passed object into this object's");
out.println("         * members, overwriting any existing data.");
out.println("         * @param src - Source Object");
out.println("         */");
out.println("        virtual void copyDataStructure( const DataStructure* src );");
out.println("");
out.println("        /**");
out.println("         * Returns a string containing the information for this DataStructure");
out.println("         * such as its type and value of its elements.");
out.println("         * @return formatted string useful for debugging.");
out.println("         */");
out.println("        virtual std::string toString() const;");
out.println("");
out.println("        /**" );
out.println("         * Compares the DataStructure passed in to this one, and returns if" );
out.println("         * they are equivalent.  Equivalent here means that they are of the" );
out.println("         * same type, and that each element of the objects are the same." );
out.println("         * @returns true if DataStructure's are Equal." );
out.println("         */" );
out.println("        virtual bool equals( const DataStructure* value ) const;" );
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);
            String constness = "";

            if( !property.getType().isPrimitiveType() &&
                !property.getType().getSimpleName().equals("ByteSequence") &&
                !property.getType().getSimpleName().equals("String") &&
                !type.startsWith("std::vector") ) {

                    type = type + "*";
            } else if( property.getType().getSimpleName().equals("String") ||
                       type.startsWith("std::vector") ) {

                type = type + "&";
                constness = "const ";
            }

            if( property.getType().isPrimitiveType() ) {
out.println("        virtual "+type+" "+property.getGetter().getSimpleName()+"() const;");
            } else {
out.println("        virtual const "+type+" "+property.getGetter().getSimpleName()+"() const;");
out.println("        virtual "+type+" "+property.getGetter().getSimpleName()+"();");
            }

out.println("        virtual void "+property.getSetter().getSimpleName()+"( "+constness+type+" "+parameterName+" );");
out.println("");
        }

out.println("    };");
out.println("");
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.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.getSimpleName();

            if (type.equals("boolean")) {
                out.println("        bs.ReadBoolean();");
            } else if (type.equals("byte")) {
                out.println("        dataOut.Write(" + 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.getSimpleName();

            if (type.equals("boolean")) {
                out.println("        dataOut.Write(" + getter + ");");
            } else if (type.equals("byte")) {
                out.println("        dataOut.Write(" + getter + ");");
View Full Code Here

        TestDataGenerator generator = new TestDataGenerator();

        List properties = getProperties();
        for (Iterator iter = properties.iterator(); iter.hasNext();) {
            JProperty property = (JProperty)iter.next();

            JAnnotation annotation = property.getAnnotation("openwire:property");
            String size = stringValue(annotation, "size");
            String testSize = stringValue(annotation, "testSize");
            String type = property.getType().getSimpleName();
//            boolean cached = isCachedProperty(property);
            String propertyName = property.getSimpleName();
            if ("-1".equals(testSize)) {
                continue;
            }

            String setterName = property.getSetter().getSimpleName();

            if (type.equals("boolean")) {
                out.println("        info." + setterName + "(" + generator.createBool() + ");");
            } else if (type.equals("byte")) {
                out.println("        info." + setterName + "(" + generator.createByte() + ");");
            } else if (type.equals("char")) {
                out.println("        info." + setterName + "(" + generator.createChar() + ");");
            } else if (type.equals("short")) {
                out.println("        info." + setterName + "(" + generator.createShort() + ");");
            } else if (type.equals("int")) {
                out.println("        info." + setterName + "(" + generator.createInt() + ");");
            } else if (type.equals("long")) {
                out.println("        info." + setterName + "(" + generator.createLong() + ");");
            } else if (type.equals("byte[]")) {
                out.println("        info." + setterName + "(" + generator.createByteArray(propertyName) + ");");
            } else if (type.equals("String")) {
                out.println("        info." + setterName + "(\"" + generator.createString(propertyName) + "\");");
            } else if (type.equals("ByteSequence")) {
                out.println("        {");
                out.println("            byte data[] = " + generator.createByteArray(propertyName) + ";");
                out.println("            info." + setterName + "(new org.apache.activemq.util.ByteSequence(data,0,data.length));");
                out.println("}");
            } else if (type.equals("Throwable")) {
                out.println("        info." + setterName + "(createThrowable(\"" + generator.createString(propertyName) + "\"));");
            } else {
                if (property.getType().isArrayType()) {
                    String arrayType = property.getType().getArrayComponentType().getSimpleName();
                    if (size == null) {
                        size = "2";
                    }
                    if (arrayType == jclass.getSimpleName()) {
                        size = "0";
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

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.