Java Utililty Methods Class Simple Name Get

List of utility methods to do Class Simple Name Get

Description

The list of methods to do Class Simple Name Get are organized into topic(s).

Method

StringsimpleClassName(Class cl)
simple Class Name
String scn;
int array_level = 0;
while (cl.isArray()) {
    ++array_level;
    cl = cl.getComponentType();
scn = simpleClassName(cl.getName());
if (array_level > 0) {
...
StringsimpleClassName(Class klass)
simple Class Name
String class_name = klass.getName();
if (klass.getPackage() != null) {
    class_name = class_name.substring(klass.getPackage().getName().length() + 1);
return class_name;
StringsimpleClassName(Class clazz)
simple Class Name
Package pkg = clazz.getPackage();
String result;
if (pkg == null)
    result = clazz.getName();
else
    result = clazz.getName().substring(pkg.getName().length() + 1);
return result;
StringsimpleClassName(Class clazz)
Generates a simplified name from a Class .
if (clazz == null) {
    return "null_class";
Package pkg = clazz.getPackage();
if (pkg != null) {
    return clazz.getName().substring(pkg.getName().length() + 1);
} else {
    return clazz.getName();
...
StringsimpleClassName(Class clazz)
simple Class Name
if (clazz == null) {
    throw new NullPointerException("clazz");
String className = clazz.getName();
final int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
if (lastDotIdx > -1) {
    return className.substring(lastDotIdx + 1);
return className;
StringsimpleClassName(Class type)
simple Class Name
String className = type.getName();
int dot = className.lastIndexOf(".");
if (dot >= 0)
    className = className.substring(dot + 1);
dot = className.lastIndexOf("$");
if (dot >= 0)
    className = className.substring(dot + 1);
return className;
...
StringsimpleClassName(final String className)
Returns the simple class name from the fully qualified class name.
assert className != null : "className must not be null";
assert !className.isEmpty() : "className must not be empty";
final int index = className.lastIndexOf('.');
assert index > -1 : "cannot find package in import " + className;
return className.substring(index + 1);
StringsimpleClassName(Object o)
The shortcut to #simpleClassName(Class) simpleClassName(o.getClass()) .
return simpleClassName(o.getClass());
StringsimpleClassName(Object o)
simple Class Name
if (o == null)
    return null;
return (o instanceof Class ? ((Class<?>) o).getName() : o.getClass().getSimpleName());
StringsimpleClassName(Object object)
simple Class Name
if (object == null) {
    return "null_object";
Class clazz = object.getClass();
Package pkg = clazz.getPackage();
if (pkg != null) {
    return clazz.getName().substring(pkg.getName().length() + 1);
} else {
...