Java Utililty Methods Class Load

List of utility methods to do Class Load

Description

The list of methods to do Class Load are organized into topic(s).

Method

TfromString(final Class clazz, final String value)
Convert the given String to the given class.
if (value == null) {
    return null;
} else if (clazz.equals(String.class)) {
    return (T) value;
} else if (clazz.equals(Integer.class)) {
    return (T) Integer.valueOf(value);
} else if (clazz.equals(Double.class)) {
    return (T) Double.valueOf(value);
...
TfromString(String string, Class arrayClass)
from String
String stringArray = string.replaceAll("[\\[\\]]", "");
String[] tokens = stringArray.split(",");
int length = tokens.length;
if (boolean[].class.equals(arrayClass)) {
    boolean[] array = new boolean[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = Boolean.valueOf(tokens[i]);
    return (T) array;
} else if (byte[].class.equals(arrayClass)) {
    byte[] array = new byte[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = Byte.valueOf(tokens[i]);
    return (T) array;
} else if (short[].class.equals(arrayClass)) {
    short[] array = new short[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = Short.valueOf(tokens[i]);
    return (T) array;
} else if (int[].class.equals(arrayClass)) {
    int[] array = new int[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = Integer.valueOf(tokens[i]);
    return (T) array;
} else if (long[].class.equals(arrayClass)) {
    long[] array = new long[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = Long.valueOf(tokens[i]);
    return (T) array;
} else if (float[].class.equals(arrayClass)) {
    float[] array = new float[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = Float.valueOf(tokens[i]);
    return (T) array;
} else if (double[].class.equals(arrayClass)) {
    double[] array = new double[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = Double.valueOf(tokens[i]);
    return (T) array;
} else if (char[].class.equals(arrayClass)) {
    char[] array = new char[length];
    for (int i = 0; i < tokens.length; i++) {
        array[i] = tokens[i].length() > 0 ? tokens[i].charAt(0) : Character.MIN_VALUE;
    return (T) array;
} else {
    return (T) tokens;
StringgetClass(Class clazz)
get Class
return commonInterfaceMap.get(clazz);
ClassgetClass(String className)
get Class
if (builtinDataTypeMap.containsKey(className)) {
    return builtinDataTypeMap.get(className);
} else {
    return Class.forName(className);
ClassgetClass(String className)
get Class
Class clazz;
if (isPrimitiveClass(className)) {
    return primitiveStringToClass.get(className);
} else {
    clazz = Class.forName(className);
return clazz;
ClassgetClass(String className)
This method returns the class matching the name className.
Class<?> c;
if ((c = primitiveMap.get(className)) != null)
    return c;
return Class.forName(className);
ClassgetClass(String fullClassName)
Get the Class reference by the given fullClassName.
Class<?> clazz = null;
synchronized (_CLASS_MAPPING) {
    if ((clazz = _CLASS_MAPPING.get(fullClassName)) == null) {
        try {
            clazz = Class.forName(fullClassName);
            _CLASS_MAPPING.put(fullClassName, clazz);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
...
ClassgetClass(String name)
get Class
return (Class) class_string_mapping.get(name.toLowerCase());
ClassgetClass(String name)
Returns a Java class object for the specified class name.
for (String clazz : classes.keySet()) {
    if (clazz.toLowerCase().contains(name.toLowerCase())) {
        return classes.get(clazz);
throw new Exception("Class " + name
        + " not found, try including the package name, for instance: net.minecraft.server._version_."
        + name);
...
ClassgetClass(String upnpDataType)
get Class
return (Class) dataTypeMap.get(upnpDataType);