Java Code Examples for com.sun.javadoc.Type#typeName()

The following examples show how to use com.sun.javadoc.Type#typeName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From PrivacyStreams with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 2
Source File: Util.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 3
Source File: Util.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 4
Source File: Util.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 5
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 6
Source File: Util.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 7
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 8
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 9
Source File: Util.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example 10
Source File: Util.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 13
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: Util.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 15
Source File: Util.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source File: Util.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 17
Source File: Util.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: Util.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source File: Util.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}