Given a package name(s), search the classpath for all classes that extend sundial.job .

<p>A comma(,) or colon(:) can be used to specify multiple packages to scan for Jobs.

@param pkgname
@return
766455
public Set<Class<? extends Job>> getJobClasses(String pkgname) {

    Set<Class<? extends Job>> classes = new HashSet<Class<? extends Job>>();

    String[] packages = pkgname.split("[\\:,]");
    if (packages.length > 1) {
      for (String pkg : packages) {
        classes.addAll(getJobClasses(pkg));
      }
    } else {
      String relPath = pkgname.replace('.', '/').replace("%20", " ");

      // Get a File object for the package
      URL resource = getResource(relPath);
      if (resource == null) {
        throw new RuntimeException("Unexpected problem: No resource for " + relPath);
      }
      String resPath = "";
      try {
        resPath = URLDecoder.decode(resource.getPath(), "UTF-8");
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      }

      logger.info("Package: '" + pkgname + "' becomes Resource: '" + resPath + "'");

      if (resource.toString().startsWith("jar:")) {
        processJarfile(resPath, pkgname, classes);
      } else {
        processDirectory(resPath, pkgname, classes);
      }
    }

    return classes;
  }
256769
public String parsePackageName(PackageElement p) {
        String pkgname = p.isUnnamed() ? "" : getPackageName(p);
        int index = -1;
        for (int j = 0; j < MAX_CONSTANT_VALUE_INDEX_LENGTH; j++) {
            index = pkgname.indexOf(".", index + 1);
        }
        if (index != -1) {
            pkgname = pkgname.substring(0, index);
        }
        return pkgname;
    }
726237
public static String[] findClass(TypeElement clazz, String format){
        String qname = format.replace("${package}", ModelUtil.getPackage(clazz))
                .replace("${class}", clazz.getSimpleName().toString());
        String pakage, clazzName;

        int dot = qname.lastIndexOf('.');
        if(dot==-1){
            pakage = "";
            clazzName = qname;
        }else{
            pakage = qname.substring(0, dot);
            clazzName = qname.substring(dot+1);
            if(pakage.length()==0)
                qname = clazzName;
        }
        return new String[]{ qname, pakage, clazzName };
    }
706293
protected IPackageFragmentRoot[] getRequiredPackageFragmentRoots(IPath[] classpathEntries, final String projectName, MultiStatus status) {
		ArrayList<IPackageFragmentRoot> result= new ArrayList<>();

		IJavaProject[] searchOrder= getProjectSearchOrder(projectName);
		
		for (int i= 0; i < classpathEntries.length; i++) {
			IPath entry= classpathEntries[i];
			IPackageFragmentRoot[] elements= findRootsForClasspath(entry, searchOrder);
			if (elements == null) {
				status.add(new Status(IStatus.WARNING, JavaUI.ID_PLUGIN,
						org.eclipse.jdt.internal.corext.util.Messages.format(
								FatJarPackagerMessages.FatJarPackageWizardPage_error_missingClassFile,
								getPathLabel(entry, false))));
			} else {
				for (int j= 0; j < elements.length; j++) {
					result.add(elements[j]);
				}
			}
		}

		return result.toArray(new IPackageFragmentRoot[result.size()]);
	}
1286983
private boolean hasPrintedPackageIndex(String pkgname) {
        String[] list = printedPackageHeaders.toArray(new String[] {});
        for (int i = 0; i < list.length; i++) {
            if (pkgname.startsWith(list[i])) {
                return true;
            }
        }
        return false;
    }
1246391
@Pure
	public static Collection<Class<?>> getPackageClasses(String packageName) {
		final Collection<Class<?>> classes = new ArrayList<>();

		final String[] entries = System.getProperty("java.class.path") //$NON-NLS-1$
				.split(Pattern.quote(System.getProperty("path.separator"))); //$NON-NLS-1$
		String lentry;

		for (final String path : entries) {
			lentry = path.toLowerCase();
			if (lentry.endsWith(".jar") || lentry.endsWith(".war")) { //$NON-NLS-1$ //$NON-NLS-2$
				getPackageClassesFromJar(classes, path, packageName);
			} else {
				getPackageClassesFromFileSystem(classes, path, packageName);
			}

		}

		return classes;
	}
1282180
public static CmsResourceInfo getJobInfo(String name, String className) {

        return new CmsResourceInfo(name, className, new CmsCssIcon(OpenCmsTheme.ICON_JOB));
    }
612780
public String packageStatement( PackageDescrBuilder pkg ) throws RecognitionException {
        String pkgName = null;

        try {
            helper.start( pkg,
                          PackageDescrBuilder.class,
                          null );

            match( input,
                   DRL5Lexer.ID,
                   DroolsSoftKeywords.PACKAGE,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return pkgName;

            pkgName = qualifiedIdentifier();
            if ( state.failed ) return pkgName;
            if ( state.backtracking == 0 ) {
                helper.setParaphrasesValue( DroolsParaphraseTypes.PACKAGE,
                                            pkgName );
            }

            if ( input.LA( 1 ) == DRL5Lexer.SEMICOLON ) {
                match( input,
                       DRL5Lexer.SEMICOLON,
                       null,
                       null,
                       DroolsEditorType.SYMBOL );
                if ( state.failed ) return pkgName;
            }

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( PackageDescrBuilder.class,
                        pkg );
        }
        return pkgName;
    }
469555
public static List<String> getClasses(String... packageNames) {
		List<String> classes = new ArrayList<>();
		for (String packageName : packageNames) {
			String packagePath = packageName.replace('.', '/');
			URL url = Conf.class.getResource("/" + packagePath);
			if (url == null) {
				return classes;
			}
			if (url.getProtocol().equals("jar")) {
				String path = url.getPath();
				int i = path.lastIndexOf('!');
				if (i >= 0) {
					path = path.substring(0, i);
				}
				try (JarFile jar = new JarFile(new File(new URL(path).toURI()))) {
					Enumeration<JarEntry> e = jar.entries();
					while (e.hasMoreElements()) {
						path = e.nextElement().getName();
						if (path.startsWith(packagePath) && path.endsWith(".class")) {
							classes.add(path.substring(0, path.length() - 6).replace('/', '.'));
						}
					}
				} catch (IOException | URISyntaxException e) {
					throw new RuntimeException(e);
				}
			} else {
				try {
					String root = new File(url.toURI()).getPath();
					root = root.substring(0, root.length() - packagePath.length());
					search(classes, root, packagePath);
				} catch (URISyntaxException e) {
					throw new RuntimeException(e);
				}
			}
		}
		return classes;
	}
896377
protected String[] getPaths (String pkgPath, String key)
    {

        String bundle = _loader.getBundle(pkgPath);
        Preconditions.checkNotNull(bundle,
            "Unable to find the bundle name for a package [package=%s, key=%s]", pkgPath, key);
        String[] names = _loader.getPaths(pkgPath, key);
        Preconditions.checkNotNull(names, "No such sound [package=%s, key=%s]", pkgPath, key);
        String[] paths = new String[names.length];
        for (int ii = 0; ii < paths.length; ii++) {
            paths[ii] = bundle + ":" + names[ii];
        }
        return paths;
    }
102009
public static boolean canGetMapsFingerprint(final PackageManager pm, final String packageName) {
		try {
			final Class<?> cls = Class.forName("com.google.android.maps.KeyHelper");
			final Method gsf = cls.getDeclaredMethod("getSignatureFingerprint", new Class[]{PackageManager.class, String.class});
			gsf.setAccessible(true);
			final Object fingerprint = gsf.invoke(null, new Object[]{pm, packageName});
			return true;
		} catch (final Throwable e) {
		}
		return false;
	}
592683
@Override
    public Class<?> fromComponentNameToClass(final String componentName) { // *important
        if (LdiStringUtil.isEmpty(componentName)) {
            throw new EmptyRuntimeException("componentName");
        }
        final String suffix = fromComponentNameToSuffix(componentName);
        if (suffix == null) {
            return null;
        }
        final String middlePackageName = fromSuffixToPackageName(suffix);
        final String partOfClassName = fromComponentNameToPartOfClassName(componentName);
        final boolean subAppSuffix = isSubAppSuffix(suffix);
        final boolean webAppSufix = isWebAppSuffix(suffix);
        final boolean jobAppSufix = isJobAppSuffix(suffix);
        for (int i = 0; i < rootPackageNames.length; ++i) {
            final String rootPackageName = rootPackageNames[i];
            if (subAppSuffix) { // first search sub application package
                Class<?> clazz = null;
                if (webAppSufix) {
                    clazz = findWebClass(rootPackageName, partOfClassName);
                } else if (jobAppSufix) {
                    clazz = findJobClass(rootPackageName, partOfClassName);
                }
                if (clazz != null) {
                    return clazz;
                }
                clazz = findClass(rootPackageName, middlePackageName, partOfClassName);
                if (clazz != null) {
                    return clazz;
                }
            } else {
                Class<?> clazz = findClass(rootPackageName, middlePackageName, partOfClassName);
                if (clazz != null) {
                    return clazz;
                }
                if (webAppSufix) {
                    clazz = findWebClass(rootPackageName, partOfClassName);
                } else if (jobAppSufix) {
                    clazz = findJobClass(rootPackageName, partOfClassName);
                } else { // e.g. base_login_harborLoginAssist (by "pickup" method)
                    clazz = findWebClass(rootPackageName, partOfClassName); // find as web at first
                    if (clazz == null) {
                        clazz = findJobClass(rootPackageName, partOfClassName); // and job as next
                    }
                }
                if (clazz != null) {
                    return clazz;
                }
            }
        }
        return null;
    }
95038
public String getPkgName(ClassDoc cd) {
        String pkgName = cd.containingPackage().name();
        if (pkgName.length() > 0) {
            pkgName += ".";
            return pkgName;
        }
        return "";
    }
942540
@Override
    public Stream<Class> scan(String annotation, String pkg) {
        if (pkg == null) {
            return Stream.empty();
        }
        List<Class> classes = doScan(annotation, pkg);
        return classes.stream();
    }
1344898
void buildPackagePrefix(final String className) {
        // TODO test
        final int lastPackageSeparator = className.lastIndexOf('/');
        final String packageName = className.substring(0, lastPackageSeparator == -1 ? className.length() : lastPackageSeparator);
        final String[] splitPackage = packageName.split("/");

        if (splitPackage.length >= PROJECT_PACKAGE_HIERARCHIES) {
            projectPackagePrefix = IntStream.range(0, PROJECT_PACKAGE_HIERARCHIES).mapToObj(i -> splitPackage[i]).collect(Collectors.joining("/"));
        } else {
            projectPackagePrefix = packageName;
        }
    }
125554
public static Collection<Class<?>> getClasses(String... packageNames) {
        List<Class<?>> classes = new ArrayList<>();
        for (String packageName : packageNames) {
            final String packagePath = packageName.replace('.', '/');
            final String packagePrefix = packageName + '.';
            List<URL> packageUrls = getResources(packagePath);
            for (URL packageUrl : packageUrls) {
                if (packageUrl.getProtocol().equals("jar")) {
                    log.debug("Scanning jar {} for classes", packageUrl);
                    try {
                        String jar = packageUrl.toString().substring("jar:".length()).split("!")[0];
                        File file = new File(new URI(jar));
                        try (JarInputStream is = new JarInputStream(new FileInputStream(file))) {
                            JarEntry entry = null;
                            while ((entry = is.getNextJarEntry()) != null) {
                                if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
                                    String className = entry.getName().replace(".class", "").replace('/', '.');
                                    if (className.startsWith(packagePrefix)) {
                                        Class<?> aClass = getClass(className);
                                        classes.add(aClass);
                                    }
                                }
                            }
                        }
                    } catch (URISyntaxException | IOException e) {
                        throw new FathomException(e, "Failed to get classes for package '{}'", packageName);
                    }
                } else {
                    log.debug("Scanning filesystem {} for classes", packageUrl);
                    log.debug(packageUrl.getProtocol());
                    try (InputStream is = packageUrl.openStream()) {
                        Preconditions.checkNotNull(is, "Package url %s stream is null!", packageUrl);
                        try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
                            classes.addAll(reader.lines()
                                    .filter(line -> line != null && line.endsWith(".class"))
                                    .map(line -> {
                                        String className = line.replace(".class", "").replace('/', '.');
                                        try {
                                            Class<?> aClass = getClass(packagePrefix + className);
                                            return aClass;
                                        } catch (Exception e) {
                                            log.error("Failed to find {}", line, e);
                                        }
                                        return null;
                                    })
                                    .collect(Collectors.toList()));
                        }
                    } catch (IOException e) {
                        throw new FathomException(e, "Failed to get classes for package '{}'", packageName);
                    }
                }
            }
        }
        return Collections.unmodifiableCollection(classes);
    }
548075
private Set<ClassInfo> findClassByPackage(final String packageName, final String packagePath,
                                              final Class<?> parent, final Class<? extends Annotation> annotation,
                                              final boolean recursive, Set<ClassInfo> classes) throws ClassNotFoundException {

        // Get the directory of this package to create a File
        File dir = new File(packagePath);
        // If not exist or is not a direct return to the directory
        if ((!dir.exists()) || (!dir.isDirectory())) {
            log.warn("The package [{}] not found.", packageName);
        }
        // If present, get all the files under the package include the directory
        File[] dirFiles = accept(dir, recursive);
        // Loop all files
        if (null != dirFiles && dirFiles.length > 0) {
            for (File file : dirFiles) {
                // If it is a directory, continue scanning
                if (file.isDirectory()) {
                    findClassByPackage(packageName + '.' + file.getName(), file.getAbsolutePath(), parent, annotation, recursive, classes);
                } else {
                    // If the java class file is removed later. Class only leave the class name
                    String   className = file.getName().substring(0, file.getName().length() - 6);
                    Class<?> clazz     = Class.forName(packageName + '.' + className);
                    if (null != parent && null != annotation) {
                        if (null != clazz.getSuperclass() && clazz.getSuperclass().equals(parent) &&
                                null != clazz.getAnnotation(annotation)) {
                            classes.add(new ClassInfo(clazz));
                        }
                        continue;
                    }
                    if (null != parent) {
                        if (null != clazz.getSuperclass() && clazz.getSuperclass().equals(parent)) {
                            classes.add(new ClassInfo(clazz));
                        } else {
                            if (null != clazz.getInterfaces() && clazz.getInterfaces().length > 0 && clazz.getInterfaces()[0].equals(parent)) {
                                classes.add(new ClassInfo(clazz));
                            }
                        }
                        continue;
                    }
                    if (null != annotation) {
                        if (null != clazz.getAnnotation(annotation)) {
                            classes.add(new ClassInfo(clazz));
                        }
                        continue;
                    }
                    classes.add(new ClassInfo(clazz));
                }
            }
        }
        return classes;
    }