Top Description Constructors Methods
org.codehaus.groovy.vmplugin.v9

public Class ClassFinder

extends Object
Class Inheritance
Imports
groovy.lang.Tuple2, java.io.File, .IOException, java.net.URI, java.nio.file.FileSystem, .FileSystemAlreadyExistsException, .FileSystems, .FileVisitResult, .Files, .Path, .Paths, .SimpleFileVisitor, java.nio.file.attribute.BasicFileAttributes, java.util.Arrays, .Collections, .HashSet, .LinkedHashMap, .Map, .Set, java.util.regex.Pattern

Find classes under the specified package via some classpath entry Usage:

  // find classes under `me.sunlan` package via classpath entry(directory) `D:/_APPS/git_apps/java8-labs/out/production/classes/`
  ClassFinder.find(URI.create("file:/D:/_APPS/git_apps/java8-labs/out/production/classes/"), "me/sunlan")

  // find classes under `groovy.lang` package via classpath entry(jar file) `D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar`
  ClassFinder.find(URI.create("file:/D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar"), "groovy/lang")

  // find classes under `java.lang` package via classpath entry(jrt)
  ClassFinder.find(URI.create("jrt:/modules/java.base/"), "java/lang")

  // find classes under the sub-packages too, e.g. we can get groovy.lang.groovydoc.GroovydocHolder via the following code
  ClassFinder.find(URI.create("file:/D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar"), "groovy/lang", true)
Since
3.0.2

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
public static Map<String, Set<String>>

Returns:

the found classes
find
(URI
the classpath entry
classpathEntryURI
,
String
the package under which we find classes
packageName
)

Returns the found classes

public static Map<String, Set<String>>

Returns:

the found classes
find
(URI
the classpath entry
classpathEntryURI
,
String
the package under which we find classes
packageName
,
boolean
whether to find sub-packages
recursive
)

Returns the found classes

private static Map<String, Set<String>>
find(URI uri, String prefix, String packageName, boolean recursive)

private static Tuple2<FileSystem, Boolean>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ClassFinderback to summary
private ClassFinder()

Method Detail

closeQuietlyback to summary
private static void closeQuietly(FileSystem fs)
findback to summary
public static Map<String, Set<String>> find(URI classpathEntryURI, String packageName)

Returns the found classes

Parameters
classpathEntryURI:URI

the classpath entry

packageName:String

the package under which we find classes

Returns:Map<String, Set<String>>

the found classes

Since
3.0.2
findback to summary
public static Map<String, Set<String>> find(URI classpathEntryURI, String packageName, boolean recursive)

Returns the found classes

Parameters
classpathEntryURI:URI

the classpath entry

packageName:String

the package under which we find classes

recursive:boolean

whether to find sub-packages

Returns:Map<String, Set<String>>

the found classes

Since
3.0.2
findback to summary
private static Map<String, Set<String>> find(URI uri, String prefix, String packageName, boolean recursive)
maybeNewFileSystemback to summary
private static Tuple2<FileSystem, Boolean> maybeNewFileSystem(URI uri) throws IOException