private static void getClassMethods()

in ti/phase2/jars/core/src/java/org/apache/ti/compiler/internal/CompilerUtils.java [383:437]


    private static void getClassMethods(TypeDeclaration type, String desiredAnnotation, boolean onlyPublicOrPrivate,
                                        Collection results) {
        if (! (type instanceof ClassDeclaration)) return;

        ClassDeclaration jclass = (ClassDeclaration) type;
        MethodDeclaration[] methods = jclass.getMethods();

        for (int i = 0; i < methods.length; i++) {
            MethodDeclaration method = methods[i];

            if (! onlyPublicOrPrivate || method.hasModifier(Modifier.PROTECTED)
                    || method.hasModifier(Modifier.PUBLIC)) {
                if (desiredAnnotation == null || getAnnotation(method, desiredAnnotation) != null) {
                    boolean isDuplicate = false;

                    //
                    // Make sure we're not adding a duplicate method -- one that was already overridden.
                    //
                    if (onlyPublicOrPrivate) {
                        ParameterDeclaration[] methodParams = method.getParameters();

                        for (Iterator j = results.iterator(); j.hasNext();) {
                            MethodDeclaration existingMethod = (MethodDeclaration) j.next();

                            if (existingMethod.getSimpleName().equals(method.getSimpleName())) {
                                ParameterDeclaration[] existingMethodParams = existingMethod.getParameters();

                                if (existingMethodParams.length == methodParams.length) {
                                    isDuplicate = true;

                                    for (int k = 0; k < existingMethodParams.length; ++k) {
                                        ParameterDeclaration existingMethodParam = existingMethodParams[k];
                                        ParameterDeclaration methodParam = methodParams[k];

                                        if (! existingMethodParam.getType().equals(methodParam.getType())) {
                                            isDuplicate = false;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (! isDuplicate) results.add(method);
                }
            }
        }

        ClassType superclass = jclass.getSuperclass();

        if (superclass != null && ! getDeclaration(superclass).getQualifiedName().startsWith("java.lang.")) {
            getClassMethods(getDeclaration(superclass), desiredAnnotation, true, results);
        }
    }