ExtensionUtilpublic class ExtensionUtil extends Object A set of useful methods relating to extensions. |
Constructors Summary |
---|
private ExtensionUtil()Class is not meant to be instantiated.
//all methods static
|
Methods Summary |
---|
private static void | addExtension(java.util.List extensionList, Extension originalExtension, boolean includeImpl, boolean includeURL)Add extension to list.
If extension should not have implementation details but
does strip them. If extension should not have url but does
then strip it.
Extension extension = originalExtension;
if (!includeURL
&& null != extension.getImplementationURL()) {
extension =
new Extension(extension.getExtensionName(),
extension.getSpecificationVersion().toString(),
extension.getSpecificationVendor(),
extension.getImplementationVersion().toString(),
extension.getImplementationVendor(),
extension.getImplementationVendorID(),
null);
}
final boolean hasImplAttributes =
null != extension.getImplementationURL()
|| null != extension.getImplementationVersion()
|| null != extension.getImplementationVendorID()
|| null != extension.getImplementationVendor();
if (!includeImpl && hasImplAttributes) {
extension =
new Extension(extension.getExtensionName(),
extension.getSpecificationVersion().toString(),
extension.getSpecificationVendor(),
null,
null,
null,
extension.getImplementationURL());
}
extensionList.add(extension);
| static void | extractExtensions(org.apache.tools.ant.Project project, java.util.List libraries, java.util.List fileset)Generate a list of extensions from a specified fileset.
if (!fileset.isEmpty()) {
final Extension[] extensions = getExtensions(project,
fileset);
for (int i = 0; i < extensions.length; i++) {
libraries.add(extensions[ i ]);
}
}
| private static Extension[] | getExtensions(org.apache.tools.ant.Project project, java.util.List libraries)Retrieve extensions from the specified libraries.
final ArrayList extensions = new ArrayList();
final Iterator iterator = libraries.iterator();
while (iterator.hasNext()) {
final FileSet fileSet = (FileSet) iterator.next();
boolean includeImpl = true;
boolean includeURL = true;
if (fileSet instanceof LibFileSet) {
LibFileSet libFileSet = (LibFileSet) fileSet;
includeImpl = libFileSet.isIncludeImpl();
includeURL = libFileSet.isIncludeURL();
}
final DirectoryScanner scanner = fileSet.getDirectoryScanner(project);
final File basedir = scanner.getBasedir();
final String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
final File file = new File(basedir, files[ i ]);
loadExtensions(file, extensions, includeImpl, includeURL);
}
}
return (Extension[]) extensions.toArray(new Extension[extensions.size()]);
| static java.util.jar.Manifest | getManifest(java.io.File file)Retrieve manifest for specified file.
try {
final JarFile jarFile = new JarFile(file);
Manifest m = jarFile.getManifest();
if (m == null) {
throw new BuildException(file + " doesn't have a MANIFEST");
}
return m;
} catch (final IOException ioe) {
throw new BuildException(ioe.getMessage(), ioe);
}
| private static void | loadExtensions(java.io.File file, java.util.List extensionList, boolean includeImpl, boolean includeURL)Load list of available extensions from specified file.
try {
final JarFile jarFile = new JarFile(file);
final Extension[] extensions =
Extension.getAvailable(jarFile.getManifest());
for (int i = 0; i < extensions.length; i++) {
final Extension extension = extensions[ i ];
addExtension(extensionList, extension, includeImpl, includeURL);
}
} catch (final Exception e) {
throw new BuildException(e.getMessage(), e);
}
| static java.util.ArrayList | toExtensions(java.util.List adapters)Convert a list of extensionAdapter objects to extensions.
final ArrayList results = new ArrayList();
final int size = adapters.size();
for (int i = 0; i < size; i++) {
final ExtensionAdapter adapter =
(ExtensionAdapter) adapters.get(i);
final Extension extension = adapter.toExtension();
results.add(extension);
}
return results;
|
|