FileDocCategorySizeDatePackage
JarLibDisplayTask.javaAPI DocApache Ant 1.704308Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.extension

JarLibDisplayTask

public class JarLibDisplayTask extends org.apache.tools.ant.Task
Displays the "Optional Package" and "Package Specification" information contained within the specified JARs.

Prior to JDK1.3, an "Optional Package" was known as an Extension. The specification for this mechanism is available in the JDK1.3 documentation in the directory $JDK_HOME/docs/guide/extensions/versioning.html. Alternatively it is available online at http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html.

ant.task
name="jarlib-display"

Fields Summary
private File
libraryFile
The library to display information about.
private final Vector
libraryFileSets
Filesets specifying all the librarys to display information about.
Constructors Summary
Methods Summary
public voidaddFileset(org.apache.tools.ant.types.FileSet fileSet)
Adds a set of files about which library data will be displayed.

param
fileSet a set of files about which library data will be displayed.

        libraryFileSets.addElement(fileSet);
    
public voidexecute()
Execute the task.

throws
BuildException if the task fails.

        validate();

        final LibraryDisplayer displayer = new LibraryDisplayer();
        // Check if list of files to check has been specified
        if (!libraryFileSets.isEmpty()) {
            final Iterator iterator = libraryFileSets.iterator();
            while (iterator.hasNext()) {
                final FileSet fileSet = (FileSet) iterator.next();
                final DirectoryScanner scanner
                    = fileSet.getDirectoryScanner(getProject());
                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 ]);
                    displayer.displayLibrary(file);
                }
            }
        } else {
            displayer.displayLibrary(libraryFile);
        }
    
public voidsetFile(java.io.File file)
The JAR library to display information for.

param
file The jar library to display information for.


                         
         
        this.libraryFile = file;
    
private voidvalidate()
Validate the tasks parameters.

throws
BuildException if invalid parameters found

        if (null == libraryFile && libraryFileSets.isEmpty()) {
            final String message = "File attribute not specified.";
            throw new BuildException(message);
        }
        if (null != libraryFile && !libraryFile.exists()) {
            final String message = "File '" + libraryFile + "' does not exist.";
            throw new BuildException(message);
        }
        if (null != libraryFile && !libraryFile.isFile()) {
            final String message = "\'" + libraryFile + "\' is not a file.";
            throw new BuildException(message);
        }