List of usage examples for java.lang Package getName
public String getName()
From source file:Main.java
/** * Another helper method to deal with rest of [JACKSON-103] */// w w w.j ava 2 s . co m protected static boolean isGroovyMetaClassGetter(AnnotatedMethod am) { Class<?> rt = am.getRawType(); if (rt == null || rt.isArray()) { return false; } Package pkg = rt.getPackage(); if (pkg != null && pkg.getName().startsWith("groovy.lang")) { return true; } return false; }
From source file:org.bremersee.common.spring.autoconfigure.JaxbAutoConfiguration.java
public static Jaxb2Marshaller createJaxbMarshaller(final Package... packages) { final List<String> packageList = new ArrayList<>(); if (packages != null) { for (Package p : packages) { if (p != null) { packageList.add(p.getName()); }//from w ww .j ava 2s . c om } } return createJaxbMarshaller(packageList); }
From source file:org.rhq.bindings.util.InterfaceSimplifier.java
private static String getSimplifiedName(Class<?> interfaceClass) { String fullName = interfaceClass.getName(); String simpleName = interfaceClass.getSimpleName(); Package pkg = interfaceClass.getPackage(); String packageName = (pkg != null) ? pkg.getName() : fullName.substring(0, fullName.length() - (simpleName.length() + 1)); return packageName + ".wrapped." + simpleName + "Simple"; }
From source file:com.ineunet.knife.mgt.ActivatorHelper.java
static int getBundleSize() { int size = 0; Package[] pkgs = Package.getPackages(); for (Package pkg : pkgs) { String name = pkg.getName(); if (name.endsWith(".internal")) { if (name.contains(".knife.")) { size++;//from w ww .j ava 2 s .c o m } else if ("com.sun.naming.internal".equals(name)) { continue; } else { try { Class<?> cls = ClassLocator.loadClass(name + ".Activator"); BundleActivator c = cls.getAnnotation(BundleActivator.class); if (c != null) { size++; } } catch (ClassNotFoundException e) { // other package has the same name '*.internal', ignore continue; } } } } return size; }
From source file:Main.java
/** * This method was added to address [JACKSON-53]: need to weed out * CGLib-injected "getCallbacks". /*from w w w. java 2 s .com*/ * At this point caller has detected a potential getter method * with name "getCallbacks" and we need to determine if it is * indeed injectect by Cglib. We do this by verifying that the * result type is "net.sf.cglib.proxy.Callback[]" *<p> * Also, see [JACKSON-177]; Hibernate may repackage cglib * it uses, so we better catch that too */ protected static boolean isCglibGetCallbacks(AnnotatedMethod am) { Class<?> rt = am.getRawType(); // Ok, first: must return an array type if (rt == null || !rt.isArray()) { return false; } /* And that type needs to be "net.sf.cglib.proxy.Callback". * Theoretically could just be a type that implements it, but * for now let's keep things simple, fix if need be. */ Class<?> compType = rt.getComponentType(); // Actually, let's just verify it's a "net.sf.cglib.*" class/interface Package pkg = compType.getPackage(); if (pkg != null) { String pname = pkg.getName(); if (pname.startsWith("net.sf.cglib") // also, as per [JACKSON-177] || pname.startsWith("org.hibernate.repackage.cglib")) { return true; } } return false; }
From source file:org.dcm4chee.xds2.pix.tool.PixQueryCmd.java
private static CommandLine parseComandLine(String[] args) throws ParseException { Options opts = new Options(); opts.addOption("h", "help", false, rb.getString("help")); opts.addOption("V", "version", false, rb.getString("version")); CommandLineParser parser = new PosixParser(); CommandLine cl = parser.parse(opts, args); if (cl.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(rb.getString("usage"), rb.getString("description"), opts, rb.getString("example")); System.exit(0);/*from w w w . j a v a 2 s .c om*/ } if (cl.hasOption("V")) { Package p = PixQueryCmd.class.getPackage(); String s = p.getName(); System.out.println(s.substring(s.lastIndexOf('.') + 1) + ": " + p.getImplementationVersion()); System.exit(0); } return cl; }
From source file:com.netspective.axiom.TestUtils.java
static public DriverManagerConnectionProvider getConnProvider(Package connProviderId) { return getConnProvider(connProviderId.getName()); }
From source file:Main.java
public static String getApplicationPath(Class cls) { if (cls == null) throw new java.lang.IllegalArgumentException("parameter is not null !"); ClassLoader loader = cls.getClassLoader(); String clsName = cls.getName() + ".class"; Package pack = cls.getPackage(); System.out.println("package name is : " + (pack == null)); String path = ""; if (pack != null) { String packName = pack.getName(); if (packName.startsWith("java.") || packName.startsWith("javax.")) throw new java.lang.IllegalArgumentException("This is system class"); clsName = clsName.substring(packName.length() + 1); if (packName.indexOf(".") < 0) path = packName + "/"; else {/*from ww w . jav a 2s . c o m*/ int start = 0, end = 0; end = packName.indexOf("."); while (end != -1) { path = path + packName.substring(start, end) + "/"; start = end + 1; end = packName.indexOf(".", start); } path = path + packName.substring(start) + "/"; } } java.net.URL url = loader.getResource(path + clsName); String realPath = url.getPath(); int pos = realPath.indexOf("file:"); if (pos > -1) realPath = realPath.substring(pos + 5); pos = realPath.indexOf(path + clsName); realPath = realPath.substring(0, pos - 1); if (realPath.endsWith("!")) realPath = realPath.substring(0, realPath.lastIndexOf("/")); try { realPath = java.net.URLDecoder.decode(realPath, "utf-8"); } catch (Exception e) { throw new RuntimeException(e); } return realPath; }
From source file:cc.aileron.commons.util.ClassPattrnFinderUtils.java
/** * ??????//from w w w. java 2s. c om * * @param targetPackage * @return ?? * @throws ResourceNotFoundException * @throws URISyntaxException * @throws IOException */ public static final List<Class<?>> getClassNameList(final Package targetPackage) throws IOException, URISyntaxException, ResourceNotFoundException { return tryGetClassNameList(targetPackage.getName(), null); }
From source file:mitm.application.djigzo.DjigzoConfigurator.java
private static void logAllPackages() { List<Package> packages = Arrays.asList(Package.getPackages()); Comparator<Package> packageComparator = new Comparator<Package>() { @Override/*from w w w .j a va 2 s . c o m*/ public int compare(Package package1, Package package2) { return package1.getName().compareTo(package2.getName()); } }; Collections.sort(packages, packageComparator); StrBuilder sb = new StrBuilder(1024); sb.appendNewLine(); for (Package pack : packages) { sb.append("Package: ").append(pack.getName()).appendSeparator("; "); sb.append("Title: ").append(pack.getImplementationTitle()).appendSeparator("; "); sb.append("Version: ").append(pack.getImplementationVersion()); sb.appendNewLine(); } logger.info(sb.toString()); }