Java 类com.sun.javadoc.WildcardType 实例源码

项目:marklet    文件:MarkletDocumentBuilder.java   
/**
 * Appends to the current document the given type parameter
 * as a valid markdown link.
 * 
 * @param source Source package to start URL from.
 * @param type Target type parameter to reach from this package.
 */
private void parameterLink(final PackageDoc source, final Type type) {
    final WildcardType wildcard = type.asWildcardType();
    if (wildcard != null) {
        character('?');
    }
    else {
        final TypeVariable variableType = type.asTypeVariable();
        if (variableType != null) {
            final Type [] bounds = variableType.bounds();
            if (bounds.length > 0) {
                text("? extends ");
                for (int i = 0; i < bounds.length; i++) {
                    typeLink(source, bounds[i]);
                    if (i < bounds.length - 1) {
                        text(" & ");
                    }
                }
            }
        }
        else {
            typeLink(source, type);
        }
    }
}
项目:xml-doclet    文件:Parser.java   
protected TypeInfo parseTypeInfo(Type type) {
  TypeInfo typeInfoNode = objectFactory.createTypeInfo();
  typeInfoNode.setName(type.simpleTypeName());
  typeInfoNode.setDisplayName(type.simpleTypeName());
  if (type.isPrimitive()) {
    typeInfoNode.setIdentifier(type.qualifiedTypeName());
  } else {
    typeInfoNode.setIdentifier(parseIdentifier(type));
  }
  typeInfoNode.setFull(type.qualifiedTypeName());
  String dimension = type.dimension();
  if (dimension.length() > 0) {
    typeInfoNode.setDimension(dimension);
  }

  WildcardType wildcard = type.asWildcardType();
  if (wildcard != null) {
    typeInfoNode.setWildcard(parseWildcard(wildcard));
  }

  ParameterizedType parameterized = type.asParameterizedType();
  if (parameterized != null) {
    for (Type typeArgument : parameterized.typeArguments()) {
      typeInfoNode.getGeneric().add(parseTypeInfo(typeArgument));
    }
  }

  return typeInfoNode;
}
项目:xml-doclet    文件:Parser.java   
protected Wildcard parseWildcard(WildcardType wildcard) {
  Wildcard wildcardNode = objectFactory.createWildcard();

  for (Type extendType : wildcard.extendsBounds()) {
    wildcardNode.getExtendsBound().add(parseTypeInfo(extendType));
  }

  for (Type superType : wildcard.superBounds()) {
    wildcardNode.getSuperBound().add(parseTypeInfo(superType));
  }

  return wildcardNode;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * @return the full JSON for the given Type
 */
protected JSONObject processWildcardType(WildcardType wildcardType) {

    if (wildcardType == null) {
        return null;
    }

    JSONObject retMe = new JSONObject();

    retMe.put("extendsBounds", processTypes( wildcardType.extendsBounds() ) );
    retMe.put("superBounds", processTypes( wildcardType.superBounds() ) );

    return retMe;
}
项目:byps    文件:BConvert.java   
/**
 * Convert a javadoc Type object into an object of my TypeInfo class.
 * @param errInfo
 * @param type
 * @param errorContext
 * @return TypeInfo object
 * @throws GeneratorException
 */
private TypeInfo makeElementTypeInfo(ErrorInfo errInfo, Type type, String errorContext) throws GeneratorException {
    errInfo = errInfo.copy();

    if (type == null) return null;

    TypeInfo tinfo = null;

    WildcardType wtype = type.asWildcardType();

    String qname = type.qualifiedTypeName();
    if (wtype != null) {

        // Wildcard Parameter machen keinen Sinn.
        // Die Elemente werden sowohl als Konsument als auch als Produzent verwendet.
        // http://www.torsten-horn.de/techdocs/java-generics.htm#Wildcard-extends-versus-T-extends
        errInfo.msg = "Wildcard parameter types are unsupported, please replace type=\"" + type +"\" by \"Object\".";
        throw new GeneratorException(errInfo);

    }
    else {
        ParameterizedType ptype = type.asParameterizedType();
        List<TypeInfo> argInfos = getParameterizedTypeArgs(errInfo, ptype, errorContext);

        ClassDoc cls = type.asClassDoc();
        boolean isEnum = false;
        boolean isInline = false; 
        boolean isFinal = false;

        if (cls != null) {
            isEnum = cls.isEnum() || cls.isEnumConstant();
            isInline = isInline(cls);
            isFinal = cls.isFinal();
        }

        tinfo = classDB.createTypeInfo(
                type.simpleTypeName(),
                qname,
                type.dimension(),
                argInfos,
                isEnum, 
                isFinal, 
                isInline);

        makeSerialInfoForCollectionType(errInfo, tinfo);
    }


    return tinfo;
}