Package com.thoughtworks.qdox.model

Examples of com.thoughtworks.qdox.model.Type


        for ( Map.Entry<String, JavaField> entry : rawParams.entrySet() )
        {
            JavaField field = entry.getValue();

            Type type = field.getType();

            Parameter pd = new Parameter();

            pd.setName( entry.getKey() );

            if ( !type.isArray() )
            {
                pd.setType( type.getValue() );
            }
            else
            {
                StringBuilder value = new StringBuilder( type.getValue() );

                int remaining = type.getDimensions();

                while ( remaining-- > 0 )
                {
                    value.append( "[]" );
                }
View Full Code Here


     *
     * @param method The parsed method.
     * @return <code>true</code> if it is an execute method.
     */
    private boolean isFeasible(JavaMethod method) {
        Type returns = method.getReturns();
        if ("execute".equals(method.getName()) && returns != null
                && "void".equals(returns.getFullyQualifiedName())
                && method.isPublic() && !method.isStatic()
                && !method.isAbstract() && !method.isConstructor()) {
            JavaParameter[] params = method.getParameters();
            if (params.length > 0) {
                JavaParameter param = params[params.length - 1];
View Full Code Here

        for (Iterator i = mockableClass.getNormalMethods().iterator(); i.hasNext();) {
            MockableMethod method = (MockableMethod) i.next();

            out("\n");
            Type returnType = method.getReturnType();
            final String returnTypeStr =
                CodeUtils.fixInnerClassName(returnType.toString());
            out("    public ").out(returnTypeStr).out(" ").out(method.getName()).out("(").out(declareParameters(method, "")).out(") ").out(throwsClause(method)).out("{\n");
            String bindSignature = method.getBindSignature();
            List parameters = method.getParameters();
            if (bindSignature.equals("equals(java.lang.Object)")) {
                out("        return com.volantis.testtools.mock.generated.GeneratedHelper.equalsMock(this, configuration, ").out(((MockableParameter) parameters.get(0)).getName()).out(");\n");
            } else if (bindSignature.equals("hashCode()")) {
                out("        return com.volantis.testtools.mock.generated.GeneratedHelper.hashCodeMock(this, configuration);\n");
            } else if (bindSignature.equals("toString()")) {
                out("        return com.volantis.testtools.mock.generated.GeneratedHelper.toStringMock(this, configuration);\n");
            } else {
                out("        com.volantis.testtools.mock.method.MethodCall _call = _mockFactory.createMethodCall(\n");
                out("                this, ").out(method.getUniqueIdentifier()).out(",\n");
                if (parameters != null) {
                    out("                new java.lang.Object[]{\n");
                    for (Iterator j = parameters.iterator(); j.hasNext();) {
                        MockableParameter parameter = (MockableParameter) j.next();
                        out("                    ").out(parameter.box()).out(",\n");
                    }
                    out("                });\n");
                } else {
                    out("                null);\n");
                }
                out("\n");
                out("        try {\n");
                if (returnType.toString().equals("void")) {
                    out("            _doMethodCall(_call);\n");
                } else {
                    out("            java.lang.Object _result = _doMethodCall(_call);\n");
                    out("            return ").out(method.unbox(returnType, "_result")).out(";\n");
                }
View Full Code Here

                    closestMockedType, closedMockedClass);
        }

        Type[] interfaces = javaClass.getImplements();
        for (int i = 0; i < interfaces.length; i++) {
            final Type interfaceType = interfaces[i];
            // if the interface is in the same package then interfaceType won't
            // have package information
            JavaClass ifc = resolveClass(interfaceType, javaClass.getPackage());

            findMockableMethods(ifc, name2MethodSet, excluded,
View Full Code Here

        for ( Map.Entry<String, JavaField> entry : rawParams.entrySet() )
        {
            JavaField field = entry.getValue();

            Type type = field.getType();

            Parameter pd = new Parameter();

            pd.setName( entry.getKey() );

            if ( !type.isArray() )
            {
                pd.setType( type.getValue() );
            }
            else
            {
                StringBuilder value = new StringBuilder( type.getValue() );

                int remaining = type.getDimensions();

                while ( remaining-- > 0 )
                {
                    value.append( "[]" );
                }
View Full Code Here

        for (int i = 0; i < types.length; i++) {
            // QDox ignores varargs and generics, so we strip them out to help QDox.
            String type = params.get(i).getType();
            type = GENERIC_REGEX.matcher(type).replaceAll("");
            type = VARARGS_REGEX.matcher(type).replaceAll("");
            types[i] = new Type(type);
        }
        JavaMethod[] methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false);
        return methods.length == 1 ?  methods[0] : null;
    }
View Full Code Here

        for ( Map.Entry<String, JavaField> entry : rawParams.entrySet() )
        {
            JavaField field = entry.getValue();

            Type type = field.getType();

            Parameter pd = new Parameter();

            pd.setName( entry.getKey() );

            if ( !type.isArray() )
            {
                pd.setType( type.getValue() );
            }
            else
            {
                StringBuilder value = new StringBuilder( type.getValue() );

                int remaining = type.getDimensions();

                while ( remaining-- > 0 )
                {
                    value.append( "[]" );
                }
View Full Code Here

        for (int i = 0; i < types.length; i++) {
            // QDox ignores varargs and generics, so we strip them out to help QDox.
            String type = params.get(i).getType();
            type = GENERIC_REGEX.matcher(type).replaceAll("");
            type = VARARGS_REGEX.matcher(type).replaceAll("");
            types[i] = new Type(type);
        }
        JavaMethod[] methods = classSource.getMethodsBySignature(
                factoryMethod.getName(), types, false);
        if (methods.length == 1) {
            return methods[0];
View Full Code Here

        JavaParameter[] params = method.getParameters();
        if (params.length < 1) {
            throw new EventConventionException("The method " + methodSig
                    + " must have at least one parameter: 'Object source'!");
        }
        Type firstType = params[0].getType();
        if (firstType.isPrimitive() || !"source".equals(params[0].getName())) {
            throw new EventConventionException("The first parameter of the method " + methodSig
                    + " must be: 'Object source'!");
        }

        //build method model
View Full Code Here

    }

    public void testVarArgsParametersAreAlsoArrays() {
        JavaMethod javaMethod = buildMethod("void doStuff(AThing param1, BThing[] param2, CThing... param3);");

        Type standardType = javaMethod.getParameterByName("param1").getType();
        Type arrayType = javaMethod.getParameterByName("param2").getType();
        Type varArgsType = javaMethod.getParameterByName("param3").getType();

        assertFalse("param1 should NOT be array", standardType.isArray());
        assertTrue("param2 should be array", arrayType.isArray());
        assertFalse("param3 should NOT be array", varArgsType.isArray());
    }
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.