Examples of JavaMethod


Examples of com.thoughtworks.qdox.model.JavaMethod

    public JavaClass[] buildFor(JavaClass metadata) {
        if (!shouldGenerate(metadata)) {
            return null;
        }

        JavaMethod method;
        JavaClass retVal = createDynamicJavaClass(getDestinationClassname(metadata), getDestinationPackage(metadata), null, getMetadataProvider());
        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();) {
            method = new DuplicatedJavaMethod((JavaMethod)iter.next());
            method.setModifiers(new String[0]);
            retVal.addMethod(method);
        }

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

Examples of com.thoughtworks.qdox.model.JavaMethod

    public Collection getCreateMethods(final JavaClass javaClass, final int viewType, final Type newType) {
        Collection createMethods = CollectionUtils.select(Arrays.asList(javaClass.getMethods(true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method), EjbUtils.IFACE_METHOD_CREATE);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, javaClass), viewType);
                        return retVal;
                    }
                });

        // Let's remove the "ejb" from it's name
        createMethods = CollectionUtils.collect(createMethods,
                new Transformer() {
                    public Object transform(Object object) {
                        return ejbUtils.externalizeMethodName((JavaMethod) object);

                        // return ejbUtils.removeFromMethodName((JavaMethod) object, "ejb");
                    }
                });

        // xdoclet-1.2.3 comment: Add mandatory create() method for stateless beans if the bean is not abstract
        if ((createMethods.size() == 0) && ejbUtils.isStateLess(javaClass)) {
            // Let's generate it then
            JavaMethod createMethod = new JavaMethod();
            createMethod.setName("create");

            // Let's add it finally
            createMethods.add(createMethod);
        }
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

    public Collection getHomeMethods(final JavaClass clazz, final int viewType) {
        Collection homeMethods = CollectionUtils.select(Arrays.asList(clazz.getMethods(true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method), EjbUtils.IFACE_METHOD_HOME);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, clazz), viewType);
                        return retVal;
                    }
                });
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

        // NOTE: xdoclet-1.2.3 makes reference to method-level
        // ejb.finder (it's not supported, as it's inconsistent across code base)
        Collection finderMethods = CollectionUtils.select(Arrays.asList(javaClass.getMethods(true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method), EjbUtils.IFACE_METHOD_FINDER);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, javaClass), viewType);
                        return retVal;
                    }
                });

        // Let's remove the "ejb" from it's name
        finderMethods = CollectionUtils.collect(finderMethods,
                new Transformer() {
                    public Object transform(Object object) {
                        return ejbUtils.externalizeMethodName((JavaMethod) object);

                        // return ejbUtils.removeFromMethodName((JavaMethod) object, "ejb");
                    }
                });

        Collection finderMethodsBySignature = CollectionUtils.select(Arrays.asList(javaClass.getTagsByName(
                    TagLibrary.EJB_FINDER, true)),
                new Predicate() {
                    public boolean evaluate(Object object) {
                        EjbFinderTag finderTag = (EjbFinderTag) object;
                        boolean retVal = finderTag.getResultTypeMapping() == null ||
                            finderTag.getResultTypeMapping().equals(EjbUtils.REMOTE_INTERFACE);
                        retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(finderTag.getViewType()), viewType);
                        return retVal;
                    }
                });

        finderMethods.addAll(CollectionUtils.collect(finderMethodsBySignature,
                new Transformer() {
                public Object transform(Object object) {
                    EjbFinderTag finderTag = (EjbFinderTag) object;
                    return ejbUtils.getFinderMethodBySignature(finderTag.getSignature());
                }
            }));

        // Add mandatory findByPrimaryKey if not already there
        // Is this only for CMP ?? (xdoclet-1.2.3 says so, but i'll ignore
        // it for consistency, but it has a point anyway..
        // TODO: Centralize "findByPrimaryKey" /EjbPkTag somewhere..
        // if (ejbUtils.isCMP(javaClass)) {
        // Let's check if there is at least one "findByPrimaryKey"
        int count = CollectionUtils.countMatches(finderMethods,
                new Predicate() {
                    public boolean evaluate(Object object) {
                        JavaMethod method = (JavaMethod) object;
                        return "findByPrimaryKey".equals(method.getName());
                    }
                });

        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
            finderMethods.add(finderMethod);
        }
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

    public JavaClass[] buildFor(JavaClass metadata) {
        if (!shouldGenerate(metadata)) {
            return null;
        }

        JavaMethod method;
        JavaClass retVal = createDynamicJavaClass(getDestinationClassname(metadata), getDestinationPackage(metadata), null, getMetadataProvider());
        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();) {
            method = new DuplicatedJavaMethod((JavaMethod)iter.next());
            method.setModifiers(new String[0]);
            retVal.addMethod(method);
        }

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

Examples of com.thoughtworks.qdox.model.JavaMethod

    public JavaClass[] buildFor(JavaClass metadata) {
        if (!shouldGenerate(metadata)) {
            return null;
        }

        JavaMethod method;
        JavaClass retVal = createDynamicJavaClass(getDestinationClassname(metadata), getDestinationPackage(metadata), null, getMetadataProvider());
        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();) {
            method = new DuplicatedJavaMethod((JavaMethod)iter.next());
            method.setModifiers(new String[0]);
            retVal.addMethod(method);
        }

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

Examples of com.thoughtworks.qdox.model.JavaMethod

            BeanProperty prop = null;

            if (pkType != null && propName != null) {
                prop = new BeanProperty(propName);
                prop.setType(pkType);
                JavaMethod getter = new JavaMethod(pkType, getGetterName(prop));
                JavaMethod setter = new JavaMethod(pkType, getSetterName(prop));
                setter.setParameters(new JavaParameter[] {new JavaParameter(pkType, prop.getName())});
                prop.setAccessor(getter);
                prop.setMutator(setter);
            }

            return prop;
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

        if (!shouldGenerate(metadata)) {
            return null;
        }

        JavaField field;
        JavaMethod method;
        JavaClass retVal = createDynamicJavaClass(getDestinationClassname(metadata), getDestinationPackage(metadata), null, getMetadataProvider());
        retVal.setModifiers(new String[] { "public" });

        PkMetadata metaPk = getMetaPk(metadata);
        String extendz = getExtends(metadata);

        JavaClass parentBuilded[];
        JavaClass parent = metadata.getSuperJavaClass();
        while (parent != null) {
            parentBuilded = buildFor(parent);
            if ((parentBuilded != null) && (parentBuilded[0].getFullyQualifiedName().equals(extendz))) {
                retVal.setSuperClass(parentBuilded[0].asType());
                break;
            }
            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

Examples of com.thoughtworks.qdox.model.JavaMethod

        return hierarchyLst;
    }

    private BeanProperty[] getPkProperties(JavaClass javaClass) {
        JavaMethod[] methods = javaClass.getMethods();
        JavaMethod method;
        SortedSet propSet = new TreeSet(new Comparator() {
                    public int compare(Object o1, Object o2) {
                        BeanProperty p1 = (BeanProperty) o1;
                        BeanProperty p2 = (BeanProperty) o2;
                        return p1.getName().compareTo(p2.getName());
                    }
                });

        for (int i = 0; i < methods.length; i++) {
            method = methods[i];
            int metaFlags = ejbUtils.getMethodMetadata(javaClass, method);

            if (EjbUtils.hasFlag(metaFlags, EjbUtils.METADATA_METHOD_PRIMARY_KEY_FIELD)) {
                BeanProperty beanProperty = javaClass.getBeanProperty(method.getPropertyName());

                if (beanProperty != null) {
                    if (propSet.add(beanProperty)) {
                        if (log.isDebugEnabled()) {
                            log.debug(beanProperty.getName() + " was added to the Set");
                        }
                    } else {
                        if (log.isDebugEnabled()) {
                            log.debug(beanProperty.getName() +
                                " wasn't added to the Set. There must be already a property with the same name");
                        }
                    }
                } else {
                    String errorMessage = "Unexpected null property for " + method.getPropertyName() + " in " +
                        javaClass.getFullyQualifiedName();
                    log.error(errorMessage);
                    throw new Error(errorMessage);
                }
            }
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

                if (jc != null) {
                    if (isMethod()) {
                        String mname = getName();
                        JavaMethod[] methods = jc.getMethods();
                        for (int i = 0; i < methods.length; i++) {
                            JavaMethod method = methods[i];
                            if (mname.equals(method.getName())) {
                                if (matchSignature(method)) {
                                    m_itemSource = method;
                                    break;
                                }
                            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.