Package com.thoughtworks.qdox.model

Examples of com.thoughtworks.qdox.model.JavaField


    }

    @Test
    public void requiredAppearsInFieldJavadoc() throws IOException {

        JavaField javaField = classWithRequired.getFieldByName("requiredProperty");
        String javaDocComment = javaField.getComment();

        assertThat(javaDocComment, containsString("(Required)"));

    }
View Full Code Here


    }

    @Test
    public void nonRequiredFiedHasNoRequiredText() throws IOException {

        JavaField javaField = classWithRequired.getFieldByName("nonRequiredProperty");
        String javaDocComment = javaField.getComment();

        assertThat(javaDocComment, not(containsString("(Required)")));

    }
View Full Code Here

    }

    @Test
    public void notRequiredIsTheDefault() throws IOException {

        JavaField javaField = classWithRequired.getFieldByName("defaultNotRequiredProperty");
        String javaDocComment = javaField.getComment();

        assertThat(javaDocComment, not(containsString("(Required)")));

    }
View Full Code Here

    }

    @Test
    public void descriptionAppearsInFieldJavadoc() throws IOException {

        JavaField javaField = classWithDescription.getFieldByName("description");
        String javaDocComment = javaField.getComment();

        assertThat(javaDocComment, containsString("A description for this property"));

    }
View Full Code Here

    }

    @Test
    public void descriptionAppearsAfterTitleInJavadoc() throws IOException {

        JavaField javaField = classWithDescription.getFieldByName("descriptionAndTitle");
        String javaDocComment = javaField.getComment();

        assertThat(javaDocComment, containsString("A title for this property"));
        assertThat(javaDocComment.indexOf("A description for this property"), is(greaterThan(javaDocComment.indexOf("A title for this property"))));

    }
View Full Code Here

            }
         }
      }
      for (int i = 0; i < clazz.getFields().length; i++)
      {
         JavaField field = clazz.getFields()[i];
         for (int j = 0; j < field.getTags().length; j++)
         {
            AnnotationDocletTag tag = (AnnotationDocletTag) field.getTags()[j];
            if (tag.getAnnotation() == null) continue;
            modified = true;
            compileField(field, tag, ctClass);
         }
      }
View Full Code Here

            pw.println("</metadata>");
         }
      }
      for (int i = 0; i < clazz.getFields().length; i++)
      {
         JavaField field = clazz.getFields()[i];
         for (int j = 0; j < field.getTags().length; j++)
         {
            AnnotationDocletTag tag = (AnnotationDocletTag) field.getTags()[j];
            if (tag.getAnnotation() == null) continue;
            indenter(pw, indent);
            pw.println("<metadata tag=\"" + tag.getName() + "\" class=\"" + clazz.getFullyQualifiedName() + "\">");
            indent++;
            printField(pw, field, indent, tag);
View Full Code Here

        // Search the current class for requirements
        // ----------------------------------------------------------------------

        for ( int i = 0; i < fields.length; i++ )
        {
            JavaField field = fields[i];

            DocletTag tag = field.getTagByName( PLEXUS_REQUIREMENT_TAG );

            if ( tag == null )
            {
                continue;
            }

            Map<String, String> parameters = new HashMap<String, String>( tag.getNamedParameterMap() );

            // ----------------------------------------------------------------------
            // Role
            // ----------------------------------------------------------------------

            String requirementClass = field.getType().getJavaClass().getFullyQualifiedName();

            boolean isMap = requirementClass.equals( Map.class.getName() ) ||
                    requirementClass.equals( Collection.class.getName() );

            try
            {
                isMap = isMap || Collection.class.isAssignableFrom( Class.forName( requirementClass ) );
            }
            catch ( ClassNotFoundException e )
            {
                // ignore the assignable Collection test, though this should never happen
            }

            boolean isList = requirementClass.equals( List.class.getName() );

            ComponentRequirement cr;

            String hint = getParameter( parameters, PLEXUS_ROLE_HINT_PARAMETER );

            if ( isMap || isList )
            {
                cr = new ComponentRequirementList();

                String hintList = getParameter( parameters, PLEXUS_ROLE_HINT_LIST_PARAMETER );

                if ( hintList != null )
                {
                    String[] hintArr = hintList.split( "," );

                    ( (ComponentRequirementList) cr).setRoleHints( Arrays.asList( hintArr ) );
                }
            }
            else
            {
                cr = new ComponentRequirement();

                cr.setRoleHint( hint );
            }

            String role = getParameter( parameters, PLEXUS_ROLE_PARAMETER );

            if ( role == null )
            {
                cr.setRole( requirementClass );
            }
            else
            {
                cr.setRole( role );
            }

            String optional = getParameter( parameters, PLEXUS_OPTIONAL_PARAMETER );

            cr.setOptional( Boolean.parseBoolean( optional ) );

            cr.setFieldName( field.getName() );

            if ( isMap || isList )
            {
                if ( hint != null )
                {
View Full Code Here

        // Search the current class for configurable fields.
        // ----------------------------------------------------------------------

        for ( int i = 0; i < fields.length; i++ )
        {
            JavaField field = fields[i];

            DocletTag tag = field.getTagByName( PLEXUS_CONFIGURATION_TAG );

            if ( tag == null )
            {
                continue;
            }

            Map<String, String> parameters = new HashMap<String, String>( tag.getNamedParameterMap() );

            /* don't use the getParameter helper as we like empty strings */
            String defaultValue = parameters.remove( PLEXUS_DEFAULT_VALUE_PARAMETER );

            if ( defaultValue == null )
            {
                /*
                log.warn( "Component: " + javaClass.getName() + ", field name: '" + field.getName() + "': " +
                    "Currently configurable fields will not be written to the descriptor " +
                    "without a default value." );*/

                continue;
            }

            String name = deHump( field.getName() );

            XmlPlexusConfiguration c;

            c = new XmlPlexusConfiguration( name );

View Full Code Here

        return result;
    }

    protected JavaField resolveField( JavaClass javaClass, int start, int end ) {
        JavaField field = null;

        for( int i = start; i < end; ++i ) {
            field = javaClass.getFieldByName( getNamePart( i ) );

            if( field == null ) {
                break;
            }

            javaClass = field.getType().getJavaClass();
        }

        return field;
    }
View Full Code Here

TOP

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

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.