Here you can find the source of resolvePrimitiveClassName(String name)
Parameter | Description |
---|---|
name | the name of the potentially primitive class |
null
if the name does not denote a primitive class or primitive array class
public static Class resolvePrimitiveClassName(String name)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; public class Main { private static final Map primitiveTypeNameMap = new HashMap(16); /**// w w w . ja v a 2s.c o m * Resolve the given class name as primitive class, if appropriate, * according to the JVM's naming rules for primitive classes. * <p> * Also supports the JVM's internal class names for primitive arrays. Does * <i>not</i> support the "[]" suffix notation for primitive arrays; this is * only supported by {@link #forName}. * @param name * the name of the potentially primitive class * @return the primitive class, or <code>null</code> if the name does not * denote a primitive class or primitive array class */ public static Class resolvePrimitiveClassName(String name) { Class result = null; // Most class names will be quite long, considering that they // SHOULD sit in a package, so a length check is worthwhile. if (name != null && name.length() <= 8) { // Could be a primitive - likely. result = (Class) primitiveTypeNameMap.get(name); } return result; } }