Package com.sun.mirror.declaration

Examples of com.sun.mirror.declaration.TypeDeclaration


          Types types = Context.getCurrentEnvironment().getTypeUtils();
          if (specifiedType instanceof PrimitiveType) {
            specifiedType = types.getPrimitiveType(((PrimitiveType) specifiedType).getKind());
          }
          else {
            TypeDeclaration decl = ((DeclaredType) specifiedType).getDeclaration();
            while (decl instanceof DecoratedTypeDeclaration) {
              decl = (TypeDeclaration) ((DecoratedTypeDeclaration) decl).getDelegate();
            }
            specifiedType = types.getDeclaredType(decl);
          }
View Full Code Here


          Types types = Context.getCurrentEnvironment().getTypeUtils();
          if (specifiedType instanceof PrimitiveType) {
            specifiedType = types.getPrimitiveType(((PrimitiveType) specifiedType).getKind());
          }
          else {
            TypeDeclaration decl = ((DeclaredType) specifiedType).getDeclaration();
            while (decl instanceof DecoratedTypeDeclaration) {
              decl = (TypeDeclaration) ((DecoratedTypeDeclaration) decl).getDelegate();
            }
            specifiedType = types.getDeclaredType(decl);
          }
View Full Code Here

    }
    else if (clazz.isArray()) {
      undecorated = env.getTypeUtils().getArrayType(getAccessorType(clazz.getComponentType()));
    }
    else {
      TypeDeclaration typeDeclaration = env.getTypeDeclaration(clazz.getName());
      //todo: worry about the formal type parameters?
      undecorated = env.getTypeUtils().getDeclaredType(typeDeclaration);
    }

    return TypeMirrorDecorator.decorate(undecorated);
View Full Code Here

    for (ReferenceType referenceType : getThrownTypes()) {
      if (!(referenceType instanceof DeclaredType)) {
        throw new ValidationException(getPosition(), "Method " + getSimpleName() + " of " + endpointInterface.getQualifiedName() + ": Thrown type must be a declared type.");
      }

      TypeDeclaration declaration = ((DeclaredType) referenceType).getDeclaration();

      if (declaration == null) {
        throw new ValidationException(getPosition(), "Method " + getSimpleName() + " of " + endpointInterface.getQualifiedName() + ": unknown declaration for " + referenceType);
      }
View Full Code Here

          if (TypeHint.NONE.class.equals(hint)) {
            hintName = hintInfo.qualifiedName();
          }

          if (!"##NONE".equals(hintName)) {
            TypeDeclaration type = env.getTypeDeclaration(hintName);
            typeMirror = TypeMirrorDecorator.decorate(env.getTypeUtils().getDeclaredType(type));
          }
          else {
            typeMirror = delegate.getType();
          }
        }
      }
      catch (MirroredTypeException e) {
        typeMirror = e.getTypeMirror();
      }
    }
    else {
      typeMirror = delegate.getType();

      if (getJavaDoc().get("inputWrapped") != null) { //support jax-doclets. see http://jira.codehaus.org/browse/ENUNCIATE-690
        String fqn = getJavaDoc().get("inputWrapped").get(0);
        AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
        TypeDeclaration type = env.getTypeDeclaration(fqn);
        if (type != null) {
          typeMirror = TypeMirrorDecorator.decorate(env.getTypeUtils().getDeclaredType(type));
        }
      }
    }
View Full Code Here

    else if (enumClass.isArray()) {
      TypeMirror componentType = getEnumBaseClass(enumClass.getComponentType());
      return getEnv().getTypeUtils().getArrayType(componentType);
    }
    else {
      TypeDeclaration decl = getEnv().getTypeDeclaration(enumClass.getName());
      return getEnv().getTypeUtils().getDeclaredType(decl);
    }
  }
View Full Code Here

    else if (typeMirror instanceof MapType) {
      return (MapType) typeMirror;
    }

    DeclaredType declaredType = (DeclaredType) typeMirror;
    TypeDeclaration declaration = declaredType.getDeclaration();
    if (declaration == null) {
      return null;
    }
    else if ("java.util.Map".equals(declaration.getQualifiedName())) {
      TypeMirror keyType = null;
      TypeMirror valueType = null;

      Collection<TypeMirror> typeArgs = declaredType.getActualTypeArguments();
      if ((typeArgs != null) && (typeArgs.size() == 2)) {
        Iterator<TypeMirror> argIt = typeArgs.iterator();
        keyType = argIt.next();
        valueType = argIt.next();
      }

      if ((keyType == null) || (valueType == null)) {
        AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
        TypeMirror objectType = env.getTypeUtils().getDeclaredType(env.getTypeDeclaration(Object.class.getName()));
        keyType = objectType;
        valueType = objectType;
      }

      return new MapType((InterfaceType) declaredType, keyType, valueType);
    }
    else if (TYPE_STACK.get().contains(declaration.getQualifiedName())) {
      return null;
    }
    else {
      TYPE_STACK.get().push(declaration.getQualifiedName());
      try {
        AdapterType adapterType = AdapterUtil.findAdapterType(declaration);
        if (adapterType != null) {
          return findMapType(adapterType.getAdaptingType());
        }
View Full Code Here

    else if (declaration instanceof WebParam) {
      WebParam parameter = ((WebParam) declaration);
      return findAdapterType(parameter.getType(), parameter, parameter.getWebMethod().getDeclaringEndpointInterface().getPackage());
    }
    else if (declaration instanceof TypeDeclaration) {
      TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
     
      // Context usage is not thread-safe!!
      AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
      typeDeclaration = ape.getTypeDeclaration(typeDeclaration.getQualifiedName()); //unwrap the decorated stuff as necessary...
      DeclaredType declaredType = ape.getTypeUtils().getDeclaredType(typeDeclaration);
      return findAdapterType(declaredType, null, null);
    }
    else {
      throw new IllegalArgumentException("A " + declaration.getClass().getSimpleName() + " is not an adaptable declaration according to the JAXB spec.");
View Full Code Here

   * The scope of the local element.
   *
   * @return The scope of the local element.
   */
  public TypeDeclaration getElementScope() {
    TypeDeclaration declaration = null;
    try {
      if (elementDecl.scope() != XmlElementDecl.GLOBAL.class) {
        Class typeClass = elementDecl.scope();
        declaration = getEnv().getTypeDeclaration(typeClass.getName());
      }
View Full Code Here

  private static AdapterType findAdapterType(TypeMirror unwrappedAdaptedType, Declaration referer, PackageDeclaration pckg) {
    TypeMirror adaptedType = unwrapComponentType(unwrappedAdaptedType);
    XmlJavaTypeAdapter typeAdapterInfo = referer != null ? referer.getAnnotation(XmlJavaTypeAdapter.class) : null;
    if (adaptedType instanceof DeclaredType) {
      if (typeAdapterInfo == null) {
        TypeDeclaration typeDeclaration = ((DeclaredType) adaptedType).getDeclaration();
        if (typeDeclaration == null) {
          throw new IllegalStateException("Class not found: " + adaptedType);
        }
        typeAdapterInfo = typeDeclaration.getAnnotation(XmlJavaTypeAdapter.class);
      }

      if ((typeAdapterInfo == null) && (pckg != null)) {
        TypeDeclaration typeDeclaration = ((DeclaredType) adaptedType).getDeclaration();
        if (typeDeclaration == null) {
          throw new IllegalStateException("Class not found: " + adaptedType);
        }
        typeAdapterInfo = getAdaptersOfPackage(pckg).get(typeDeclaration.getQualifiedName());
      }
    }

    if (typeAdapterInfo != null) {
      ClassType adapterTypeMirror;
View Full Code Here

TOP

Related Classes of com.sun.mirror.declaration.TypeDeclaration

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.