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

@SuppressWarnings("unchecked")
public static Class resolvePrimitiveClassName(String name) {
    if (name.length() <= 8) {
        for (int i = 0; i < PRIMITIVE_CLASSES.length; i++) {
            Class clazz = PRIMITIVE_CLASSES[i];
            if (clazz.getName().equals(name))
                return clazz;
        }/*from  w  ww.  j ava 2 s  . c o m*/
    }
    return null;
}

From source file:Main.java

/**
 * Convenience method to obtain the Swing class from which this
 * component was directly or indirectly derived.
 *
 * @param component The component whose Swing superclass is to be
 * determined//from   ww  w .j  a va 2  s.com
 * @return The nearest Swing class in the inheritance tree
 */
public static <T extends JComponent> Class getJClass(T component) {
    Class<?> clazz = component.getClass();
    while (!clazz.getName().matches("javax.swing.J[^.]*$")) {
        clazz = clazz.getSuperclass();
    }
    return clazz;
}

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining
 * to a particular class./*from  ww  w .ja v  a2s . co m*/
 *
 * @param clazz the class of interest
 * @return the UIDefaults of the class
 */
public static UIDefaults getUIDefaultsOfClass(Class clazz) {
    String name = clazz.getName();
    name = name.substring(name.lastIndexOf(".") + 2);
    return getUIDefaultsOfClass(name);
}

From source file:Main.java

public static File getClassFile(Class clazz) {
    URL path = clazz.getResource(clazz.getName().substring(clazz.getName().lastIndexOf("") + 1) + ".classs");
    if (path == null) {
        String name = clazz.getName().replaceAll("[.]", "/");
        path = clazz.getResource("/" + name + ".class");
    }/*from   w w  w.j  av a 2 s.  c o m*/
    return new File(path.getFile());
}

From source file:Main.java

public static String getPackageName(Class<?> c) {
    String fullyQualifiedName = c.getName();
    return getPackageName(fullyQualifiedName);
}

From source file:Main.java

public static String makeIntentActionName(Class<?> cls, String actionName) {
    return String.format("%s.action.%s", cls.getName(), actionName.toUpperCase());
}

From source file:Main.java

public static void stopService(Context context, Class clazz) {
    if (isServiceRunning(context, clazz.getName())) {
        context.stopService(new Intent(context, clazz));
    }//from  w w  w  .  ja v a 2 s  . com
}

From source file:Main.java

public static boolean isDbPrimitiveType(Class<?> fieldType) {
    return DB_PRIMITIVE_TYPES.contains(fieldType.getName());
}

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining to a particular class.
 * //  w w  w  .  j a va 2s.co  m
 * @param clazz
 *            the class of interest
 * @return the UIDefaults of the class
 */
public static UIDefaults getUIDefaultsOfClass(Class<?> clazz) {
    String name = clazz.getName();
    name = name.substring(name.lastIndexOf(".") + 2); //$NON-NLS-1$
    return getUIDefaultsOfClass(name);
}

From source file:Main.java

/**
 * Please do not use - internal//from   www  .  j  a v a2s  . c o  m
 * org.my.Class -> org/my/Class.class
 */
public static String convertClassToResourcePath(final Class cls) {
    return convertClassToResourcePath(cls.getName());
}