List of usage examples for java.lang Class getPackage
public Package getPackage()
From source file:org.bonitasoft.web.designer.utils.rule.TestResource.java
public TestResource(Class<?> aClass) { this.packageName = aClass.getPackage().getName(); }
From source file:org.objenesis.tck.OsgiTest.java
protected String getImplementationVersion(final Class c) { return c.getPackage().getImplementationVersion(); }
From source file:IntrospectionUtil.java
public static Method findMethod(Class clazz, String methodName, Class[] args, boolean checkInheritance, boolean strictArgs) throws NoSuchMethodException { if (clazz == null) throw new NoSuchMethodException("No class"); if (methodName == null || methodName.trim().equals("")) throw new NoSuchMethodException("No method name"); Method method = null;//from ww w. ja va 2 s . co m Method[] methods = clazz.getDeclaredMethods(); for (int i = 0; i < methods.length && method == null; i++) { if (methods[i].getName().equals(methodName) && checkParams(methods[i].getParameterTypes(), (args == null ? new Class[] {} : args), strictArgs)) { method = methods[i]; } } if (method != null) { return method; } else if (checkInheritance) return findInheritedMethod(clazz.getPackage(), clazz.getSuperclass(), methodName, args, strictArgs); else throw new NoSuchMethodException("No such method " + methodName + " on class " + clazz.getName()); }
From source file:org.entermedia.websocket.AnnotationServerConfig.java
@Override public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned) { // Deploy all WebSocket endpoints defined by annotations in the examples // web application. Filter out all others to avoid issues when running // tests on Gump log.info("loading classes " + scanned.size()); Set<Class<?>> results = new HashSet<Class<?>>(); for (Class<?> clazz : scanned) { if (clazz.getPackage().getName().startsWith("org.entermedia.websocket.")) { results.add(clazz);// w ww. ja v a2 s .c o m log.info("configured " + clazz.getPackage().getName()); } } return results; }
From source file:org.castor.jaxb.reflection.PackageAnnotationProcessingServiceTest.java
/** * Test method for {@link org.castor.jaxb.annoproc.BaseAnnotationProcessingService#processAnnotations(org.castor.jaxb.reflection.info.Info, * java.lang.annotation.Annotation[])}.//from www .j av a 2 s.c o m */ @Test public final void testProcessAnnotations() { Class<USAddress> clazz = USAddress.class; Package pack = clazz.getPackage(); Annotation[] annotations = pack.getAnnotations(); JaxbPackageNature packageInfo = new JaxbPackageNature(new PackageInfo(pack.getName())); paps.processAnnotations(packageInfo, annotations); Assert.assertEquals(XmlAccessType.PROPERTY, packageInfo.getAccessType()); }
From source file:com.astamuse.asta4d.web.initialization.SimplePropertyFileInitializer.java
@SuppressWarnings("rawtypes") protected boolean expectInstance(Class clz) { Package pkg = clz.getPackage(); if (pkg == null) { return false; } else {//w ww . ja va 2 s . c o m return pkg.getName().startsWith("com.astamuse.asta4d."); } }
From source file:org.easymock.itests.OsgiBaseTest.java
protected String getImplementationVersion(Class<?> c) { return c.getPackage().getImplementationVersion(); }
From source file:org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl.java
private String getPackageName(Class<?> clazz) { return clazz.getPackage().getName(); }
From source file:org.apache.axis2.jaxws.runtime.description.marshal.impl.PackageSetBuilder.java
/** * Add all of the packages/names in classSet to our package set collection * @param classSet/* ww w .j a va 2 s .com*/ * @param set */ private static void addClassesToPackageSet(Set<Class> classSet, TreeSet<String> set) { if (log.isDebugEnabled()) { log.debug("enter addClassesToPackageSet"); } if (classSet != null) { for (Class clz : classSet) { if (clz != null && clz != Holder.class && clz != Future.class && clz != Response.class) { Package pkg = clz.getPackage(); //For primitive types there is no package String pkgText = (pkg != null) ? pkg.getName() : null; if (pkg != null) { String name = clz.getCanonicalName(); if (log.isDebugEnabled()) { log.debug(" adding class " + name); } set.add("@" + pkgText); // Indicates a package from an actual class reference set.add("[" + name + "]"); // Indicates a actual class referenced } } } } if (log.isDebugEnabled()) { log.debug("exit addClassesToPackageSet"); } }
From source file:org.blocks4j.reconf.infra.i18n.BundleSettings.java
public BundleSettings(Class<?> cls) { className = cls.getSimpleName();/*from w w w. j a v a2 s . c om*/ String[] packages = StringUtils.split(cls.getPackage().getName(), '.'); if (packages.length == 0 || packages.length == 1) { throw new IllegalArgumentException("only meant to be used inside reconf"); } headPackageName = packages[3]; if (packages.length >= 2) { tailPackageName = StringUtils.substringAfter(cls.getPackage().getName(), "reconf." + headPackageName + "."); } else { tailPackageName = StringUtils.EMPTY; } }