Example usage for java.lang Class getSimpleName

List of usage examples for java.lang Class getSimpleName

Introduction

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

Prototype

public String getSimpleName() 

Source Link

Document

Returns the simple name of the underlying class as given in the source code.

Usage

From source file:Main.java

/**
 * WARNING: Don't use this when obfuscating class names with Proguard!
 *//*w w  w . j a  va2s. com*/
public static String makeLogTag(Class cls) {
    return makeLogTag(cls.getSimpleName());
}

From source file:de.webtech2.croaking.services.impl.Invoker.java

public static String invoke(Class<?> clazz) {
    return clazz.getSimpleName() + "." + SUCCESS_SUFFIX;
}

From source file:Main.java

public static void convertActivityToTranslucent(Activity activity) {
    try {//from  w  ww  .j  av a  2  s.  co m
        Class<?>[] classes = Activity.class.getDeclaredClasses();
        Class<?> translucentConversionListenerClazz = null;
        for (Class clazz : classes) {
            if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
                translucentConversionListenerClazz = clazz;
            }
        }
        Method method = Activity.class.getDeclaredMethod("convertToTranslucent",
                translucentConversionListenerClazz);
        method.setAccessible(true);
        method.invoke(activity, new Object[] { null });
    } catch (Throwable t) {
    }
}

From source file:Main.java

public static String makeIntentExtraName(Class<?> cls, String extraName) {
    return String.format("%s.EXTRA_%s", cls.getSimpleName(), extraName.toUpperCase());
}

From source file:Main.java

/**
 * Build an Engagement alias for an Android Activity class. This implementation takes the simple
 * name of the class and removes the "Activity" suffix if any (e.g. "com.mycompany.MainActivity"
 * becomes "Main").<br/>//from  ww w. ja  v a 2s  .  co m
 * This method is used by {@link EngagementActivity} and its variants.
 * @return an activity name suitable to be reported by the Engagement service.
 */
public static String buildEngagementActivityName(Class<?> activityClass) {
    String name = activityClass.getSimpleName();
    String suffix = "Activity";
    if (name.endsWith(suffix) && name.length() > suffix.length())
        return name.substring(0, name.length() - suffix.length());
    else
        return name;
}

From source file:Main.java

/**
 * Calling the convertToTranslucent method on platforms before Android 5.0
 *//*ww w .  j a  v a  2  s.c o m*/
public static void convertActivityToTranslucentBeforeL(Activity activity) {
    try {
        Class<?>[] classes = Activity.class.getDeclaredClasses();
        Class<?> translucentConversionListenerClazz = null;
        for (Class clazz : classes) {
            if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
                translucentConversionListenerClazz = clazz;
            }
        }
        Method method = Activity.class.getDeclaredMethod("convertToTranslucent",
                translucentConversionListenerClazz);
        method.setAccessible(true);
        method.invoke(activity, new Object[] { null });
    } catch (Throwable t) {
    }
}

From source file:Main.java

/**
 * Build an Capptain alias for an Android Activity class. This implementation takes the simple
 * name of the class and removes the "Activity" suffix if any (e.g. "com.mycompany.MainActivity"
 * becomes "Main").<br/>//from  ww  w.  j a v  a  2  s .co m
 * This method is used by {@link CapptainActivity} and its variants.
 * @return an activity name suitable to be reported by the Capptain service.
 */
public static String buildCapptainActivityName(Class<?> activityClass) {
    String name = activityClass.getSimpleName();
    String suffix = "Activity";
    if (name.endsWith(suffix) && name.length() > suffix.length())
        return name.substring(0, name.length() - suffix.length());
    else
        return name;
}

From source file:MySuperClass.java

public static ArrayList<String> getFieldsDesciption(Field[] fields) {
    ArrayList<String> fieldList = new ArrayList<>();

    for (Field f : fields) {
        int mod = f.getModifiers() & Modifier.fieldModifiers();
        String modifiers = Modifier.toString(mod);

        Class<?> type = f.getType();
        String typeName = type.getSimpleName();

        String fieldName = f.getName();

        fieldList.add(modifiers + "  " + typeName + "  " + fieldName);
    }//  www  .  ja  va2s  .com

    return fieldList;
}

From source file:Main.java

/**
 * Calling the convertToTranslucent method on platforms before Android 5.0
 *//*from w w  w.jav  a2  s  .c o m*/
public static void convertActivityToTranslucentBeforeL(Activity activity) {
    try {
        Class<?>[] classes = Activity.class.getDeclaredClasses();
        Class<?> translucentConversionListenerClazz = null;
        for (Class<?> clazz : classes) {
            if (clazz.getSimpleName().contains("TranslucentConversionListener")) {
                translucentConversionListenerClazz = clazz;
            }
        }
        Method method = Activity.class.getDeclaredMethod("convertToTranslucent",
                translucentConversionListenerClazz);
        method.setAccessible(true);
        method.invoke(activity, new Object[] { null });
    } catch (Throwable t) {
    }
}

From source file:Main.java

public static void i(Class<?> clazz, String message) {
    String tag = clazz.getSimpleName();
    i(tag, message);
}