Example usage for java.lang Class getName

List of usage examples for java.lang Class getName

Introduction

In this page you can find the example usage for java.lang Class getName.

Prototype

public String getName() 

Source Link

Document

Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String .

Usage

From source file:Main.java

public static void printMethods(Class cl) {
    Method[] methods = cl.getDeclaredMethods();

    for (int i = 0; i < methods.length; i++) {
        Method m = methods[i];/*from   w w  w. j a v a 2s . c o m*/
        Class retType = m.getReturnType();
        System.out.println(retType.getName());

    }
}

From source file:Main.java

public static String getLogTag(Class<?> objClass) {
    return "log." + objClass.getName();
}

From source file:Main.java

public static String shortClassName(Class c) {
    String clss = c.getName();
    int inx = clss.lastIndexOf('.');
    if (inx >= 0)
        clss = clss.substring(inx + 1);/*from  w w w  .jav a 2s  . c o  m*/
    return clss;
}

From source file:Main.java

/**
 * Returns the simple name for the class <tt>c</tt>.
 * /*from   w  w  w  . j  a  v a 2  s .  c  o m*/
 * @param c the class in question
 * @return the simple name for the class <tt>c</tt>
 */
static String simpleName(final Class c) {
    String s = c.getName();
    int ilastDot = s.lastIndexOf(".");
    return ilastDot == -1 ? s : s.substring(ilastDot + 1);
}

From source file:Main.java

public static String getFullClassName(Class<? extends Object> c) {
    return c.getName();
}

From source file:Main.java

private static String fileName(Class<?> c) {
    return c.getName();
}

From source file:SampleComponentReflection.java

static void printComponentType(Object array) {
    Class arrayClass = array.getClass();
    String arrayName = arrayClass.getName();
    Class componentClass = arrayClass.getComponentType();
    String componentName = componentClass.getName();
    System.out.println("Array: " + arrayName + ", Component: " + componentName);
}

From source file:Utils.java

public static String nonPackageQualifiedName(final Class<?> clazz) {

    String name = clazz.getName();
    return name.substring(name.lastIndexOf('.') + 1);
}

From source file:Main.java

@SuppressWarnings("rawtypes")
public static String getObjShortClassName(Object object) {
    Class clazz = object.getClass();
    return clazz.getName().substring(clazz.getName().lastIndexOf(".") + 1);
}

From source file:Main.java

public static Logger getLogger(Class class_) {
    return getLogger(class_.getName());
}