本文整理汇总了Java中com.sun.javadoc.Type.asParameterizedType方法的典型用法代码示例。如果您正苦于以下问题:Java Type.asParameterizedType方法的具体用法?Java Type.asParameterizedType怎么用?Java Type.asParameterizedType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.javadoc.Type
的用法示例。
在下文中一共展示了Type.asParameterizedType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTypeTo
import com.sun.javadoc.Type; //导入方法依赖的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;
}
示例2: parameterLinks
import com.sun.javadoc.Type; //导入方法依赖的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('>');
}
}
}
示例3: internalContainerType
import com.sun.javadoc.Type; //导入方法依赖的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";
}
示例4: getReturnString
import com.sun.javadoc.Type; //导入方法依赖的package包/类
public String getReturnString(JOTDocletHolder holder)
{
Type type = null;
if (holder instanceof JOTDocletFieldHolder)
{
type = ((FieldDoc) holder.getDoc()).type();
} else
{
type = ((MethodDoc) holder.getDoc()).returnType();
}
String str = "";
if (type.asParameterizedType() != null)
{
str += handleGenerics(type, 0);
} else if (type.asTypeVariable() != null)
{
str += handleGenerics(type, 0);
} else if (type.asClassDoc() != null)
{
str += getTypeLink(type.asClassDoc());
} else
{
str += "<font class='type'>" + type.simpleTypeName() + "</font>";
}
return str;
}
示例5: isParameterizedTypeInStopClasses
import com.sun.javadoc.Type; //导入方法依赖的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;
}
示例6: getFields
import com.sun.javadoc.Type; //导入方法依赖的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;
}
示例7: parseTypeInfo
import com.sun.javadoc.Type; //导入方法依赖的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;
}
示例8: getTypeString
import com.sun.javadoc.Type; //导入方法依赖的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 += "<" + Strings.join(parametersTypeStrings, ",") + ">";
}
}
typeString += type.dimension();
return typeString;
}
示例9: handleGenerics
import com.sun.javadoc.Type; //导入方法依赖的package包/类
private String handleGenerics(Type type, int depth)
{
String str = "";
depth++;
// lame anti-recusrion hack
if (depth > 15)
{
return str;
}
//System.out.println(type.qualifiedTypeName());
if (type.asParameterizedType() != null)
{
str += getTypeLink(type.asParameterizedType().asClassDoc());
Type[] args = type.asParameterizedType().typeArguments();
if (args.length > 0)
{
str += "<";
for (int i = 0; i != args.length; i++)
{
if (i > 0)
{
str += ", ";
}
// generic might be imbricated, so recurse as needed
//System.out.println("$ "+str);
str += handleGenerics(args[i], depth);
}
str += ">";
}
} else if (type.asTypeVariable() != null)
{
String name = type.simpleTypeName();
/*Type[] types=type.asTypeVariable().bounds();
for (int i = 0; i != types.length; i++)
{
if (i > 0)
{
str += ", ";
}
// generic might be imbricated, so recurse as needed
str+=handleGenerics(types[i],depth);
}*/
str += (sameName(name, type.asTypeVariable()) ? "" : " <font class='genericVar'>" + type.asTypeVariable().typeName() + "</font>");
} else if (type.asClassDoc() != null)
{
str = getTypeLink(type.asClassDoc());
} else
{
str = "<font class='type'>" + type.simpleTypeName() + "</font>";
}
return str;
}
示例10: makeElementTypeInfo
import com.sun.javadoc.Type; //导入方法依赖的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;
}