Package org.codehaus.jam

Examples of org.codehaus.jam.JProperty


  public JProperty addNewDeclaredProperty(String name, JMethod getter, JMethod setter) {
    if (mDeclaredProperties == null) mDeclaredProperties = new ArrayList();
    String typeName = (getter != null) ?
      getter.getReturnType().getFieldDescriptor() :
      setter.getParameters()[0].getType().getFieldDescriptor();
    JProperty out = new PropertyImpl(name,getter,setter,typeName);
    mDeclaredProperties.add(out);
    return out;
  }
View Full Code Here


                                                   XmlSchemaComplexType complexType,
                                                   XmlSchema xmlSchema) throws Exception {
        JProperty[] properties = javaType.getDeclaredProperties();

        for (int i = 0; i < properties.length; i++) {
            JProperty property = properties[i];
            String propertyName = property.getType().getQualifiedName();
            boolean isArryType = property.getType().isArrayType();
            if (isArryType) {
                propertyName = property.getType().getArrayComponentType().getQualifiedName();
            }

            if (typeTable.isSimpleType(propertyName)) {
                XmlSchemaElement elt1 = new XmlSchemaElement();
                elt1.setName(getCorrectName(property.getSimpleName()));
                elt1.setSchemaTypeName(typeTable.getSimpleSchemaTypeName(propertyName));
                ((XmlSchemaGroupBase) complexType.getParticle()).getItems().add(elt1);
                if (isArryType) {
                    elt1.setMaxOccurs(Long.MAX_VALUE);
                    elt1.setMinOccurs(0);
                }
            } else {
                QName schemaTypeName = null;
                if (isArryType) {
                    schemaTypeName = generateSchema(property.getType().getArrayComponentType());
                } else {
                    schemaTypeName = generateSchema(property.getType());
                }

                XmlSchemaElement elt1 = new XmlSchemaElement();
                elt1.setName(getCorrectName(property.getSimpleName()));
                elt1.setSchemaTypeName(schemaTypeName);
                ((XmlSchemaGroupBase) complexType.getParticle()).getItems().add(elt1);

                if (isArryType) {
                    elt1.setMaxOccurs(Long.MAX_VALUE);
View Full Code Here

                                                   XmlSchemaComplexType complexType,
                                                   XmlSchema xmlSchema) throws Exception {
        JProperty[] properties = javaType.getDeclaredProperties();

        for (int i = 0; i < properties.length; i++) {
            JProperty property = properties[i];
            String propertyName = property.getType().getQualifiedName();
            boolean isArryType = property.getType().isArrayType();
            if (isArryType) {
                propertyName = property.getType().getArrayComponentType().getQualifiedName();
            }

            if (typeTable.isSimpleType(propertyName)) {
                XmlSchemaElement elt1 = new XmlSchemaElement();
                elt1.setName(getCorrectName(property.getSimpleName()));
                elt1.setSchemaTypeName(typeTable.getSimpleSchemaTypeName(propertyName));
                ((XmlSchemaGroupBase) complexType.getParticle()).getItems().add(elt1);
                if (isArryType) {
                    elt1.setMaxOccurs(Long.MAX_VALUE);
                    elt1.setMinOccurs(0);
                }
            } else {
                QName schemaTypeName = null;
                if (isArryType) {
                    schemaTypeName = generateSchema(property.getType().getArrayComponentType());
                } else {
                    schemaTypeName = generateSchema(property.getType());
                }

                XmlSchemaElement elt1 = new XmlSchemaElement();
                elt1.setName(getCorrectName(property.getSimpleName()));
                elt1.setSchemaTypeName(schemaTypeName);
                ((XmlSchemaGroupBase) complexType.getParticle()).getItems().add(elt1);

                if (isArryType) {
                    elt1.setMaxOccurs(Long.MAX_VALUE);
View Full Code Here

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

        List properties = getProperties();
        for (Iterator iter = properties.iterator(); iter.hasNext();) {
            JProperty property = (JProperty) iter.next();
            String type = toCppType(property.getType());
            String value = toCppDefaultValue(property.getType());
            String propertyName = property.getSimpleName();
            String parameterName = decapitalize(propertyName);

            if( !type.startsWith("std::vector") ) {
out.println("    this->"+parameterName+" = "+value+";");
            }
        }
out.println("}");
out.println("");
out.println("////////////////////////////////////////////////////////////////////////////////");
out.println(""+className+"::~"+className+"()");
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);

        if( property.getType().isPrimitiveType() ||
            property.getType().getSimpleName().equals("String") ) {
            continue;
        }

        if( !type.startsWith("std::vector" ) ) {
out.println("    delete this->" + parameterName + ";");
        } else if( type.contains( "*" ) ) {
out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < " + parameterName + ".size(); ++i" + parameterName + " ) {");
out.println("        delete " + parameterName + "[i" + parameterName + "];");
out.println("    }");
        }
    }
out.println("}");

out.println("");
out.println("////////////////////////////////////////////////////////////////////////////////");
out.println(className+"* "+className+"::cloneDataStructure() const {");

    String newInstance = decapitalize( className );

out.println("    std::auto_ptr<"+className+"> "+newInstance+"( new "+className+"() );");
out.println("");
out.println("    // Copy the data from the base class or classes");
out.println("    "+newInstance+"->copyDataStructure( this );");
out.println("");
out.println("    return "+newInstance+".release();");
out.println("}");

out.println("");
out.println("////////////////////////////////////////////////////////////////////////////////");
out.println("void "+className+"::copyDataStructure( const DataStructure* src ) {");
out.println("");

        if( baseClass != null ) {
out.println("    // Copy the data of the base class or classes");
out.println("    "+getProperBaseClassName( className, baseClass )+"::copyDataStructure( src );");
out.println("");
        }

out.println("    const "+className+"* srcPtr = dynamic_cast<const "+className+"*>( src );");
out.println("");
out.println("    if( srcPtr == NULL || src == NULL ) {");
out.println("");
out.println("        throw decaf::lang::exceptions::NullPointerException(");
out.println("            __FILE__, __LINE__,");
out.println("            \""+className+"::copyDataStructure - src is NULL or invalid\" );");
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 = "";
        String getter = property.getGetter().getSimpleName();
        String setter = property.getSetter().getSimpleName();

        if( property.getType().isPrimitiveType() ||
            type.equals("std::string") ||
            property.getType().getSimpleName().equals("ByteSequence") ){
    out.println("    this->"+setter+"( srcPtr->"+getter+"() );");
        } else if( property.getType().isArrayType() &&
                   !property.getType().getArrayComponentType().isPrimitiveType() ) {

            String arrayType = property.getType().getArrayComponentType().getSimpleName();

    out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < srcPtr->"+getter+"().size(); ++i" + parameterName + " ) {");
    out.println("        if( srcPtr->"+getter+"()[i"+parameterName+"] != NULL ) {");
    out.println("            this->"+getter+"().push_back(");
    out.println("                dynamic_cast<"+arrayType+"*>(");
    out.println("                    srcPtr->"+getter+"()[i"+parameterName+"]->cloneDataStructure() ) );");
    out.println("        } else {");
    out.println("            this->"+getter+"().push_back( NULL );");
    out.println("        }");
    out.println("    }");
        } else if( property.getType().isArrayType() &&
                   property.getType().getArrayComponentType().isPrimitiveType() ) {
    out.println("    this->"+setter+"( srcPtr->"+getter+"() );");
        } else {
    out.println("    if( srcPtr->"+getter+"() != NULL ) {");
    out.println("        this->"+setter+"(");
    out.println("            dynamic_cast<"+type+"*>(");
    out.println("                srcPtr->"+getter+"()->cloneDataStructure() ) );");
    out.println("    }");
        }
    }

out.println("}");


// getDataStructureType

out.println("");
out.println("////////////////////////////////////////////////////////////////////////////////");
out.println("unsigned char "+className+"::getDataStructureType() const {");
out.println("    return "+className+"::ID_" + className.toUpperCase() + ";");
out.println("}");

// toString

out.println("");
out.println("////////////////////////////////////////////////////////////////////////////////");
out.println("std::string "+className+"::toString() const {");
out.println("");

out.println("    ostringstream stream;" );
out.println("");
out.println("    stream << \"Begin Class = "+className+"\" << std::endl;" );
out.println("    stream << \" Value of "+className+"::ID_" + className.toUpperCase() + " = "+getOpenWireOpCode(jclass)+"\" << std::endl;");

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 = "";
    String getter = property.getGetter().getSimpleName();
    String setter = property.getSetter().getSimpleName();

    if( property.getType().getSimpleName().equals("ByteSequence") ) {

out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < this->"+getter+"().size(); ++i" + parameterName + " ) {");
out.println("        stream << \" Value of "+propertyName+"[\" << i" + parameterName+" << \"] = \" << this->"+getter+"()[i"+parameterName+"] << std::endl;" );
out.println("    }" );

    } else if( type.equals("unsigned char") ){

out.println("    stream << \" Value of "+propertyName+" = \" << (int)this->"+getter+"() << std::endl;");

    } else if( property.getType().isPrimitiveType() ||
               type.equals("std::string") ){

out.println("    stream << \" Value of "+propertyName+" = \" << this->"+getter+"() << std::endl;");

    } else if( property.getType().isArrayType() &&
               !property.getType().getArrayComponentType().isPrimitiveType() ) {

        String arrayType = property.getType().getArrayComponentType().getSimpleName();

out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < this->"+getter+"().size(); ++i" + parameterName + " ) {");
out.println("        stream << \" Value of "+propertyName+"[\" << i" + parameterName+" << \"] is Below:\" << std::endl;" );
out.println("        if( this->"+getter+"()[i"+parameterName+"] != NULL ) {");
out.println("            stream << this->"+getter+"()[i"+parameterName+"]->toString() << std::endl;");
out.println("        } else {");
out.println("            stream << \"   Object is NULL\" << std::endl;");
out.println("        }");
out.println("    }");
    } else if( property.getType().isArrayType() &&
               property.getType().getArrayComponentType().isPrimitiveType() ) {
out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < this->"+getter+"().size(); ++i" + parameterName + " ) {");
out.println("        stream << \" Value of "+propertyName+"[\" << i"+parameterName+" << \"] = \" << this->"+getter+"()[i"+parameterName+"] << std::endl;");
out.println("    }");
    } else {
out.println("    stream << \" Value of "+propertyName+" is Below:\" << std::endl;" );
out.println("    if( this->"+getter+"() != NULL ) {");
out.println("        stream << this->"+getter+"()->toString() << std::endl;");
out.println("    } else {");
out.println("        stream << \"   Object is NULL\" << std::endl;");
out.println("    }");
    }
}

    if( baseClass != null ) {
out.println("    stream << "+getProperBaseClassName( className, baseClass )+"::toString();");
    }

out.println("    stream << \"End Class = "+className+"\" << std::endl;" );
out.println("");
out.println("    return stream.str();");
out.println("}");

// equals

out.println("");
out.println("////////////////////////////////////////////////////////////////////////////////");
out.println("bool "+className+"::equals( const DataStructure* value ) const {");

out.println("    const "+className+"* valuePtr = dynamic_cast<const "+className+"*>( value );");
out.println("");
out.println("    if( valuePtr == NULL || value == NULL ) {");
out.println("        return false;");
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 = "";
    String getter = property.getGetter().getSimpleName();
    String setter = property.getSetter().getSimpleName();

    if( property.getType().getSimpleName().equals("ByteSequence") ) {

out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < this->"+getter+"().size(); ++i" + parameterName + " ) {");
out.println("        if( this->"+getter+"()[i" + parameterName+"] != valuePtr->"+getter+"()[i"+parameterName+"] ) {" );
out.println("            return false;" );
out.println("        }" );
out.println("    }" );

    } else if( property.getType().isPrimitiveType() ||
               type.equals("std::string") ){

out.println("    if( this->"+getter+"() != valuePtr->"+getter+"() ) {");
out.println("        return false;" );
out.println("    }" );

    } else if( property.getType().isArrayType() &&
               !property.getType().getArrayComponentType().isPrimitiveType() ) {

        String arrayType = property.getType().getArrayComponentType().getSimpleName();

out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < this->"+getter+"().size(); ++i" + parameterName + " ) {");
out.println("        if( this->"+getter+"()[i"+parameterName+"] != NULL ) {" );
out.println("            if( !this->"+getter+"()[i"+parameterName+"]->equals( valuePtr->"+getter+"()[i"+parameterName+"] ) ) {" );
out.println("                return false;");
out.println("            }");
out.println("        } else if( valuePtr->"+getter+"()[i"+parameterName+"] != NULL ) {");
out.println("            return false;");
out.println("        }");
out.println("    }");
    } else if( property.getType().isArrayType() &&
               property.getType().getArrayComponentType().isPrimitiveType() ) {
out.println("    for( size_t i" + parameterName + " = 0; i" + parameterName + " < this->"+getter+"().size(); ++i" + parameterName + " ) {");
out.println("        if( this->"+getter+"()[i"+parameterName+"] != valuePtr->"+getter+"()[i"+parameterName+"] ) {");
out.println("            return false;");
out.println("        }");
out.println("    }");
    } else {
out.println("    if( this->"+getter+"() != NULL ) {");
out.println("        if( !this->"+getter+"()->equals( valuePtr->"+getter+"() ) ) {" );
out.println("            return false;");
out.println("        }");
out.println("    } else if( valuePtr->"+getter+"() != NULL ) {");
out.println("        return false;");
out.println("    }");
    }
}

    if( baseClass != null ) {
out.println("    if( !"+getProperBaseClassName( className, baseClass )+"::equals( value ) ) {");
out.println("        return false;");
out.println("    }");
    }

out.println("    return true;" );
out.println("}");

   if( className.equals( "Message" ) ) {
out.println("");
out.println("////////////////////////////////////////////////////////////////////////////////");
out.println("unsigned int "+className+"::getSize() const {");
out.println("");
out.println("    unsigned int size = DEFAULT_MESSAGE_SIZE;");
out.println("");
out.println("    size += (unsigned int)this->getContent().size();");
out.println("    size += (unsigned int)this->getMarshalledProperties().size();");
out.println("");
out.println("    return size;");
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 getter = property.getGetter().getSimpleName();
            String setter = property.getSetter().getSimpleName();
            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 ";
            }


out.println("");

    if( property.getType().isPrimitiveType() ) {

out.println("////////////////////////////////////////////////////////////////////////////////");
out.println(type+" "+className+"::"+getter+"() const {");
out.println("    return "+parameterName+";");
out.println("}");
View Full Code Here

out.println("#include <activemq/util/Config.h>");
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 AMQCPP_API "+className+" : public "+getProperBaseClassName( className, baseClass ) );
out.println("    {");
out.println("    protected:");
out.println("");


            if( className.equals( "Message" ) ) {

out.println("        static const unsigned int DEFAULT_MESSAGE_SIZE = 1024;");
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 "+className+"* 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("");

        if( className.equals( "Message" ) ) {

out.println("        /**");
out.println("         * Returns the Size of this message in Bytes.");
out.println("         * @returns number of bytes this message equates to.");
out.println("         */");
out.println("        virtual unsigned int getSize() 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 void generateFile(PrintWriter out) throws Exception {

        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);
            }
        }

        String name = jclass.getSimpleName();
        String type = ("ow_" + name).toUpperCase() + "_TYPE";
        String baseName = "DataStructure";
        JClass superclass = jclass.getSuperclass();
        while (superclass.getSuperclass() != null) {
            if (sortedClasses.contains(superclass)) {
                baseName = superclass.getSimpleName();
                break;
            } else {
                superclass = superclass.getSuperclass();
            }
        }

        out.println("ow_boolean ow_is_a_" + name + "(ow_DataStructure *object) {");
        out.println("   if( object == 0 )");
        out.println("      return 0;");
        out.println("      ");
        out.println("   switch(object->structType) {");

        for (Iterator iterator = sortedClasses.iterator(); iterator.hasNext();) {
            JClass sub = (JClass)iterator.next();
            String subtype = "OW_" + sub.getSimpleName().toUpperCase() + "_TYPE";
            if (jclass.isAssignableFrom(sub) && !isAbstract(sub)) {
                out.println("");
                out.println("   case " + subtype + ":");
            }
        }
        out.println("");
        out.println("      return 1;");
        out.println("   }");
        out.println("   return 0;");
        out.println("}");

        if (!isAbstract(jclass)) {
            out.println("");
            out.println("");
            out.println("ow_" + name + " *ow_" + name + "_create(apr_pool_t *pool) ");
            out.println("{");
            out.println("   ow_" + name + " *value = apr_pcalloc(pool,sizeof(ow_" + name + "));");
            out.println("   if( value!=0 ) {");
            out.println("      ((ow_DataStructure*)value)->structType = " + type + ";");
            out.println("   }");
            out.println("   return value;");
            out.println("}");
        }

        out.println("");
        out.println("");
        out.println("apr_status_t ow_marshal1_" + name + "(ow_bit_buffer *buffer, ow_" + name + " *object)");
        out.println("{");
        out.println("   ow_marshal1_" + baseName + "(buffer, (ow_" + baseName + "*)object);");

        for (Iterator<JProperty> iter = properties.iterator(); iter.hasNext();) {
            JProperty property = iter.next();
            String propname = toPropertyCase(property.getSimpleName());
            boolean cached = isCachedProperty(property);
            JAnnotation annotation = property.getGetter().getAnnotation("openwire:property");
            JAnnotationValue size = annotation.getValue("size");

            type = property.getType().getQualifiedName();
            if (type.equals("boolean")) {
                out.println("   ow_bit_buffer_append(buffer, object->" + propname + ");");
            } else if (type.equals("byte")) {
            } else if (type.equals("char")) {
            } else if (type.equals("short")) {
            } else if (type.equals("int")) {
            } else if (type.equals("long")) {
                out.println("   ow_marshal1_long(buffer, object->" + propname + ");");
            } else if (type.equals("byte[]")) {
                if (size == null) {
                    out.println("   ow_bit_buffer_append(buffer,  object->" + propname + "!=0 );");
                }
            } else if (type.equals("org.apache.activeio.packet.ByteSequence")) {
                if (size == null) {
                    out.println("   ow_bit_buffer_append(buffer,  object->" + propname + "!=0 );");
                }
            } else if (type.equals("java.lang.String")) {
                out.println("   ow_marshal1_string(buffer, object->" + propname + ");");
            } else {
                if (property.getType().isArrayType()) {
                    if (size != null) {
                        out.println("   SUCCESS_CHECK(ow_marshal1_DataStructure_array_const_size(buffer, object->" + propname + ", " + size.asInt() + "));");
                    } else {
                        out.println("   SUCCESS_CHECK(ow_marshal1_DataStructure_array(buffer, object->" + propname + "));");
                    }
                } else if (isThrowable(property.getType())) {
                    out.println("   SUCCESS_CHECK(ow_marshal1_throwable(buffer, object->" + propname + "));");
                } else {
                    if (cached) {
                        out.println("   SUCCESS_CHECK(ow_marshal1_cached_object(buffer, (ow_DataStructure*)object->" + propname + "));");
                    } else {
                        out.println("   SUCCESS_CHECK(ow_marshal1_nested_object(buffer, (ow_DataStructure*)object->" + propname + "));");
                    }
                }
            }
            out.println("");
        }

        out.println("   ");
        out.println("   return APR_SUCCESS;");
        out.println("}");
        out.println("apr_status_t ow_marshal2_" + name + "(ow_byte_buffer *buffer, ow_bit_buffer *bitbuffer, ow_" + name + " *object)");
        out.println("{");
        out.println("   ow_marshal2_" + baseName + "(buffer, bitbuffer, (ow_" + baseName + "*)object);   ");

        for (Iterator<JProperty> iter = properties.iterator(); iter.hasNext();) {
            JProperty property = iter.next();
            JAnnotation annotation = property.getGetter().getAnnotation("openwire:property");
            JAnnotationValue size = annotation.getValue("size");
            Object propname = toPropertyCase(property.getSimpleName());
            boolean cached = isCachedProperty(property);

            type = property.getType().getQualifiedName();
            if (type.equals("boolean")) {
                out.println("   ow_bit_buffer_read(bitbuffer);");
            } else if (type.equals("byte")) {
                out.println("   SUCCESS_CHECK(ow_byte_buffer_append_" + type + "(buffer, object->" + propname + "));");
            } else if (type.equals("char")) {
                out.println("   SUCCESS_CHECK(ow_byte_buffer_append_" + type + "(buffer, object->" + propname + "));");
            } else if (type.equals("short")) {
                out.println("   SUCCESS_CHECK(ow_byte_buffer_append_" + type + "(buffer, object->" + propname + "));");
            } else if (type.equals("int")) {
                out.println("   SUCCESS_CHECK(ow_byte_buffer_append_" + type + "(buffer, object->" + propname + "));");
            } else if (type.equals("long")) {
                out.println("   SUCCESS_CHECK(ow_marshal2_long(buffer, bitbuffer, object->" + propname + "));");
            } else if (type.equals("byte[]")) {
                if (size != null) {
                    out.println("   SUCCESS_CHECK(ow_marshal2_byte_array_const_size(buffer, object->" + propname + ", " + size.asInt() + "));");
                } else {
                    out.println("   SUCCESS_CHECK(ow_marshal2_byte_array(buffer, bitbuffer, object->" + propname + "));");
                }
            } else if (type.equals("org.apache.activeio.packet.ByteSequence")) {
                if (size != null) {
                    out.println("   SUCCESS_CHECK(ow_marshal2_byte_array_const_size(buffer, object->" + propname + ", " + size.asInt() + "));");
                } else {
                    out.println("   SUCCESS_CHECK(ow_marshal2_byte_array(buffer, bitbuffer, object->" + propname + "));");
                }
            } else if (type.equals("java.lang.String")) {
                out.println("   SUCCESS_CHECK(ow_marshal2_string(buffer, bitbuffer, object->" + propname + "));");
            } else {
                if (property.getType().isArrayType()) {
                    if (size != null) {
                        out.println("   SUCCESS_CHECK(ow_marshal2_DataStructure_array_const_size(buffer, bitbuffer, object->" + propname + ", " + size.asInt() + "));");
                    } else {
                        out.println("   SUCCESS_CHECK(ow_marshal2_DataStructure_array(buffer, bitbuffer, object->" + propname + "));");
                    }
                } else if (isThrowable(property.getType())) {
                    out.println("   SUCCESS_CHECK(ow_marshal2_throwable(buffer, bitbuffer, object->" + propname + "));");
                } else {
                    if (cached) {
                        out.println("   SUCCESS_CHECK(ow_marshal2_cached_object(buffer, bitbuffer, (ow_DataStructure*)object->" + propname + "));");
                    } else {
                        out.println("   SUCCESS_CHECK(ow_marshal2_nested_object(buffer, bitbuffer, (ow_DataStructure*)object->" + propname + "));");
                    }
                }
            }
            out.println("");
        }

        out.println("   ");
        out.println("   return APR_SUCCESS;");
        out.println("}");
        out.println("");
        out.println("apr_status_t ow_unmarshal_" + name + "(ow_byte_array *buffer, ow_bit_buffer *bitbuffer, ow_" + name + " *object, apr_pool_t *pool)");
        out.println("{");
        out.println("   ow_unmarshal_" + baseName + "(buffer, bitbuffer, (ow_" + baseName + "*)object, pool);   ");

        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 propname = toPropertyCase(property.getSimpleName());
            boolean cached = isCachedProperty(property);

            type = property.getType().getQualifiedName();

            if (type.equals("boolean")) {
                out.println("   object->" + propname + " = ow_bit_buffer_read(bitbuffer);");
            } else if (type.equals("byte")) {
                out.println("   SUCCESS_CHECK(ow_byte_array_read_" + type + "(buffer, &object->" + propname + "));");
            } else if (type.equals("char")) {
                out.println("   SUCCESS_CHECK(ow_byte_array_read_" + type + "(buffer, &object->" + propname + "));");
            } else if (type.equals("short")) {
                out.println("   SUCCESS_CHECK(ow_byte_array_read_" + type + "(buffer, &object->" + propname + "));");
            } else if (type.equals("int")) {
                out.println("   SUCCESS_CHECK(ow_byte_array_read_" + type + "(buffer, &object->" + propname + "));");
            } else if (type.equals("long")) {
                out.println("   SUCCESS_CHECK(ow_unmarshal_long(buffer, bitbuffer, &object->" + propname + ", pool));");
            } else if (type.equals("byte[]")) {
                if (size != null) {
                    out.println("   SUCCESS_CHECK(ow_unmarshal_byte_array_const_size(buffer, &object->" + propname + ", " + size.asInt() + ", pool));");
                } else {
                    out.println("   SUCCESS_CHECK(ow_unmarshal_byte_array(buffer, bitbuffer, &object->" + propname + ", pool));");
                }
            } else if (type.equals("org.apache.activeio.packet.ByteSequence")) {
                if (size != null) {
                    out.println("   SUCCESS_CHECK(ow_unmarshal_byte_array_const_size(buffer, &object->" + propname + ", " + size.asInt() + ", pool));");
                } else {
                    out.println("   SUCCESS_CHECK(ow_unmarshal_byte_array(buffer, bitbuffer, &object->" + propname + ", pool));");
                }
            } else if (type.equals("java.lang.String")) {
                out.println("   SUCCESS_CHECK(ow_unmarshal_string(buffer, bitbuffer, &object->" + propname + ", pool));");
            } else {
                if (property.getType().isArrayType()) {
                    if (size != null) {
                        out.println("   SUCCESS_CHECK(ow_unmarshal_DataStructure_array_const_size(buffer, bitbuffer, &object->" + propname + ", " + size.asInt() + ", pool));");
                    } else {
                        out.println("   SUCCESS_CHECK(ow_unmarshal_DataStructure_array(buffer, bitbuffer, &object->" + propname + ", pool));");
                    }
                } else if (isThrowable(property.getType())) {
                    out.println("   SUCCESS_CHECK(ow_unmarshal_throwable(buffer, bitbuffer, &object->" + propname + ", pool));");
                } else {
                    if (cached) {
                        out.println("   SUCCESS_CHECK(ow_unmarshal_cached_object(buffer, bitbuffer, (ow_DataStructure**)&object->" + propname + ", pool));");
                    } else {
View Full Code Here

            if (service.getExcludeInfo() !=null) {
                beanExcludeInfo = service.getExcludeInfo().getBeanExcludeInfoForClass(
                        javaType.getQualifiedName());
            }
            for (int i = 0; i < tempProperties.length; i++) {
                JProperty tempProperty = tempProperties[i];
                String propertyName = getCorrectName(tempProperty.getSimpleName());
                if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)){
                    propertiesSet.add(tempProperty);
                }
            }

            JProperty[] properties = (JProperty[]) propertiesSet.toArray(new JProperty[0]);
            Arrays.sort(properties);
            for (int i = 0; i < properties.length; i++) {
                JProperty property = properties[i];
                boolean isArryType = property.getType().isArrayType();

                String propname = getCorrectName(property.getSimpleName());

                propertiesNames.add(propname);

                this.generateSchemaforFieldsandProperties(xmlSchema, sequence, property.getType(),
                        propname, isArryType);

            }

            JField[] tempFields = javaType.getDeclaredFields();
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

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.