Package com.sun.mirror.type

Examples of com.sun.mirror.type.TypeMirror


   */
  public String getMaxOccurs() {
    DecoratedTypeMirror paramType = (DecoratedTypeMirror) getType();
    boolean unbounded = paramType.isCollection() || paramType.isArray();
    if (paramType.isArray()) {
      TypeMirror componentType = ((ArrayType) paramType).getComponentType();
      //special case for byte[]
      if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) {
        unbounded = false;
      }
    }
View Full Code Here


  }

  @Override
  public String convert(TypeMirror typeMirror) throws TemplateModelException {
    if (typeMirror instanceof ArrayType) {
      TypeMirror componentType = ((ArrayType) typeMirror).getComponentType();
      if (!(componentType instanceof PrimitiveType) || (((PrimitiveType) componentType).getKind() != PrimitiveType.Kind.BYTE)) {
        return super.convert(componentType);
      }
    }
    else if (typeMirror instanceof DeclaredType) {
View Full Code Here

   *
   * @param accessor    The accessor.
   * @return The XML type, or null if none was specified.
   */
  public static XmlType findExplicitSchemaType(Accessor accessor) {
    TypeMirror typeMirror = unwrapComponentType(accessor.getAccessorType());

    XmlType xmlType = null;
    XmlSchemaType schemaType = accessor.getAnnotation(XmlSchemaType.class);

    if ((schemaType == null) && (typeMirror instanceof DeclaredType)) {
      PackageDeclaration pckg = accessor.getDeclaringType().getPackage();
      String packageName = pckg.getQualifiedName();
      HashMap<String, XmlSchemaType> explicitTypes = EXPLICIT_ELEMENTS_BY_PACKAGE.get(packageName);
      if (explicitTypes == null) {
        explicitTypes = new HashMap<String, XmlSchemaType>();
        EXPLICIT_ELEMENTS_BY_PACKAGE.put(packageName, explicitTypes);

        XmlSchemaType schemaTypeInfo = pckg.getAnnotation(XmlSchemaType.class);
        XmlSchemaTypes schemaTypes = pckg.getAnnotation(XmlSchemaTypes.class);

        if ((schemaTypeInfo != null) || (schemaTypes != null)) {
          ArrayList<XmlSchemaType> allSpecifiedTypes = new ArrayList<XmlSchemaType>();
          if (schemaTypeInfo != null) {
            allSpecifiedTypes.add(schemaTypeInfo);
          }

          if (schemaTypes != null) {
            allSpecifiedTypes.addAll(Arrays.asList(schemaTypes.value()));
          }

          for (XmlSchemaType specifiedType : allSpecifiedTypes) {
            String typeFqn;
            try {
              Class specifiedClass = specifiedType.type();
              if (specifiedClass == XmlSchemaType.DEFAULT.class) {
                throw new ValidationException(pckg.getPosition(), pckg.getQualifiedName() + ": a type must be specified in " + XmlSchemaType.class.getName() + " at the package-level.");
              }
              typeFqn = specifiedClass.getName();
            }
            catch (MirroredTypeException e) {
              TypeMirror explicitTypeMirror = e.getTypeMirror();
              if (!(explicitTypeMirror instanceof DeclaredType)) {
                throw new ValidationException(pckg.getPosition(), pckg.getQualifiedName() + ": only a declared type can be adapted.  Offending type: " + explicitTypeMirror);
              }
              typeFqn = ((DeclaredType) explicitTypeMirror).getDeclaration().getQualifiedName();
            }
View Full Code Here

      throw new TemplateModelException("The functionIdentifierFor method must have an accessor or type mirror as a parameter.");
    }

    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = BeansWrapper.getDefaultInstance().unwrap(from);
    TypeMirror typeMirror;
    if (unwrapped instanceof Accessor) {
      Accessor accessor = (Accessor) unwrapped;
      if (accessor.isAdapted()) {
        typeMirror = accessor.getAdapterType().getAdaptingType(accessor.getAccessorType());
      }
View Full Code Here

    }
    else if (decorated.isCollection()) {
      return "Array";
    }
    else if (decorated.isArray()) {
      TypeMirror componentType = ((ArrayType) decorated).getComponentType();
      if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) {
        return "String";
      }
    }
View Full Code Here

      return jsonSchemaForType(jsonType);
    }

    if (object instanceof ResourceRepresentationMetadata) {
      ResourceRepresentationMetadata metadata = (ResourceRepresentationMetadata) object;
      TypeMirror typeMirror = metadata.getDelegate();
      final JsonType jsonType = model.findJsonTypeDefinition(typeMirror.toString());
      return jsonSchemaForType(jsonType);
    }

    if (object instanceof TypeMirror) {
      TypeMirror typeMirror = (TypeMirror) object;
      final JsonType jsonType = model.findJsonTypeDefinition(typeMirror.toString());
      return jsonSchemaForType(jsonType);
    }

    if (object instanceof JsonType) {
      final JsonType jsonType = (JsonType) object;
View Full Code Here

    }
    else if (decorated.isCollection()) {
      return "Array";
    }
    else if (decorated.isArray()) {
      TypeMirror componentType = ((ArrayType) decorated).getComponentType();
      if ((componentType instanceof PrimitiveType) && (((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE)) {
        return "String";
      }
    }
View Full Code Here

        if (!typeDef.isBaseObject()) {
          imports.add(classnameFor.convert(typeDef.getSuperclass()));
        }
        for (Attribute attribute : typeDef.getAttributes()) {
          imports.add(classnameFor.convert(attribute));
          TypeMirror accessorType;
          if (attribute.isAdapted()) {
              // If the attribute is adaptable, we need to use the adapting type
              // else it will try to import the "real type" defined by the attribute.
              accessorType = attribute.getAdapterType().getAdaptingType();
          }
          else {
              accessorType = attribute.getAccessorType();
          }
          addComponentTypes(accessorType, imports);
        }
        for (Element element : typeDef.getElements()) {
          imports.add(classnameFor.convert(element));
          TypeMirror accessorType;
          if (element.isAdapted()) {
              // If the element is adaptable, we need to use the adapting type
              // else it will try to import the "real type" defined by the attribute.
              accessorType = element.getAdapterType().getAdaptingType();
          }
View Full Code Here

                defaultNamespaceRemap );

        builder.setErrorHandler(new ErrorHandlerImpl(env.getMessager()));

        for( Reference ref : rootClasses ) {
            TypeMirror t = ref.type;

            XmlJavaTypeAdapter xjta = ref.annotations.getAnnotation(XmlJavaTypeAdapter.class);
            XmlList xl = ref.annotations.getAnnotation(XmlList.class);

            builder.getTypeInfo(new Ref<TypeMirror,TypeDeclaration>(builder,t,xjta,xl));
View Full Code Here

    public boolean isArrayButNotByteArray(TypeMirror t) {
        if(!isArray(t))
            return false;

        ArrayType at = (ArrayType) t;
        TypeMirror ct = at.getComponentType();

        return !ct.equals(primitiveByte);
    }
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.