Package com.thoughtworks.qdox.model

Examples of com.thoughtworks.qdox.model.Type


        retVal.setInterface(true);
        retVal.setModifiers(new String[]{"public"});
        String[] extendz = getExtends(metadata);
        Type[] extendzTypes = new Type[extendz.length];
        for (int j = 0; j < extendz.length; j++) {
            extendzTypes[j] = new Type(extendz[j]);
        }
        retVal.setImplementz(extendzTypes);

        Collection methods = getInterfaceMethods(metadata);
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
View Full Code Here


        retVal.setInterface(true);
        retVal.setModifiers(new String[]{"public"});
        String[] extendz = getExtends(metadata);
        Type[] extendzTypes = new Type[extendz.length];
        for (int j = 0; j < extendz.length; j++) {
            extendzTypes[j] = new Type(extendz[j]);
        }
        retVal.setImplementz(extendzTypes);

        field = new JavaField(new Type("java.lang.String"), ejbHomeUtils.getCompleteNameConst());
        field.setModifiers(new String[]{"public","static","final"});
        retVal.addField(field);

        field = new JavaField(new Type("java.lang.String"), ejbHomeUtils.getJndiNameConst());
        field.setModifiers(new String[]{"public","static","final"});
        retVal.addField(field);

        Collection methods = getCreateMethods(metadata);
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
View Full Code Here

        retVal.setInterface(true);
        retVal.setModifiers(new String[]{"public"});
        String[] extendz = getExtends(metadata);
        Type[] extendzTypes = new Type[extendz.length];
        for (int j = 0; j < extendz.length; j++) {
            extendzTypes[j] = new Type(extendz[j]);
        }
        retVal.setImplementz(extendzTypes);

        Collection methods = getInterfaceMethods(metadata);
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
View Full Code Here

                });

        if (count == 0) {
            // Let's generate it then
            PrimaryKeyClassPlugin pkPlugin = EjbRuntime.getPrimaryKeyClassPlugin();
            JavaParameter javaParameter = new JavaParameter(new Type(pkPlugin.pkClass(javaClass)), "pk");
            JavaMethod finderMethod = new JavaMethod();
            finderMethod.setName("findByPrimaryKey");
            finderMethod.setParameters(new JavaParameter[] {javaParameter});

            // Let's add it finally
View Full Code Here

        retVal.setInterface(true);
        retVal.setModifiers(new String[]{"public"});
        String[] extendz = getExtends(metadata);
        Type[] extendzTypes = new Type[extendz.length];
        for (int j = 0; j < extendz.length; j++) {
            extendzTypes[j] = new Type(extendz[j]);
        }
        retVal.setImplementz(extendzTypes);

        Collection methods = getInterfaceMethods(metadata);
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
View Full Code Here

        public boolean hasPk() {
            return (getPkProperty() != null);
        }

        public BeanProperty getPkProperty() {
            Type pkType = null;
            String propName = null;

            if (!pkMetadata.isSimpleProperty()) {
                if (pkMetadata.isEmptyWithParent()) {
                    PkMetadata pkMeta = pkMetadata.getParent();
View Full Code Here

            parent = parent.getSuperJavaClass();
        }
        String[] implementz = getImplements(metadata);
        Type[] implementzTypes = new Type[implementz.length];
        for (int i = 0; i < implementz.length; i++) {
            implementzTypes[i] = new Type(implementz[i]);
        }
        retVal.setImplementz(implementzTypes);

        BeanProperty[] properties = metaPk.getProperties();
        for (int i = 0; (properties != null) && (i < properties.length); i++) {
            field = new JavaField(properties[i].getType(), properties[i].getName());
            field.setModifiers(new String[] { "public" });
            retVal.addField(field);
        }

        method = new JavaMethod(getDestinationClassname(metadata));
        method.setConstructor(true);
        method.setModifiers(new String[] { "public" });
        retVal.addMethod(method);

        BeanProperty[] parentProperties = metaPk.getParentProperties();
        if ((properties != null && properties.length > 0)
         || (parentProperties != null && parentProperties.length > 0)) {
            method = new JavaMethod(getDestinationClassname(metadata));
            method.setConstructor(true);
            method.setModifiers(new String[] { "public" });

            JavaParameter[] params = new JavaParameter[((properties != null) ? properties.length : 0) ((parentProperties != null) ? parentProperties.length : 0)];
            int idx = 0;
            for (int i = 0; (properties != null) && (i < properties.length); i++) {
                params[idx++] = new JavaParameter(properties[i].getType(), properties[i].getName());
            }
            for (int i = 0; (parentProperties != null) && (i < parentProperties.length); i++) {
                params[idx++] = new JavaParameter(parentProperties[i].getType(), parentProperties[i].getName());
            }
            method.setParameters(params);
            retVal.addMethod(method);
        }

        for (int i = 0; (properties != null) && (i < properties.length); i++) {
            method = new JavaMethod(getSetterName(properties[i]));
            method.setModifiers(new String[] { "public" });
            method.setParameters(new JavaParameter[]{new JavaParameter(properties[i].getType(), properties[i].getName())});
            retVal.addMethod(method);
            method = new JavaMethod(properties[i].getType(), getGetterName(properties[i]));
            method.setModifiers(new String[] { "public" });
            retVal.addMethod(method);
        }

        method = new JavaMethod(new Type("int"), "hashCode");
        method.setModifiers(new String[] { "public" });
        retVal.addMethod(method);

        method = new JavaMethod(new Type("boolean"), "equals");
        method.setModifiers(new String[] { "public" });
        method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.lang.Object"), "other")});
        retVal.addMethod(method);

        method = new JavaMethod(new Type("java.lang.String"), "toString");
        method.setModifiers(new String[] { "public" });
        retVal.addMethod(method);

        return new JavaClass[]{retVal};
    }
View Full Code Here

        if (pkClassHierarchy.isSimpleProperty()) {
            return pkClassHierarchy.getProperties()[0].getType();
        } else {
            if (pkClassHierarchy.isEmptyWithParent()) {
                pkClassHierarchy = pkClassHierarchy.getParent();
                return new Type(pkClassHierarchy.getType().toString());
            } else {
                throw new Error("Cannot resolve primary key class name (" + javaClass.getFullyQualifiedName() +
                    "). Have you forgot to set @ejb.bean \"primkey-field\" or @ejb.pk-field ? (" + pkClassHierarchy +
                    ")");
            }
View Full Code Here

    private boolean matchSignature(JavaMethod method) {
        boolean match = true;
        JavaParameter[] parms = method.getParameters();
        if (parms.length == getArgumentCount()) {
            for (int j = 0; j < parms.length; j++) {
                Type ptype = parms[j].getType();
                String type = ptype.getValue();
                int ndim = ptype.getDimensions();
                while (ndim-- > 0) {
                    type += "[]";
                }
                String comp = getArgumentType(j);
                if (!comp.equals(type)) {
View Full Code Here

    public JavaMethod getMethodBySignature(String signature) {
        Matcher matcher = methodPattern.matcher(signature);

        if (matcher.matches()) {
            JavaMethod method = new JavaMethod(new Type(matcher.group(1)), matcher.group(2));

            // Now let's find out the arguments
            matcher = paramPattern.matcher(matcher.group(3));
            int beginIdx = 0;
            int count = 0;
            String paramType = null;
            String paramName = null;
            List paramLst = new ArrayList();

            while (matcher.find(beginIdx)) {
                int paramDim = 0;

                if (matcher.group(1) != null) {
                    paramType = matcher.group(2) + (matcher.group(4) != null ? matcher.group(4) : "");
                    paramName = matcher.group(3);
                } else {
                    paramType = matcher.group(6);
                    paramName = "_arg" + (count++);
                }

                // Now we need to parse paramType for it's dimensions
                Matcher dMatcher = dimensionPattern.matcher(paramType);

                if (dMatcher.find()) {
                    paramType = paramType.substring(0, dMatcher.start());
                    paramDim = 1;

                    while (dMatcher.find(dMatcher.end())) {
                        paramDim++;
                    }
                }

                paramLst.add(new JavaParameter(new Type(paramType, paramDim), paramName));
                beginIdx = matcher.end();
            }

            method.setParameters((JavaParameter[]) paramLst.toArray(new JavaParameter[0]));
            return method;
View Full Code Here

TOP

Related Classes of com.thoughtworks.qdox.model.Type

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.