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

/**
 * Get just the class name from a fully qualified class
 * /*from  w ww .j  a  va2s  .  co  m*/
 * @param clazz Class
 * @return String name of the class without its package
 */
private static String getClassName(Class<?> clazz) {
    int beginIndex = clazz.getName().lastIndexOf(".") + 1;

    return clazz.getName().substring(beginIndex);
}

From source file:ClassUtil.java

public static String toPackagePath(Class<?> clazz) {
    String result = clazz.getName();
    int index = result.lastIndexOf('.');
    if (index < 1) {
        return "";
    }/* www  . ja  va 2 s.c  om*/
    result = result.substring(0, index);
    result = result.replace('.', '/');
    return result;
}

From source file:Main.java

static public String getClassNameOnly(Class activityCls) {
    return getClassNameOnly(activityCls.getName());
}

From source file:Main.java

public static <T> String getTAG(Class<T> clazz) {
    String className = clazz.getName();
    className = getClassNameFromPackageName(className);
    return className;
}

From source file:Main.java

public static String getPackageName(Class<?> clazz) {
    String className = clazz.getName();
    int lastIndex = className.lastIndexOf(".");
    if (lastIndex != -1) {
        return className.substring(0, lastIndex);
    } else {// ww w .j  a va 2  s .c  o m
        return null;
    }
}

From source file:Main.java

private static boolean shouldSkipClass(final Class<?> clazz) {
    final String clsName = clazz.getName();
    return Object.class.equals(clazz) || clsName.startsWith("java.") || clsName.startsWith("javax.")
            || clsName.startsWith("android.") || clsName.startsWith("com.android.");
}

From source file:Main.java

/**
 *
 *///from w  w w .  ja  v a  2s . com
private static String getMappingFile(Class<?> clazz) {
    return clazz.getName().replace(".", "/") + ".xml";
}

From source file:Main.java

static void appendTitle(Object obj, Class<?> clz, StringBuilder sb) {
    sb.append("{(" + clz.getName() + ") = " + obj + CHANGE_LINE);
}

From source file:Main.java

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

From source file:Main.java

public static String getName(Class clazz) {
    String name = clazz.getName();
    if (name.startsWith("scouter.agent.") == false)
        return name;
    return "Scouter-" + name.substring(name.lastIndexOf('.') + 1);
}