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 File getClassPathFile(Class clazz) {
    File file = getClassFile(clazz);
    for (int i = 0, count = clazz.getName().split("[.]").length; i < count; i++)
        file = file.getParentFile();/*from w w w. j  a v  a2  s . com*/
    if (file.getName().toUpperCase().endsWith(".JAR!")) {
        file = file.getParentFile();
    }
    return file;
}

From source file:au.id.jericho.lib.html.LoggerFactory.java

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

From source file:com.net2plan.gui.utils.NoRunnableCodeFound.java

private static String[] toString(Set<Class<? extends IExternal>> _classes) {
    String[] out = new String[_classes.size()];
    int i = 0;/*from  www.j a va  2  s . c o m*/
    for (Class<? extends IExternal> _class : _classes)
        out[i++] = _class.getName();

    return out;
}

From source file:Main.java

/**
 * Checks if a class is a Java type: Map, Collection,arrays, Number (extensions and primitives), String, Boolean..
 * /*  www .j  av  a2  s  . c  om*/
 * @param clazz
 *          Class<?> to examine
 * @return true if clazz is Java type, false otherwise
 */
public static boolean isJavaType(Class<?> clazz) {
    if (clazz.isPrimitive())
        return true;
    else if (clazz.getName().startsWith("java.lang"))
        return true;
    else if (clazz.getName().startsWith("java.util"))
        return true;
    else if (clazz.isArray())
        return true;
    return false;
}

From source file:Main.java

/**
 * new a fragment instance//from w  ww .j  a  va 2s  .c  om
 * */
@SuppressWarnings("unchecked")
public static <T extends Fragment> T newFragment(@NonNull Context context, @NonNull Class<T> clazz,
        Bundle bundle) {
    return (T) Fragment.instantiate(context, clazz.getName(), bundle);
}

From source file:Util.java

/**
 * Checks if class in member of the package
 * //  w w w  .j a v a2 s .  c  om
 * @param clazz
 *            class to check
 * @param packageName
 *            package
 * @return true if is member
 */
public static boolean isPackageMember(Class<?> clazz, String packageName) {
    return isPackageMember(clazz.getName(), packageName);
}

From source file:ch.algotrader.util.HibernateUtil.java

private static AbstractEntityPersister getEntityPersister(SessionFactory sessionFactory, Class<?> type) {

    String className = StringUtils.removeEnd(type.getName(), "Impl") + "Impl";
    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory;
    return (AbstractEntityPersister) sessionFactoryImpl.getEntityPersister(className);
}

From source file:Main.java

public static long NonSearchingJavaToUnoType(Class<?> cls, boolean errorIfMissing) throws Throwable {
    String clsName = cls.getName();
    Long unoTypePtr = unoTypes.get(clsName);
    if (unoTypePtr == null) {
        if (errorIfMissing) {
            String msg = "NonSearchingJavaToUnoType: Could not find uno type for " + clsName;
            throw new Exception(msg);
        } else {/*from w  w w .j  a va 2s  .c o m*/
            return 0L;
        }
    }
    return (long) unoTypePtr;
}

From source file:Main.java

public static JAXBContext getJAXBContext(Class<?> c) throws JAXBException {
    JAXBContext context = jaxbcontextmap.get(c.getName());
    if (context != null) {
        return context;
    } else {//from   ww  w  .  j a  va2 s  . co  m
        context = JAXBContext.newInstance(c);
        jaxbcontextmap.put(c.getName(), context);
        return context;
    }
}

From source file:Main.java

public static Object getBeanFromXml(String xml, Class xmlBeanClass) throws Exception {
    Method method = (Method) UNMARSHAL_METHOD_MAP.get(xmlBeanClass.getName());

    if (method == null) {
        method = xmlBeanClass.getMethod("unmarshal", new Class[] { Reader.class });
        UNMARSHAL_METHOD_MAP.put(xmlBeanClass.getName(), method);
    }/*from www.  ja v a 2s. c  o m*/
    StringReader stringReader = new StringReader(xml);

    return method.invoke(null, new Object[] { stringReader });

}