Example usage for java.lang Class getPackage

List of usage examples for java.lang Class getPackage

Introduction

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

Prototype

public Package getPackage() 

Source Link

Document

Gets the package of this class.

Usage

From source file:org.alfresco.module.org_alfresco_module_rm.api.PublicAPITestUtil.java

/**
 * Check if a class is within org.alfresco, and so whether it could potentially be part of the public API.
 *
 * @param type The class to check./*from  w  ww . j  a v  a 2  s.  co  m*/
 * @return {@code true} if this is an Alfresco class.
 */
private static boolean isInAlfresco(Class<?> type) {
    if (type.getPackage() == null) {
        return false;
    }
    return type.getPackage().getName().startsWith(ALFRESCO_PACKAGE);
}

From source file:edu.uw.apl.nativelibloader.NativeLoader.java

/**
 * A convenience helper for the primary entry point, where the
 * group name is derived from a class's own package name
 *//*from  w  w w .  j  a va2  s.  co  m*/
static public synchronized void load(Class c, String libName) throws IOException {
    String package_ = c.getPackage().getName();
    load(package_, libName);
}

From source file:org.dasein.cloud.digitalocean.DigitalOcean.java

static public @Nonnull Logger getWireLogger(@Nonnull Class<?> cls) {
    return Logger.getLogger("dasein.cloud.digitalocean.wire." + getLastItem(cls.getPackage().getName()) + "."
            + getLastItem(cls.getName()));
}

From source file:com.dosport.system.utils.ReflectionUtils.java

/**
 * ??/*from   w  ww.  ja v  a  2  s  . co  m*/
 * 
 * @param cls
 * @return
 * @throws IOException
 * @throws ClassNotFoundException
 */
public static List<Class<?>> getClasses(Class<?> cls) throws IOException, ClassNotFoundException {
    String pk = cls.getPackage().getName();
    String path = pk.replace('.', '/');
    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    URL url = classloader.getResource(path);
    return getClasses(new File(url.getFile()), pk);
}

From source file:org.ensembl.healthcheck.util.InputOutputUtils.java

public static String getResourceAsStreamCompatibleName(Class<?> clazz, String resourceName) {
    String output = "/" + clazz.getPackage().getName();
    output = output.replaceAll("\\.", "/");
    return output + "/" + resourceName;
}

From source file:org.assertj.assertions.generator.AssertionGeneratorTest.java

private static File fileGeneratedFor(Class<?> clazz) {
    String dirName = TARGET_DIRECTORY + File.separatorChar
            + clazz.getPackage().getName().replace('.', File.separatorChar);
    String generatedFileName = getSimpleNameWithOuterClassNotSeparatedByDots(clazz) + ASSERT_CLASS_FILE_SUFFIX;
    return new File(dirName, generatedFileName);
}

From source file:org.assertj.assertions.generator.AssertionGeneratorTest.java

private static File abstractFileGeneratedFor(Class<?> clazz) {
    String dirName = TARGET_DIRECTORY + File.separatorChar
            + clazz.getPackage().getName().replace('.', File.separatorChar);
    String generatedFileName = ABSTRACT_ASSERT_CLASS_PREFIX
            + getSimpleNameWithOuterClassNotSeparatedByDots(clazz) + ASSERT_CLASS_FILE_SUFFIX;
    return new File(dirName, generatedFileName);
}

From source file:org.apdplat.platform.util.ReflectionUtils.java

/**
 * ???/*from  w  w  w . j av  a  2 s.c o m*/
 */
public static List<Class<?>> getClasses(Class<?> cls) throws ClassNotFoundException {
    String pk = cls.getPackage().getName();
    String path = pk.replace('.', '/');
    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    URL url = classloader.getResource(path);
    return getClasses(new File(url.getFile()), pk, null);
}

From source file:org.dasein.cloud.google.Google.java

static public @Nonnull Logger getLogger(@Nonnull Class<?> cls) {
    String pkg = getLastItem(cls.getPackage().getName());

    if (pkg.equals("google")) {
        pkg = "";
    } else {//from  ww  w .ja  va2 s .  c om
        pkg = pkg + ".";
    }
    return Logger.getLogger("dasein.cloud.google.std." + pkg + getLastItem(cls.getName()));
}

From source file:org.bremersee.pagebuilder.PageBuilderUtils.java

private static JAXBContext getJaxbContext(final Class<?> valueType) throws JAXBException {
    JAXBContext jaxbContext = JAXB_CONTEXTS.get(valueType.getPackage());
    if (jaxbContext == null) {
        jaxbContext = JAXB_CONTEXTS.get(valueType);
    }//from   ww w  . j  a  va2s. c om
    if (jaxbContext == null) {
        try {
            jaxbContext = JAXBContext.newInstance(valueType.getPackage().getName());
        } catch (JAXBException e) { // NOSONAR
            jaxbContext = JAXBContext.newInstance(valueType);
            JAXB_CONTEXTS.put(valueType, jaxbContext);
        }
    }
    return jaxbContext;
}