Examples of DecoratedTypeMirror


Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   */
  protected boolean isInstanceOf(ClassDeclaration classDeclaration, String fqn) {
    AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
    Types utils = env.getTypeUtils();
    DeclaredType declaredType = utils.getDeclaredType(env.getTypeDeclaration(classDeclaration.getQualifiedName()));
    DecoratedTypeMirror decorated = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaredType);
    return decorated.isInstanceOf(fqn);
  }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   * @return the qname of the referenced root element declaration.
   */
  protected QName loadRef() {
    TypeDeclaration declaration = null;
    String elementDeclaration;
    DecoratedTypeMirror refType;
    try {
      if ((xmlElementRef != null) && (xmlElementRef.type() != XmlElementRef.DEFAULT.class)) {
        Class typeClass = xmlElementRef.type();
        elementDeclaration = typeClass.getName();
        declaration = getEnv().getTypeDeclaration(typeClass.getName());
        refType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(getEnv().getTypeUtils().getDeclaredType(declaration));
      }
      else {
        TypeMirror accessorType = getBareAccessorType();
        elementDeclaration = accessorType.toString();
        if (accessorType instanceof DeclaredType) {
          declaration = ((DeclaredType) accessorType).getDeclaration();
        }
        refType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(accessorType);
      }
    }
    catch (MirroredTypeException e) {
      //This exception implies the ref is within the source base.
      TypeMirror typeMirror = e.getTypeMirror();
      elementDeclaration = typeMirror.toString();
      if (typeMirror instanceof DeclaredType) {
        declaration = ((DeclaredType) typeMirror).getDeclaration();
      }
      refType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror);
    }

    QName refQName = null;
    if (refType.isInstanceOf(JAXBElement.class.getName())) {
      String localName = xmlElementRef != null && !"##default".equals(xmlElementRef.name()) ? xmlElementRef.name() : null;
      String namespace = xmlElementRef != null ? xmlElementRef.namespace() : "";
      if (localName == null) {
        throw new ValidationException(getPosition(), "Member " + getName() + " of " + getTypeDefinition().getQualifiedName() + ": @XmlElementRef annotates a type JAXBElement without specifying the name of the JAXB element.");
      }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

      specifiedType = TypeMirrorDecorator.decorate(e.getTypeMirror());
    }

    if (specifiedType != null) {
      if (!isChoice) {
        DecoratedTypeMirror accessorType = (DecoratedTypeMirror) super.getAccessorType();

        if (accessorType.isCollection()) {
          AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
          Types types = ape.getTypeUtils();
          if (specifiedType instanceof PrimitiveType) {
            specifiedType = types.getPrimitiveType(((PrimitiveType) specifiedType).getKind());
          }
          else {
            specifiedType = types.getDeclaredType(ape.getTypeDeclaration(((DeclaredType) specifiedType).getDeclaration().getQualifiedName()));
          }
          specifiedType = TypeMirrorDecorator.decorate(types.getDeclaredType(ape.getTypeDeclaration(((DeclaredType) accessorType).getDeclaration().getQualifiedName()), specifiedType));
        }
        else if (accessorType.isArray() && !(specifiedType instanceof ArrayType)) {
          Types types = Context.getCurrentEnvironment().getTypeUtils();
          if (specifiedType instanceof PrimitiveType) {
            specifiedType = types.getPrimitiveType(((PrimitiveType) specifiedType).getKind());
          }
          else {
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

      specifiedType = TypeMirrorDecorator.decorate(e.getTypeMirror());
    }

    if (specifiedType != null) {
      if (!isChoice) {
        DecoratedTypeMirror accessorType = (DecoratedTypeMirror) super.getAccessorType();

        if (accessorType.isCollection()) {
          AnnotationProcessorEnvironment ape = Context.getCurrentEnvironment();
          Types types = ape.getTypeUtils();
          if (specifiedType instanceof PrimitiveType) {
            specifiedType = types.getPrimitiveType(((PrimitiveType) specifiedType).getKind());
          }
          else {
            specifiedType = types.getDeclaredType(ape.getTypeDeclaration(((DeclaredType) specifiedType).getDeclaration().getQualifiedName()));
          }
          specifiedType = TypeMirrorDecorator.decorate(types.getDeclaredType(ape.getTypeDeclaration(((DeclaredType) accessorType).getDeclaration().getQualifiedName()), specifiedType));
        }
        else if (accessorType.isArray() && !(specifiedType instanceof ArrayType)) {
          Types types = Context.getCurrentEnvironment().getTypeUtils();
          if (specifiedType instanceof PrimitiveType) {
            specifiedType = types.getPrimitiveType(((PrimitiveType) specifiedType).getKind());
          }
          else {
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

      Collection<ConstructorDeclaration> constructors = getConstructors();
      for (ConstructorDeclaration constructor : constructors) {
        if (constructor.getModifiers().contains(Modifier.PUBLIC)) {
          ParameterDeclaration[] parameters = constructor.getParameters().toArray(new ParameterDeclaration[constructor.getParameters().size()]);
          if (parameters.length >= 2) {
            DecoratedTypeMirror param0Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[0].getType());
            DecoratedTypeMirror param1Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[1].getType());
            if (parameters.length == 2) {
              messageConstructorFound |= param0Type.isInstanceOf(String.class.getName()) && param1Type.isInstanceOf(faultInfoType.getDeclaration().getQualifiedName());
            }
            else if (parameters.length == 3) {
              DecoratedTypeMirror param2Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[2].getType());
              messageAndThrowableConstructorFound |= param0Type.isInstanceOf(String.class.getName())
                && param1Type.isInstanceOf(faultInfoType.getDeclaration().getQualifiedName())
                && param2Type.isInstanceOf(Throwable.class.getName());
            }
          }
        }
      }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

    private final String maxOccurs;
    private final AdapterType adaperType;
    private final WebFault webFault;

    private FaultBeanChildElement(PropertyDeclaration property, WebFault webFault) {
      DecoratedTypeMirror propertyType = (DecoratedTypeMirror) property.getPropertyType();
      this.adaperType = AdapterUtil.findAdapterType(property.getGetter());
      int minOccurs = propertyType.isPrimitive() ? 1 : 0;
      boolean unbounded = propertyType.isCollection() || propertyType.isArray();
      if (propertyType.isArray()) {
        TypeMirror componentType = ((ArrayType) propertyType).getComponentType();
        //special case for byte[]
        if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) {
          unbounded = false;
        }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

    super(conversions);
  }

  @Override
  public String convert(TypeMirror typeMirror) throws TemplateModelException {
    DecoratedTypeMirror decoratedMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(typeMirror);
    if (decoratedMirror.isCollection()) {
      return convert(((DeclaredType) decoratedMirror).getDeclaration().getQualifiedName());
    }
    else {
      throw new TemplateModelException(typeMirror + " isn't a collection!");
    }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

    AdapterType adapterType = AdapterUtil.findAdapterType(declaration);
    if (adapterType != null) {
      return convert(adapterType.getAdaptingType());
    }
    if (declaration instanceof ClassDeclaration) {
      DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(((ClassDeclaration) declaration).getSuperclass());
      if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) {
        //for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement
        return convert(superType);
      }
    }
    String convertedPackage = convertPackage(declaration.getPackage());
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

          declaredEntityParameters.add(entityParameter);
          customParameterName = parameterDeclaration.getSimpleName();
        }
      }

      DecoratedTypeMirror returnTypeMirror;
      TypeHint hintInfo = getAnnotation(TypeHint.class);
      if (hintInfo != null) {
        try {
          Class hint = hintInfo.value();
          AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
          if (TypeHint.NO_CONTENT.class.equals(hint)) {
            returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(env.getTypeUtils().getVoidType());
          }
          else {
            String hintName = hint.getName();

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

            if (!"##NONE".equals(hintName)) {
              TypeDeclaration type = env.getTypeDeclaration(hintName);
              returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(env.getTypeUtils().getDeclaredType(type));
            }
            else {
              returnTypeMirror = (DecoratedTypeMirror) getReturnType();
            }
          }
        }
        catch (MirroredTypeException e) {
          returnTypeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
        }
        returnTypeMirror.setDocComment(((DecoratedTypeMirror) getReturnType()).getDocComment());
      }
      else {
        returnTypeMirror = (DecoratedTypeMirror) getReturnType();

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

        // in the case where the return type is com.sun.jersey.api.JResponse,
        // we can use the type argument to get the entity type
        if (returnTypeMirror.isClass() && returnTypeMirror.isInstanceOf("com.sun.jersey.api.JResponse")) {
          DecoratedClassType jresponse = (DecoratedClassType) returnTypeMirror;
          if (!jresponse.getActualTypeArguments().isEmpty()) {
            DecoratedTypeMirror responseType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(jresponse.getActualTypeArguments().iterator().next());
            if (responseType.isDeclared()) {
              responseType.setDocComment(returnTypeMirror.getDocComment());
              returnTypeMirror = responseType;
            }
          }
        }
      }
View Full Code Here

Examples of net.sf.jelly.apt.decorations.type.DecoratedTypeMirror

   *
   * @param signatureOverride The method signature override.
   * @return The output payload (explicit in the signature override.
   */
  protected ResourceRepresentationMetadata loadOutputPayload(ResourceMethodSignature signatureOverride) {
    DecoratedTypeMirror returnType = (DecoratedTypeMirror) getReturnType();

    try {
      Class<?> outputType = signatureOverride.output();
      if (outputType != ResourceMethodSignature.NONE.class) {
        AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
        TypeDeclaration type = env.getTypeDeclaration(outputType.getName());
        return new ResourceRepresentationMetadata(env.getTypeUtils().getDeclaredType(type), returnType.getDocValue());
      }
    }
    catch (MirroredTypeException e) {
      DecoratedTypeMirror typeMirror = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
      if (typeMirror.isDeclared()) {
        if (typeMirror.isInstanceOf(ResourceMethodSignature.class.getName() + ".NONE")) {
          return null;
        }
        return new ResourceRepresentationMetadata(typeMirror, returnType.getDocValue());
      }
      else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.