Package com.thoughtworks.qdox.model

Examples of com.thoughtworks.qdox.model.JavaMethod


        StringBuilder sb = new StringBuilder();

        // special case for inherited method
        if ( isJavaMethod )
        {
            JavaMethod javaMethod = (JavaMethod) entity;

            if ( isInherited( javaMethod ) )
            {
                // QDOX-154 could be empty
                if ( StringUtils.isEmpty( javaMethod.getComment() ) )
                {
                    sb.append( indent ).append( INHERITED_JAVADOC );
                    sb.append( EOL );
                    stringWriter.write( sb.toString() );
                    return;
                }

                String javadoc = getJavadocComment( originalContent, javaMethod );

                // case: /** {@inheritDoc} */ or no tags
                if ( hasInheritedTag( javadoc ) && ( javaMethod.getTags() == null
                    || javaMethod.getTags().length == 0 ) )
                {
                    sb.append( indent ).append( INHERITED_JAVADOC );
                    sb.append( EOL );
                    stringWriter.write( sb.toString() );
                    return;
                }

                if ( javadoc.contains( START_JAVADOC ) )
                {
                    javadoc = javadoc.substring( javadoc.indexOf( START_JAVADOC ) + START_JAVADOC.length() );
                }
                if ( javadoc.contains( END_JAVADOC ) )
                {
                    javadoc = javadoc.substring( 0, javadoc.indexOf( END_JAVADOC ) );
                }

                sb.append( indent ).append( START_JAVADOC );
                sb.append( EOL );
                if ( !javadoc.contains( INHERITED_TAG ) )
                {
                    sb.append( indent ).append( SEPARATOR_JAVADOC ).append( INHERITED_TAG );
                    sb.append( EOL );
                    appendSeparator( sb, indent );
                }
                javadoc = removeLastEmptyJavadocLines( javadoc );
                javadoc = alignIndentationJavadocLines( javadoc, indent );
                sb.append( javadoc );
                sb.append( EOL );
                if ( javaMethod.getTags() != null )
                {
                    for ( int i = 0; i < javaMethod.getTags().length; i++ )
                    {
                        DocletTag docletTag = javaMethod.getTags()[i];

                        // Voluntary ignore these tags
                        if ( JavadocUtil.equals( docletTag.getName(), PARAM_TAG, RETURN_TAG, THROWS_TAG ) )
                        {
                            continue;
View Full Code Here


        {
            DocletTag docletTag = entity.getTags()[i];

            if ( isJavaMethod )
            {
                JavaMethod javaMethod = (JavaMethod) entity;

                String[] params = docletTag.getParameters();
                if ( params.length < 1 )
                {
                    continue;
View Full Code Here

                                        final JavaEntityTags javaEntityTags )
        throws MojoExecutionException
    {
        if ( isJavaMethod )
        {
            JavaMethod javaMethod = (JavaMethod) entity;

            if ( fixTag( PARAM_TAG ) )
            {
                if ( javaMethod.getParameters() != null )
                {
                    for ( int i = 0; i < javaMethod.getParameters().length; i++ )
                    {
                        JavaParameter javaParameter = javaMethod.getParameters()[i];

                        if ( javaEntityTags.getJavadocParamTag( javaParameter.getName(), true ) == null )
                        {
                            appendDefaultParamTag( sb, indent, javaParameter );
                        }
                    }
                }
                // is generic?
                if ( javaMethod.getTypeParameters() != null )
                {
                    for ( int i = 0; i < javaMethod.getTypeParameters().length; i++ )
                    {
                        TypeVariable typeParam = javaMethod.getTypeParameters()[i];

                        if ( javaEntityTags.getJavadocParamTag( "<" + typeParam.getName() + ">", true ) == null )
                        {
                            appendDefaultParamTag( sb, indent, typeParam );
                        }
                    }
                }
            }

            if ( fixTag( RETURN_TAG ) && StringUtils.isEmpty( javaEntityTags.getJavadocReturnTag() )
                && javaMethod.getReturns() != null && !javaMethod.getReturns().isVoid() )
            {
                appendDefaultReturnTag( sb, indent, javaMethod );
            }

            if ( fixTag( THROWS_TAG ) && javaMethod.getExceptions() != null )
            {
                for ( int i = 0; i < javaMethod.getExceptions().length; i++ )
                {
                    Type exception = javaMethod.getExceptions()[i];

                    if ( javaEntityTags.getJavadocThrowsTag( exception.getValue(), true ) == null )
                    {
                        appendDefaultThrowsTag( sb, indent, exception );
                    }
View Full Code Here

        throws MojoExecutionException
    {
        boolean separatorAdded = false;
        if ( isJavaMethod )
        {
            JavaMethod javaMethod = (JavaMethod) entity;

            if ( fixTag( PARAM_TAG ) && javaMethod.getParameters() != null )
            {
                for ( int i = 0; i < javaMethod.getParameters().length; i++ )
                {
                    JavaParameter javaParameter = javaMethod.getParameters()[i];

                    separatorAdded = appendDefaultParamTag( sb, indent, separatorAdded, javaParameter );
                }
            }

            if ( fixTag( RETURN_TAG ) )
            {
                if ( javaMethod.getReturns() != null && !javaMethod.getReturns().isVoid() )
                {
                    separatorAdded = appendDefaultReturnTag( sb, indent, separatorAdded, javaMethod );
                }
            }

            if ( fixTag( THROWS_TAG ) && javaMethod.getExceptions() != null )
            {
                for ( int i = 0; i < javaMethod.getExceptions().length; i++ )
                {
                    Type exception = javaMethod.getExceptions()[i];

                    separatorAdded = appendDefaultThrowsTag( sb, indent, separatorAdded, exception );
                }
            }
        }
        else
        {
            separatorAdded = appendDefaultAuthorTag( sb, indent, separatorAdded );

            separatorAdded = appendDefaultVersionTag( sb, indent, separatorAdded );
        }

        if ( fixTag( SINCE_TAG ) )
        {
            if ( !isJavaMethod )
            {
                JavaClass javaClass = (JavaClass) entity;

                if ( !ignoreClirr )
                {
                    if ( isNewClassFromLastVersion( javaClass ) )
                    {
                        separatorAdded = appendDefaultSinceTag( sb, indent, separatorAdded );
                    }
                }
                else
                {
                    separatorAdded = appendDefaultSinceTag( sb, indent, separatorAdded );

                    addSinceClasses( javaClass );
                }
            }
            else
            {
                JavaMethod javaMethod = (JavaMethod) entity;

                if ( !ignoreClirr )
                {
                    if ( isNewMethodFromLastRevision( javaMethod ) )
                    {
                        separatorAdded = appendDefaultSinceTag( sb, indent, separatorAdded );
                    }
                }
                else
                {
                    if ( sinceClasses != null && !sinceClassesContains( javaMethod.getParentClass() ) )
                    {
                        separatorAdded = appendDefaultSinceTag( sb, indent, separatorAdded );
                    }
                }
            }
View Full Code Here

            closedMockedClass = javaClass;
        }

        JavaMethod[] methods = javaClass.getMethods();
        for (int i = 0; i < methods.length; i++) {
            JavaMethod javaMethod = methods[i];

            String bindSignature =
                    GenerationHelper.getBindSignature(javaMethod);

            if (javaMethod.isConstructor() || javaMethod.isStatic()) {
                // Ignore constructors.
                continue;
            } else if (javaMethod.isFinal()) {
                // Ignore final methods and also exclude them from being picked
                // up on any other classes.
                excluded.add(bindSignature);
                continue;
            } else if (excluded.contains(bindSignature)) {
                // Ignore any previously excluded methods.
                continue;
            }

            JavaParameter[] parameters = javaMethod.getParameters();
            int parameterCount = (parameters == null ? 0 : parameters.length);
            String name = javaMethod.getName();
            String key = name + " " + parameterCount;

            MethodSet methodSet = (MethodSet) name2MethodSet.get(key);
            if (methodSet == null) {
                methodSet = new MethodSet(name, parameterCount, renamer, isInterface());
View Full Code Here

        JavaMethod[] methods = mockedClass.getMethods(false);
        Arrays.sort(methods, METHOD_COMPARATOR);

        List filteredMethods = new ArrayList();
        for (int i = 0; i < methods.length; i++) {
            JavaMethod method = methods[i];

            if (method.isConstructor() && !method.isPrivate()) {
                filteredMethods.add(method);
            }
        }

        Collection filteredConstructors = filteredMethods;
        if (filteredConstructors.isEmpty()) {
            filteredConstructors = new ArrayList();
            JavaMethod constructor = new JavaMethod();
            constructor.setConstructor(true);
            constructor.setParentClass(mockedClass);
            constructor.setParameters(new JavaParameter[0]);
            filteredConstructors.add(constructor);
        }

        List constructors = new ArrayList();
        for (Iterator i = filteredConstructors.iterator(); i.hasNext();) {
            JavaMethod javaMethod = (JavaMethod) i.next();
            Set throwables = GenerationHelper.getThrowables(javaMethod);
            constructors.add(new MockableConstructor(javaMethod, throwables));
        }

        return constructors;
View Full Code Here

             i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            String bindSignature = (String) entry.getKey();
            MergedMethod mergedMethod = (MergedMethod) entry.getValue();

            JavaMethod javaMethod = mergedMethod.javaMethod;
            String name = javaMethod.getName();
            List parameters = GenerationHelper.getParameters(javaMethod);

            SourceType mockedType = mergedMethod.mockedType;
            JavaClass mockedClass = mergedMethod.mockedClass;
            String uniqueIdentifier = GenerationHelper.uniqueMethodIdentifer(
                    name, parameters);
            String identifierReference;
            boolean declareIdentifier;
            if (mockedType == SourceType.BASE_INTERFACE && isInterface) {
                declareIdentifier = false;
                identifierReference = null;
            } else if (mockedType.isMockAvailable()) {
                declareIdentifier = true;
                identifierReference =
                        renamer.rename(mockedClass.getFullyQualifiedName()) +
                        "." + uniqueIdentifier;
            } else {
                declareIdentifier = true;
                identifierReference = null;
            }

            MockableMethod method =
                    new MockableMethod(name,
                            parameters,
                            bindSignature,
                            mergedMethod.throwables,
                            javaMethod.getReturns(),
                            getCallUpdaterInfo(javaMethod.getReturns()),
                            unique,
                            uniqueIdentifier, declareIdentifier,
                            identifierReference, true, null,
                            renamer.rename(mockedClass.getFullyQualifiedName()));
           
View Full Code Here

    JavaClass jc = getClassByName(methodClass);
    if (jc != null) {
      List<JavaMethod> methods = new ArrayList<JavaMethod>();
      JavaMethod[] allMethods = jc.getMethods();
      for (int i = 0; i < allMethods.length; i++) {
        JavaMethod jm = allMethods[i];
        if (methodsAreEqual(jm, methodName, parameterTypes)) {
          methods.add(jm);
        }
      }
     
      JavaMethod method = null;
//      if (methods.size() > 1) {
//        ppp("WARNING:  method " + methodName + " is overloaded, only considering the first one");
//      }
     
      if (methods.size() > 0) {
View Full Code Here

        throws Exception
    {
        final PhoenixAttributeInterceptor interceptor = new PhoenixAttributeInterceptor();
        final Attribute attribute = new Attribute( "ignore-me" );
        final Attribute result =
            interceptor.processMethodAttribute( new JavaMethod(), attribute );
        assertNotNull( "attribute", result );
        assertEquals( "attribute.name", "ignore-me", result.getName() );
        assertEquals( "attribute.value", null, result.getValue() );
        assertEquals( "attribute.parameterCount",
                      0,
View Full Code Here

        throws Exception
    {
        final PhoenixAttributeInterceptor interceptor = new PhoenixAttributeInterceptor();
        final Attribute attribute = new Attribute( "phoenix:mx-description" );
        final Attribute result =
            interceptor.processMethodAttribute( new JavaMethod(), attribute );
        assertNull( "attribute", result );
    }
View Full Code Here

TOP

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

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.