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

The following examples show how to use com.sun.javadoc.Type#toString() . 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: StubSkeletonWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source File: StubSkeletonWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 3
Source File: StubSkeletonWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source File: StubSkeletonWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 5
Source File: StubSkeletonWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 6
Source File: StubSkeletonWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 8
Source File: StubSkeletonWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 9
Source File: StubSkeletonWriter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 10
Source File: StubSkeletonWriter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 11
Source File: StubSkeletonWriter.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 12
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 13
Source File: StubSkeletonWriter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}