Package com.sun.mirror.type

Examples of com.sun.mirror.type.TypeMirror


    /**
     * Initializes the ControlInterface associated with this ControlField
     */
    protected AptControlInterface initControlInterface()
    {
        TypeMirror controlType = _fieldDecl.getType();
        if (! (controlType instanceof DeclaredType))
        {
            _ap.printError( _fieldDecl, "control.field.bad.type" );
            return null;
        }

        //
        // The field can either be declared as the bean type or the public interface type.
        // If it is the bean type, then we need to reflect to find the public interface
        // type it implements.
        //
        TypeDeclaration typeDecl = ((DeclaredType)controlType).getDeclaration();
        InterfaceDeclaration controlIntf = null;

        //
        // It is possible that the declared type is associated with a to-be-generated
        // bean type.  In this case, look for the associated control interface on the
        // processor input list.
        //
        if ( typeDecl == null )
        {
            String className = controlType.toString();
            String intfName = className.substring(0, className.length() - 4);
            controlIntf = (InterfaceDeclaration)_ap.getAnnotationProcessorEnvironment().getTypeDeclaration(intfName);
            if (controlIntf == null)
            {
                // The specified class name may not be fully qualified.  In this case, the
View Full Code Here


            }

            //
            // Locate the EventSet based upon the eventSet element value
            //
            TypeMirror tm = (TypeMirror)( handlerAnnot.getObjectValue("eventSet") );
            if ( tm == null )
                continue;
            String setName = tm.toString();

            AptControlInterface controlIntf = eventField.getControlInterface();
            AptEventSet eventSet = controlIntf.getEventSet(setName);
            if (eventSet == null)
            {
View Full Code Here

        //
        StringBuffer sb = new StringBuffer();
        boolean isFirst = true;
        while (paramBoundIter.hasNext())
        {
            TypeMirror paramBound = paramBoundIter.next();
            TypeParameterDeclaration paramDecl = paramDeclIter.next();

            //
            // Save a mapping from the formal type name to the bound mirror type
            //
View Full Code Here

            return "";
       
        int i = 0;
        for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
        {
            TypeMirror paramType = paramDecl.getType();
            if ( paramType == null )
                return "";
               
            if (bindingMap != null && bindingMap.containsKey(paramType.toString()))
                paramType = bindingMap.get(paramType.toString());

            if (i != 0)
                sb.append(", ");
           
            sb.append(paramType.toString());

            sb.append(' ');

            // BUGBUG: when the MethodDeclaration is derived from Reflection, this seems
            // to return 'arg0' for all arguments!
View Full Code Here

        for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
        {
            if (i++ != 0)
                sb.append(", ");

            TypeMirror paramType = paramDecl.getType();
            if (paramType == null)
                return "";

            //
            // Use the erasure here, because we only want the raw type, not the reference
View Full Code Here

     */
    public boolean hasParameterizedArguments()
    {
        for (ParameterDeclaration paramDecl : _methodDecl.getParameters())
        {
            TypeMirror paramType = paramDecl.getType();
            if (paramType instanceof ReferenceType || paramType instanceof WildcardType)
                return true;
        }
        return false;
    }
View Full Code Here

    if ( !isProbablyOwnType( type ) ) {
      return codeGenerator.ref( type );
    }

    if ( TypeUtils.isCollectionType( type ) ) {
      TypeMirror collectionParam = TypeUtils.getCollectionParam( type );
      JClass collection = codeGenerator.ref( TypeUtils.getErasure( type ) );

      if ( collectionParam instanceof WildcardType ) {
        return collection.narrow( codeGenerator.ref( getJaxbTypeName( TypeUtils.getErasure( collectionParam ), stub ) ).wildcard() );
      } else {
View Full Code Here

        if (paramMap.containsKey(paramNameQualifiers[0]) == false) {
            throw new ControlException(buildMessage(parameterName, method.getSimpleName()));
        }

        ParameterDeclaration tpd = paramMap.get(paramNameQualifiers[0]);
        TypeMirror type = tpd.getType();

        MethodDeclaration getterMethod = null;
        FieldDeclaration field = null;

        for (int i = 1; i < paramNameQualifiers.length; i++) {
View Full Code Here

        //
        // batch update methods must return int[]
        //
        final boolean batchUpdate = methodSQL.batchUpdate();
        final TypeMirror returnType = method.getReturnType();
        if (batchUpdate) {
            if (returnType instanceof ArrayType == true) {
                final TypeMirror aType = ((ArrayType) returnType).getComponentType();
                if (aType instanceof PrimitiveType == false || ((PrimitiveType) aType).getKind() != PrimitiveType.Kind.INT) {
                    env.getMessager().printError(method.getPosition(), "@SQL annotation on method: " + method.getSimpleName()
                                                                       + " if batchUpdate is set to true, method must return void or an array of integers.");
                    return;
                }
View Full Code Here

                {
                    if ( decl instanceof FieldDeclaration )
                    {
                        FieldDeclaration fd = (FieldDeclaration)decl;
                        TypeDeclaration clientType = fd.getDeclaringType();
                        TypeMirror controlFieldType = fd.getType();
                        addControlType( clientsMap, clientType, controlFieldType );

                        /*
                        If this field is public or protected, add the control type to any derived class.  Private
                        fields are also included here as private controls in superclasses may be exposed through public
                        or protected methods to subclasses
                        */
                        Collection<Modifier> modifiers = fd.getModifiers();
                        if (modifiers.contains( Modifier.PUBLIC ) ||
                            modifiers.contains( Modifier.PROTECTED ) ||
                            modifiers.contains( Modifier.PRIVATE) )
                        {
                            Collection<TypeDeclaration> specifiedTypeDeclartions = env.getSpecifiedTypeDeclarations();
                            for (TypeDeclaration td : specifiedTypeDeclartions)
                            {
                                if ( td instanceof ClassDeclaration )
                                {
                                    ClassType superclass = ( ( ClassDeclaration ) td ).getSuperclass();

                                    while ( superclass != null )
                                    {
                                        if ( superclass.getDeclaration().equals( clientType ) )
                                        {
                                            addControlType( clientsMap, td, controlFieldType );
                                            break;
                                        }

                                        superclass = superclass.getSuperclass();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (atd.getSimpleName().equals("ControlReferences"))
            {
                Collection<Declaration> decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
                for (Declaration decl : decls)
                {
                    if ( decl instanceof TypeDeclaration )
                    {
                        TypeDeclaration clientType = (TypeDeclaration)decl;
                        Set<TypeMirror> controlTypes = clientsMap.get( clientType );
                        if ( controlTypes == null )
                        {
                            controlTypes = new HashSet<TypeMirror>();
                            clientsMap.put( clientType, controlTypes );
                        }

                        // Read ControlReferences annotation
                        AnnotationMirror controlMirror = null;
                        for (AnnotationMirror annot : clientType.getAnnotationMirrors())
                        {
                            if (annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
                                    "org.apache.beehive.controls.api.bean.ControlReferences"))
                            {
                                controlMirror = annot;
                                break;
                            }
                        }

                        assert( controlMirror != null );

                        // Add each control type listed in the ControlReferences annotation
                        AptAnnotationHelper controlAnnot = new AptAnnotationHelper(controlMirror);
                        Collection<AnnotationValue> references = (Collection<AnnotationValue>)controlAnnot.getObjectValue("value");
                        if ( references != null )
                        {
                            for ( AnnotationValue av : references )
                            {
                                TypeMirror crType = (TypeMirror)av.getValue();
                                controlTypes.add( crType );
                            }
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of com.sun.mirror.type.TypeMirror

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.