Package host.anzo.commons.versioning
Class Locator
java.lang.Object
host.anzo.commons.versioning.Locator
The Locator is a utility class which is used to find certain items in the
environment.
- Since:
- Ant 1.6
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringConstructs a file path from afile:URI.static FilegetClassSource(@NotNull Class<?> c) Find the directory or jar file the class has been loaded from.static URL @NotNull []getLocationURLs(@NotNull File location, String[] extensions) Get an array of URLs representing all of the files of a given set of extensions in the given location.static URL @NotNull []getLocationURLs(File location) Get an array of URLs representing all of the jar files in the given location.static @Nullable FilegetResourceSource(ClassLoader c, String resource) Find the directory or jar a given resource has been loaded from.static @Nullable FileGet the File necessary to load the Sun compiler tools.
-
Method Details
-
getClassSource
Find the directory or jar file the class has been loaded from.- Parameters:
c- the class whose location is required.- Returns:
- the file or jar with the class or null if we cannot determine the location.
- Since:
- Ant 1.6
-
getResourceSource
Find the directory or jar a given resource has been loaded from.- Parameters:
c- the classloader to be consulted for the source.resource- the resource whose location is required.- Returns:
- the file with the resource source or null if we cannot determine the location.
- Since:
- Ant 1.6
-
fromURI
Constructs a file path from afile:URI.Will be an absolute path if the given URI is absolute.
Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.
- Parameters:
uri- the URI designating a file in the local filesystem.- Returns:
- the local file system path for the file.
- Since:
- Ant 1.6
-
getToolsJar
Get the File necessary to load the Sun compiler tools. If the classes are available to this class, then no additional URL is required and null is returned. This may be because the classes are explicitly in the class path or provided by the JVM directly.- Returns:
- the tools jar as a File if required, null otherwise.
-
getLocationURLs
Get an array of URLs representing all of the jar files in the given location. If the location is a file, it is returned as the only element of the array. If the location is a directory, it is scanned for jar files.- Parameters:
location- the location to scan for Jars.- Returns:
- an array of URLs for all jars in the given location.
- Throws:
MalformedURLException- if the URLs for the jars cannot be formed.
-
getLocationURLs
public static URL @NotNull [] getLocationURLs(@NotNull @NotNull File location, String[] extensions) throws MalformedURLException Get an array of URLs representing all of the files of a given set of extensions in the given location. If the location is a file, it is returned as the only element of the array. If the location is a directory, it is scanned for matching files.- Parameters:
location- the location to scan for files.extensions- an array of extension that are to match in the directory search.- Returns:
- an array of URLs of matching files.
- Throws:
MalformedURLException- if the URLs for the files cannot be formed.
-