当前位置: 首页>>代码示例>>Java>>正文


Java ParameterizedType类代码示例

本文整理汇总了Java中com.sun.javadoc.ParameterizedType的典型用法代码示例。如果您正苦于以下问题:Java ParameterizedType类的具体用法?Java ParameterizedType怎么用?Java ParameterizedType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ParameterizedType类属于com.sun.javadoc包,在下文中一共展示了ParameterizedType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSimpleTypeName

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
public static String getSimpleTypeName(Type type) {
    if (type instanceof ParameterizedType) {
        String typeName = type.typeName() + "<";
        boolean firstParameter = true;
        for (Type parameter : ((ParameterizedType) type).typeArguments()) {
            if (firstParameter) {
                typeName += getSimpleTypeName(parameter);
                firstParameter = false;
            }
            else {
                typeName += "," + getSimpleTypeName(parameter);
            }
        }
        typeName += ">";
        return typeName;
    }
    return type.typeName();
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:19,代码来源:Utils.java

示例2: writeTypeTo

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
protected static IndentingPrintWriter writeTypeTo(IndentingPrintWriter out, Type type) {
    if (type != null) {
        out.append(type.typeName());
        final ParameterizedType parameterizedType = type.asParameterizedType();
        if (parameterizedType != null) {
            final Type[] generics = parameterizedType.typeArguments();
            if (generics.length > 0) {
                out.append("<");
                String sep = "";
                for (Type generic : generics) {
                    writeTypeTo(out.append(sep), generic);
                    sep = ", ";
                }
                out.append(">");
            }
        }
        out.append(type.dimension());
    }
    return out;
}
 
开发者ID:talsma-ict,项目名称:umldoclet,代码行数:21,代码来源:Renderer.java

示例3: addAllInterfaceTypes

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
private void addAllInterfaceTypes(Map results, Type type,
        Type[] interfaceTypes, boolean raw) {
    for (int i = 0; i < interfaceTypes.length; i++) {
        Type interfaceType = interfaceTypes[i];
        ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
        if (! (interfaceClassDoc.isPublic() ||
            interfaceClassDoc.isIncluded())) {
            continue;
        }
        if (raw)
            interfaceType = interfaceType.asClassDoc();
        results.put(interfaceClassDoc, interfaceType);
        List superInterfaces = getAllInterfaces(interfaceType);
        for (Iterator iter = superInterfaces.iterator(); iter.hasNext(); ) {
            Type superInterface = (Type) iter.next();
            results.put(superInterface.asClassDoc(), superInterface);
        }
    }
    if (type instanceof ParameterizedType)
        findAllInterfaceTypes(results, (ParameterizedType) type);
    else if (((ClassDoc) type).typeParameters().length == 0)
        findAllInterfaceTypes(results, (ClassDoc) type, raw);
    else
        findAllInterfaceTypes(results, (ClassDoc) type, true);
}
 
开发者ID:riptano,项目名称:xml-doclet,代码行数:26,代码来源:ClassTree.java

示例4: parameterLinks

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
/**
 * Appends to the current document the list of parameters
 * from the given ``type`` if any.
 * 
 * @param source Source package to start URL from.
 * @param type Target type to append parameters from.
 */
private void parameterLinks(final PackageDoc source, final Type type) {
	final ParameterizedType invocation = type.asParameterizedType();
	if (invocation != null) {
		final Type [] types = invocation.typeArguments();
		if (types.length > 0) {
			character('<');
			for (int i = 0; i < types.length; i++) {
				parameterLink(source, types[i]);
				if (i < types.length - 1) {
					text(", ");
				}
			}
			character('>');
		}
	}
}
 
开发者ID:Faylixe,项目名称:marklet,代码行数:24,代码来源:MarkletDocumentBuilder.java

示例5: internalContainerType

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
/**
 * This will grab the internal type from an array or a parameterized container.
 * @param type
 * @return
 */
public static String internalContainerType(Type type) {
    //treat arrays first
    if (type.dimension() != null && !type.dimension().isEmpty())
        return basicType(type);

    ParameterizedType pType = type.asParameterizedType();
    if (pType != null) {
        Type[] paramTypes = ((ParameterizedType)type).typeArguments();
        if (!isEmpty(paramTypes))
            return basicType(paramTypes[0]);
    }

    //TODO look into supporting models.
    return "Object";
}
 
开发者ID:calrissian,项目名称:rest-doclet,代码行数:21,代码来源:TypeUtils.java

示例6: isParameterizedTypeInStopClasses

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
protected boolean isParameterizedTypeInStopClasses(Type type) {
	if (!this.isInStopClasses(type.asClassDoc())) {
		return false;
	}
	ParameterizedType pt = type.asParameterizedType();
	if (pt != null) {
		for (Type arg : pt.typeArguments()) {
			if (!this.isParameterizedTypeInStopClasses(arg)) {
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:15,代码来源:AbstractDocBuilder.java

示例7: getFields

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
protected List<APIParameter> getFields(Type type, ParameterType paramType, HashSet<String> processingClasses) {
	processingClasses.add(type.toString());
	List<APIParameter> result = new LinkedList<APIParameter>();
	if (!type.isPrimitive()) {
		ParameterizedType pt = type.asParameterizedType();
		if (pt != null && pt.typeArguments().length > 0) {
			for (Type arg : pt.typeArguments()) {
				if (!this.isParameterizedTypeInStopClasses(arg)) {
					APIParameter tmp = new APIParameter();
					tmp.setName(arg.simpleTypeName());
					tmp.setType(this.getTypeName(arg, false));
					tmp.setDescription("");
					tmp.setParentTypeArgument(true);
					if (!processingClasses.contains(arg.qualifiedTypeName())) {
						tmp.setFields(this.getFields(arg, paramType, processingClasses));
					}
					result.add(tmp);
				}
			}
		}

		ClassDoc classDoc = this.wrDoc.getConfiguration().root.classNamed(type.qualifiedTypeName());
		if (classDoc != null) {
			result.addAll(this.getFields(classDoc, paramType, processingClasses));
		}
	}
	return result;
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:29,代码来源:AbstractDocBuilder.java

示例8: findAllInterfaceTypes

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
private void findAllInterfaceTypes(Map results, ClassDoc c, boolean raw) {
    Type superType = c.superclassType();
    if (superType == null)
        return;
    addAllInterfaceTypes(results, superType,
            superType instanceof ClassDoc ?
            ((ClassDoc) superType).interfaceTypes() :
            ((ParameterizedType) superType).interfaceTypes(),
            raw);
}
 
开发者ID:riptano,项目名称:xml-doclet,代码行数:11,代码来源:ClassTree.java

示例9: parseTypeInfo

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
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;
}
 
开发者ID:riptano,项目名称:xml-doclet,代码行数:30,代码来源:Parser.java

示例10: getParameterizedTypeArgs

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
/**
 * Convert generic type args from javadoc to my TypeInfo objects.
 * @param errInfo
 * @param ptype
 * @param errorContext
 * @return List of TypeInfo objects
 * @throws GeneratorException
 */
private List<TypeInfo> getParameterizedTypeArgs(ErrorInfo errInfo, ParameterizedType ptype, String errorContext) throws GeneratorException {
	errInfo = errInfo.copy();
	List<TypeInfo> argInfos = null;
	if (ptype != null) {
		Type[] targs = ptype.typeArguments();
		argInfos = new ArrayList<TypeInfo>(targs.length);
		for (int i = 0; i < targs.length; i++) {
			errInfo.typeArg = "<" + targs[i] + ">";
			argInfos.add( makeElementTypeInfo(errInfo, targs[i], errorContext) );
		}
	}
	return argInfos;
}
 
开发者ID:wolfgangimig,项目名称:byps,代码行数:22,代码来源:BConvert.java

示例11: getTypeString

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
/**
 * Returns type string.
 *
 * @param type type for which to return type string
 * @return type string, including parametrized types, dimensions and links.
 */
private String getTypeString(Type type) {
    String typeQualifiedName = type.qualifiedTypeName().replaceFirst("^java\\.lang\\.", "");
    typeQualifiedName = typeQualifiedName.replaceFirst("^com\\.qspin\\.qtaste\\.testsuite\\.(QTaste\\w*Exception)", "$1");
    String typeDocFileName = null;
    if (typeQualifiedName.startsWith("com.qspin.")) {
        String javaDocDir = typeQualifiedName.startsWith("com.qspin.qtaste.") ? QTaste_JAVADOC_URL_PREFIX :
              SUT_JAVADOC_URL_PREFIX;
        typeDocFileName = javaDocDir + typeQualifiedName.replace('.', '/') + ".html";
    }
    String typeString = typeQualifiedName;
    if (typeDocFileName != null) {
        typeString = "<A HREF=\"" + typeDocFileName + "\">" + typeString + "</A>";
    }
    if (type.asParameterizedType() != null) {
        ParameterizedType parametrizedType = type.asParameterizedType();
        final Type[] parameterTypes = parametrizedType.typeArguments();
        if (parameterTypes.length > 0) {
            String[] parametersTypeStrings = new String[parameterTypes.length];
            for (int i = 0; i < parameterTypes.length; i++) {
                parametersTypeStrings[i] = getTypeString(parameterTypes[i]);
            }
            typeString += "&lt;" + Strings.join(parametersTypeStrings, ",") + "&gt;";
        }
    }
    typeString += type.dimension();

    return typeString;
}
 
开发者ID:qspin,项目名称:qtaste,代码行数:35,代码来源:HTMLFileWriter.java

示例12: getAllInterfaces

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
public List getAllInterfaces(Type type) {
    Map results = new TreeMap();
    Type[] interfaceTypes = null;
    Type superType = null;
    if (type instanceof ParameterizedType) {
        interfaceTypes = ((ParameterizedType) type).interfaceTypes();
        superType = ((ParameterizedType) type).superclassType();
    } else if (type instanceof ClassDoc) {
        interfaceTypes = ((ClassDoc) type).interfaceTypes();
        superType = ((ClassDoc) type).superclassType();
    } else {
        interfaceTypes = type.asClassDoc().interfaceTypes();
        superType = type.asClassDoc().superclassType();
    }

    for (int i = 0; i < interfaceTypes.length; i++) {
        Type interfaceType = interfaceTypes[i];
        ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
        if (! (interfaceClassDoc.isPublic() ||
               interfaceClassDoc.isIncluded())) {
            continue;
        }
        results.put(interfaceClassDoc, interfaceType);
        List superInterfaces = getAllInterfaces(interfaceType);
        for (Iterator iter = superInterfaces.iterator(); iter.hasNext(); ) {
            Type t = (Type) iter.next();
            results.put(t.asClassDoc(), t);
        }
    }
    if (superType == null)
        return new ArrayList(results.values());
    //Try walking the tree.
    addAllInterfaceTypes(results,
        superType,
        superType instanceof ClassDoc ?
            ((ClassDoc) superType).interfaceTypes() :
            ((ParameterizedType) superType).interfaceTypes(),
        false);
    List resultsList = new ArrayList(results.values());
    Collections.sort(resultsList, new TypeComparator());
    return resultsList;
}
 
开发者ID:riptano,项目名称:xml-doclet,代码行数:43,代码来源:ClassTree.java

示例13: renderOn

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
@Override
public void renderOn(HtmlCanvas html) throws IOException {
    if (type.isPrimitive()) {
        html.write(type.typeName() + type.dimension());
    } else {
        String name;
        ClassDoc classDoc = type.asClassDoc();
        DocReferenceable referenceable = generator.getRefLocator().getClassDocRef(classDoc);
        String ref = PageRenderer.getPage(html).getReferenceTo(referenceable);
        if ((flags & FQN) != 0) {
            name = classDoc.qualifiedName();
        } else {
            name = referenceable.getName();
        }
        if ((flags & LINK) != 0 && ref != null) {
            html.a(href(PageRenderer.getPage(html).getReferenceTo(referenceable))).content(name,
                    HtmlCanvas.NO_ESCAPE);
        } else {
            html.write(name);
        }
    }

    ParameterizedType parameterizedType = type.asParameterizedType();
    if (parameterizedType != null) {
        Type[] typeArguments = parameterizedType.typeArguments();
        if (typeArguments.length > 0) {
            html.write("<");
            for (int typeVarCount = 0; typeVarCount < typeArguments.length; typeVarCount++) {
                Type typeArgument = typeArguments[typeVarCount];
                if (typeVarCount > 0) {
                    html.write(", ");
                }
                renderReferenceable(generator.getRefLocator().getClassDocRef(typeArgument.asClassDoc()), html);
            }
            html.write(">");
        }
    } else if (!type.isPrimitive()) {
        TypeVariable[] typeVariables = type.asClassDoc().typeParameters();
        if (typeVariables.length > 0) {
            html.write("<");
            for (int typeVarCount = 0; typeVarCount < typeVariables.length; typeVarCount++) {
                TypeVariable typeVariable = typeVariables[typeVarCount];
                if (typeVarCount > 0) {
                    html.write(", ");
                }
                html.write(typeVariable.typeName());
                if ((flags & BOUNDS) != 0) {
                    Type[] bounds = typeVariable.bounds();
                    if (bounds.length > 0) {
                        html.write(" extends ");
                        for (int boundCnt = 0; boundCnt < bounds.length; boundCnt++) {
                            ClassDoc boundClass = bounds[boundCnt].asClassDoc();
                            if (boundCnt > 0) {
                                html.write(" & ");
                            }
                            renderReferenceable(generator.getRefLocator().getClassDocRef(boundClass), html);
                        }
                    }
                }
            }
            html.write(">");
        }
    }
}
 
开发者ID:nicolaschriste,项目名称:docdown,代码行数:65,代码来源:ClassNameRenderable.java

示例14: makeElementTypeInfo

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:wolfgangimig,项目名称:byps,代码行数:58,代码来源:BConvert.java

示例15: processParameterizedType

import com.sun.javadoc.ParameterizedType; //导入依赖的package包/类
/**
 * @return the full JSON for the given Type
 */
protected JSONObject processParameterizedType(ParameterizedType parameterizedType) {
    
    if (parameterizedType == null) {
        return null;
    }
    
    JSONObject retMe = new JSONObject();
    
    retMe.put("typeArguments", processTypes( parameterizedType.typeArguments() ) );

    return retMe;
}
 
开发者ID:rob4lderman,项目名称:javadoc-json-doclet,代码行数:16,代码来源:JsonDoclet.java


注:本文中的com.sun.javadoc.ParameterizedType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。