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


Java Type.asClassDoc方法代码示例

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


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

示例1: wrapArgumentCode

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:StubSkeletonWriter.java

示例2: unwrapArgumentCode

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:StubSkeletonWriter.java

示例3: addAllInterfaceTypes

import com.sun.javadoc.Type; //导入方法依赖的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: 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;
}
 
开发者ID:tcolar,项目名称:javaontracks,代码行数:27,代码来源:JOTDocletNavView.java

示例5: writeMarshalArgument

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * Writes a snippet of Java code to marshal a value named "name"
 * of type "type" to the java.io.ObjectOutput stream named
 * "stream".
 *
 * Primitive types are marshalled with their corresponding methods
 * in the java.io.DataOutput interface, and objects (including
 * arrays) are marshalled using the writeObject method.
 **/
private static void writeMarshalArgument(IndentingWriter p,
                                         String streamName,
                                         Type type, String name)
    throws IOException
{
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p(streamName + ".writeObject(" + name + ")");
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".writeBoolean(" + name + ")");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".writeByte(" + name + ")");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".writeChar(" + name + ")");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".writeShort(" + name + ")");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".writeInt(" + name + ")");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".writeLong(" + name + ")");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".writeFloat(" + name + ")");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".writeDouble(" + name + ")");
    } else {
        throw new AssertionError(type);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:StubSkeletonWriter.java

示例6: writeUnmarshalArgument

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * Writes a snippet of Java code to unmarshal a value of type
 * "type" from the java.io.ObjectInput stream named "stream" into
 * a variable named "name" (if "name" is null, the value is
 * unmarshalled and discarded).
 *
 * Primitive types are unmarshalled with their corresponding
 * methods in the java.io.DataInput interface, and objects
 * (including arrays) are unmarshalled using the readObject
 * method.
 *
 * Returns true if code to invoke readObject was written, and
 * false otherwise.
 **/
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

    if (name != null) {
        p.p(name + " = ");
    }

    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p("(" + type.toString() + ") " + streamName + ".readObject()");
        readObject = true;
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".readBoolean()");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".readByte()");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".readChar()");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".readShort()");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".readInt()");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".readLong()");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".readFloat()");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".readDouble()");
    } else {
        throw new AssertionError(type);
    }

    return readObject;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:StubSkeletonWriter.java

示例7: possiblyQualifiedName

import com.sun.javadoc.Type; //导入方法依赖的package包/类
protected String possiblyQualifiedName(Type type)
{
   if (null == type.asClassDoc()
       || !omitPackageQualifier(type.asClassDoc().containingPackage())) {
      return type.qualifiedTypeName();
   }
   else {
      return type.typeName();
   }
}
 
开发者ID:vilie,项目名称:javify,代码行数:11,代码来源:AbstractDoclet.java

示例8: possiblyQualifiedName

import com.sun.javadoc.Type; //导入方法依赖的package包/类
protected String possiblyQualifiedName(Type type)
{
   if (null == type.asClassDoc() 
       || !omitPackageQualifier(type.asClassDoc().containingPackage())) {
      return type.qualifiedTypeName();
   }
   else {
      return type.typeName();
   }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:11,代码来源:AbstractDoclet.java

示例9: getAllInheritedMethodsHelper

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * 
 * @param childClassDoc - The class for which we are determining the inherited methods 
 * @param parentClassDoc - will search for inherited methods from the *parent*
 *                         of this class. So the first pass thru this recursive
 *                         algorithm should pass in the base/child class for this
 *                         argument.
 * @param alreadyInherited - keeps track of methods we've already inherited so
 *                           as not to inherit them again from another superclass.
 *                           
 * @return [ { "superclassType": {}, "inheritedMethods": [ {}, {}, ... ] },
 *           { "superclassType": {}, "inheritedMethods": [ {}, {}, ... ] } ]
 */
protected List<Map> getAllInheritedMethodsHelper(ClassDoc childClassDoc,
                                                 ClassDoc parentClassDoc, 
                                                 List<MethodDoc> alreadyInherited) {
    List<Map> retMe = new ArrayList<Map>();
    
    // use getSuperclassTypes to handle interfaces with more than 1 superclass.
    for ( Type superclassType : getSuperclassTypes(parentClassDoc) ) {
        
        ClassDoc superclassDoc = superclassType.asClassDoc();
        
        // Collect all methods inherited from this superclass,
        // ignoring methods that we've alreadyInherited from a
        // previous superclass.
        List<MethodDoc> inheritedMethods = new ArrayList<MethodDoc>();

        for (MethodDoc supermethodDoc : superclassDoc.methods()) {
            if ( !isMethodOverridden( supermethodDoc, childClassDoc.methods(), alreadyInherited ) ) {
                inheritedMethods.add( supermethodDoc );
            }
        }

        if (inheritedMethods.size() > 0) {
            // Create an entry for the inherited methods from this superclass
            retMe.add( processInheritedMethods( superclassDoc, inheritedMethods ) );

            // Keep track of inheritedMethods so as not to inherit them again from
            // another superclass.
            alreadyInherited.addAll( inheritedMethods );
        }
        
        // Recurse to search parents of this superclass
        retMe.addAll( getAllInheritedMethodsHelper( childClassDoc, superclassDoc, alreadyInherited ) );
    }
    
    return retMe;
}
 
开发者ID:rob4lderman,项目名称:javadoc-json-doclet,代码行数:50,代码来源:JsonDoclet.java

示例10: allowableValues

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * This will retrieve all known allowable values from an enum.
 * @param type
 * @return
 */
public static Collection<String> allowableValues(Type type) {
    if (type == null || type.asClassDoc() == null)
        return emptyList();

    FieldDoc[] fields = type.asClassDoc().enumConstants();
    if (isEmpty(fields))
        return emptyList();

    Collection<String> values = new ArrayList<String>(fields.length);
    for (FieldDoc field : fields)
        values.add(field.name());

    return values;
}
 
开发者ID:calrissian,项目名称:rest-doclet,代码行数:20,代码来源:TypeUtils.java

示例11: typeDescriptorOf

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * Returns the descriptor for the specified type, as appropriate
 * for either a parameter or return type in a method descriptor.
 **/
private static String typeDescriptorOf(Type type) {
    String desc;
    ClassDoc classDoc = type.asClassDoc();
    if (classDoc == null) {
        /*
         * Handle primitive types.
         */
        String name = type.typeName();
        if (name.equals("boolean")) {
            desc = "Z";
        } else if (name.equals("byte")) {
            desc = "B";
        } else if (name.equals("char")) {
            desc = "C";
        } else if (name.equals("short")) {
            desc = "S";
        } else if (name.equals("int")) {
            desc = "I";
        } else if (name.equals("long")) {
            desc = "J";
        } else if (name.equals("float")) {
            desc = "F";
        } else if (name.equals("double")) {
            desc = "D";
        } else if (name.equals("void")) {
            desc = "V";
        } else {
            throw new AssertionError(
                "unrecognized primitive type: " + name);
        }
    } else {
        /*
         * Handle non-array reference types.
         */
        desc = "L" + binaryNameOf(classDoc).replace('.', '/') + ";";
    }

    /*
     * Handle array types.
     */
    int dimensions = type.dimension().length() / 2;
    for (int i = 0; i < dimensions; i++) {
        desc = "[" + desc;
    }

    return desc;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:Util.java

示例12: isVoid

import com.sun.javadoc.Type; //导入方法依赖的package包/类
/**
 * Returns true if the specified type is void.
 **/
static boolean isVoid(Type type) {
    return type.asClassDoc() == null && type.typeName().equals("void");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:Util.java

示例13: getAllInterfaces

import com.sun.javadoc.Type; //导入方法依赖的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

示例14: 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;
}
 
开发者ID:tcolar,项目名称:javaontracks,代码行数:55,代码来源:JOTDocletNavView.java

示例15: 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;
}
 
开发者ID:wolfgangimig,项目名称:byps,代码行数:58,代码来源:BConvert.java


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