Browse Source

javadoc

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277925 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
fbb0b6d2d7
5 changed files with 179 additions and 41 deletions
  1. +58
    -5
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  2. +74
    -8
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  3. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/Jikes.java
  4. +9
    -2
      src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java
  5. +34
    -23
      src/main/org/apache/tools/ant/taskdefs/KeySubst.java

+ 58
- 5
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -151,6 +151,8 @@ public class Jar extends Zip {
} }


/** /**
* Not used for jar files.
* @param we not used
* @ant.attribute ignore="true" * @ant.attribute ignore="true"
*/ */
public void setWhenempty(WhenEmpty we) { public void setWhenempty(WhenEmpty we) {
@@ -159,6 +161,8 @@ public class Jar extends Zip {
} }


/** /**
* Set the destination file.
* @param jarFile the destination file
* @deprecated Use setDestFile(File) instead * @deprecated Use setDestFile(File) instead
*/ */
public void setJarfile(File jarFile) { public void setJarfile(File jarFile) {
@@ -168,14 +172,16 @@ public class Jar extends Zip {
/** /**
* Set whether or not to create an index list for classes. * Set whether or not to create an index list for classes.
* This may speed up classloading in some cases. * This may speed up classloading in some cases.
* @param flag a <code>boolean</code> value
*/ */
public void setIndex(boolean flag) { public void setIndex(boolean flag) {
index = flag; index = flag;
} }


/** /**
* Set whether or not to create an index list for classes.
* This may speed up classloading in some cases.
* The character encoding to use in the manifest file.
*
* @param manifestEncoding the character encoding
*/ */
public void setManifestEncoding(String manifestEncoding) { public void setManifestEncoding(String manifestEncoding) {
this.manifestEncoding = manifestEncoding; this.manifestEncoding = manifestEncoding;
@@ -185,8 +191,8 @@ public class Jar extends Zip {
* Allows the manifest for the archive file to be provided inline * Allows the manifest for the archive file to be provided inline
* in the build file rather than in an external file. * in the build file rather than in an external file.
* *
* @param newManifest
* @throws ManifestException
* @param newManifest an embedded manifest element
* @throws ManifestException on error
*/ */
public void addConfiguredManifest(Manifest newManifest) public void addConfiguredManifest(Manifest newManifest)
throws ManifestException { throws ManifestException {
@@ -331,6 +337,8 @@ public class Jar extends Zip {
} }


/** /**
* Add a path to index jars.
* @param p a path
* @since Ant 1.6.2 * @since Ant 1.6.2
*/ */
public void addConfiguredIndexJars(Path p) { public void addConfiguredIndexJars(Path p) {
@@ -340,6 +348,12 @@ public class Jar extends Zip {
indexJars.append(p); indexJars.append(p);
} }


/**
* Initialize the zip output stream.
* @param zOut the zip output stream
* @throws IOException on I/O errors
* @throws BuildException on other errors
*/
protected void initZipOutputStream(ZipOutputStream zOut) protected void initZipOutputStream(ZipOutputStream zOut)
throws IOException, BuildException { throws IOException, BuildException {


@@ -410,6 +424,13 @@ public class Jar extends Zip {
super.initZipOutputStream(zOut); super.initZipOutputStream(zOut);
} }


/**
* Finalize the zip output stream.
* This creates an index list if the index attribute is true.
* @param zOut the zip output stream
* @throws IOException on I/O errors
* @throws BuildException on other errors
*/
protected void finalizeZipOutputStream(ZipOutputStream zOut) protected void finalizeZipOutputStream(ZipOutputStream zOut)
throws IOException, BuildException { throws IOException, BuildException {


@@ -484,6 +505,14 @@ public class Jar extends Zip {


/** /**
* Overridden from Zip class to deal with manifests and index lists. * Overridden from Zip class to deal with manifests and index lists.
* @param is the input stream
* @param zOut the zip output stream
* @param vPath the name this entry shall have in the archive
* @param lastModified last modification time for the entry.
* @param fromArchive the original archive we are copying this
* entry from, will be null if we are not copying from an archive.
* @param mode the Unix permissions to set.
* @throws IOException on error
*/ */
protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath,
long lastModified, File fromArchive, int mode) long lastModified, File fromArchive, int mode)
@@ -637,6 +666,12 @@ public class Jar extends Zip {
return super.getResourcesToAdd(filesets, zipFile, needsUpdate); return super.getResourcesToAdd(filesets, zipFile, needsUpdate);
} }


/**
* Create an empty jar file.
* @param zipFile the file to create
* @return true for historic reasons
* @throws BuildException on error
*/
protected boolean createEmptyZip(File zipFile) throws BuildException { protected boolean createEmptyZip(File zipFile) throws BuildException {
if (!createEmpty) { if (!createEmpty) {
return true; return true;
@@ -667,6 +702,7 @@ public class Jar extends Zip {
zOut.close(); zOut.close();
} }
} catch (IOException ex) { } catch (IOException ex) {
// Ignore close exception
} }
createEmpty = false; createEmpty = false;
} }
@@ -708,7 +744,14 @@ public class Jar extends Zip {
index = false; index = false;
} }


/**
* The manifest config enumerated type.
*/
public static class FilesetManifestConfig extends EnumeratedAttribute { public static class FilesetManifestConfig extends EnumeratedAttribute {
/**
* Get the list of valid strings.
* @return the list of values - "skip", "merge" and "mergewithoutmain"
*/
public String[] getValues() { public String[] getValues() {
return new String[] {"skip", "merge", "mergewithoutmain"}; return new String[] {"skip", "merge", "mergewithoutmain"};
} }
@@ -718,6 +761,10 @@ public class Jar extends Zip {
* Writes the directory entries from the first and the filenames * Writes the directory entries from the first and the filenames
* from the second list to the given writer, one entry per line. * from the second list to the given writer, one entry per line.
* *
* @param dirs a list of directories
* @param files a list of files
* @param writer the writer to write to
* @throws IOException on error
* @since Ant 1.6.2 * @since Ant 1.6.2
*/ */
protected final void writeIndexLikeList(List dirs, List files, protected final void writeIndexLikeList(List dirs, List files,
@@ -776,6 +823,9 @@ public class Jar extends Zip {
* <p>if there is a classpath and the given file doesn't match any * <p>if there is a classpath and the given file doesn't match any
* of its entries, return null.</p> * of its entries, return null.</p>
* *
* @param fileName the name to look for
* @param classpath the classpath to look in (may be null)
* @return the matching entry, or null if the file is not found
* @since Ant 1.6.2 * @since Ant 1.6.2
*/ */
protected static final String findJarName(String fileName, protected static final String findJarName(String fileName,
@@ -819,8 +869,11 @@ public class Jar extends Zip {
/** /**
* Grab lists of all root-level files and all directories * Grab lists of all root-level files and all directories
* contained in the given archive. * contained in the given archive.
*
* @param file the zip file to examine
* @param dirs where to place the directories found
* @param files where to place the files found
* @since Ant 1.7 * @since Ant 1.7
* @throws IOException on error
*/ */
protected static final void grabFilesAndDirs(String file, List dirs, protected static final void grabFilesAndDirs(String file, List dirs,
List files) List files)


+ 74
- 8
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -486,6 +486,7 @@ public class Javadoc extends Task {


/** /**
* Adds a command-line argument. * Adds a command-line argument.
* @return a command-line argument to configure
* @since Ant 1.6 * @since Ant 1.6
*/ */
public Commandline.Argument createArg() { public Commandline.Argument createArg() {
@@ -1064,6 +1065,7 @@ public class Javadoc extends Task {


/** /**
* Create links to javadoc output at the given URL. * Create links to javadoc output at the given URL.
* @param src the URL to link to
*/ */
public void setLink(String src) { public void setLink(String src) {
if (!javadoc1) { if (!javadoc1) {
@@ -1199,30 +1201,55 @@ public class Javadoc extends Task {
private boolean offline = false; private boolean offline = false;
private File packagelistLoc; private File packagelistLoc;


/** Constructor for LinkArguement */
public LinkArgument() { public LinkArgument() {
//empty //empty
} }


/**
* Set the href attribute.
* @param hr a <code>String</code> value
*/
public void setHref(String hr) { public void setHref(String hr) {
href = hr; href = hr;
} }


/**
* Get the href attribute.
* @return the href attribute.
*/
public String getHref() { public String getHref() {
return href; return href;
} }


/**
* Set the packetlist location attribute.
* @param src a <code>File</code> value
*/
public void setPackagelistLoc(File src) { public void setPackagelistLoc(File src) {
packagelistLoc = src; packagelistLoc = src;
} }


/**
* Get the packetList location attribute.
* @return the packetList location attribute.
*/
public File getPackagelistLoc() { public File getPackagelistLoc() {
return packagelistLoc; return packagelistLoc;
} }


/**
* Set the offline attribute.
* @param offline a <code>boolean</code> value
*/
public void setOffline(boolean offline) { public void setOffline(boolean offline) {
this.offline = offline; this.offline = offline;
} }


/**
* Get the linkOffline attribute.
* @return the linkOffline attribute.
*/
public boolean isLinkOffline() { public boolean isLinkOffline() {
return offline; return offline;
} }
@@ -1233,6 +1260,7 @@ public class Javadoc extends Task {
* custom tags. This argument is only available for JavaDoc 1.4, * custom tags. This argument is only available for JavaDoc 1.4,
* and will generate a verbose message (and then be ignored) * and will generate a verbose message (and then be ignored)
* when run on Java versions below 1.4. * when run on Java versions below 1.4.
* @return tag argument to be configured
*/ */
public TagArgument createTag() { public TagArgument createTag() {
if (!javadoc4) { if (!javadoc4) {
@@ -1372,11 +1400,11 @@ public class Javadoc extends Task {


/** /**
* Returns the -tag parameter this argument represented. * Returns the -tag parameter this argument represented.
*
* @return the -tag parameter as a string
* @exception BuildException if either the name or description * @exception BuildException if either the name or description
* is <code>null</code> or empty. * is <code>null</code> or empty.
*/ */
public String getParameter () throws BuildException {
public String getParameter() throws BuildException {
if (name == null || name.equals("")) { if (name == null || name.equals("")) {
throw new BuildException ("No name specified for custom tag."); throw new BuildException ("No name specified for custom tag.");
} }
@@ -1392,6 +1420,7 @@ public class Javadoc extends Task {
/** /**
* Separates packages on the overview page into whatever * Separates packages on the overview page into whatever
* groups you specify, one group per table. * groups you specify, one group per table.
* @return a group argument to be configured
*/ */
public GroupArgument createGroup() { public GroupArgument createGroup() {
GroupArgument ga = new GroupArgument(); GroupArgument ga = new GroupArgument();
@@ -1399,27 +1428,48 @@ public class Javadoc extends Task {
return ga; return ga;
} }



/**
* A class corresponding to the group nested element.
*/
public class GroupArgument { public class GroupArgument {
private Html title; private Html title;
private Vector packages = new Vector(); private Vector packages = new Vector();


/** Constructor for GroupArgument */
public GroupArgument() { public GroupArgument() {
//empty //empty
} }


/**
* Set the title attribute using a string.
* @param src a <code>String</code> value
*/
public void setTitle(String src) { public void setTitle(String src) {
Html h = new Html(); Html h = new Html();
h.addText(src); h.addText(src);
addTitle(h); addTitle(h);
} }
/**
* Set the title attribute using a nested Html value.
* @param text a <code>Html</code> value
*/
public void addTitle(Html text) { public void addTitle(Html text) {
title = text; title = text;
} }


/**
* Get the title.
* @return the title
*/
public String getTitle() { public String getTitle() {
return title != null ? title.getText() : null; return title != null ? title.getText() : null;
} }


/**
* Set the packages to javadoc on.
* @param src a comma separated list of packages
*/
public void setPackages(String src) { public void setPackages(String src) {
StringTokenizer tok = new StringTokenizer(src, ","); StringTokenizer tok = new StringTokenizer(src, ",");
while (tok.hasMoreTokens()) { while (tok.hasMoreTokens()) {
@@ -1429,10 +1479,18 @@ public class Javadoc extends Task {
addPackage(pn); addPackage(pn);
} }
} }
/**
* Add a package nested element.
* @param pn a nested element specifing the package.
*/
public void addPackage(PackageName pn) { public void addPackage(PackageName pn) {
packages.addElement(pn); packages.addElement(pn);
} }


/**
* Get the packages as a collon separated list.
* @return the packages as a string
*/
public String getPackages() { public String getPackages() {
StringBuffer p = new StringBuffer(); StringBuffer p = new StringBuffer();
for (int i = 0; i < packages.size(); i++) { for (int i = 0; i < packages.size(); i++) {
@@ -1447,6 +1505,7 @@ public class Javadoc extends Task {


/** /**
* Charset for cross-platform viewing of generated documentation. * Charset for cross-platform viewing of generated documentation.
* @param src the name of the charset
*/ */
public void setCharset(String src) { public void setCharset(String src) {
this.add12ArgIfNotEmpty("-charset", src); this.add12ArgIfNotEmpty("-charset", src);
@@ -1457,6 +1516,7 @@ public class Javadoc extends Task {
* a non zero return code)? * a non zero return code)?
* *
* <p>Default is false.</p> * <p>Default is false.</p>
* @param b a <code>boolean</code> value
*/ */
public void setFailonerror(boolean b) { public void setFailonerror(boolean b) {
failOnError = b; failOnError = b;
@@ -1465,7 +1525,7 @@ public class Javadoc extends Task {
/** /**
* Enables the -source switch, will be ignored if javadoc is not * Enables the -source switch, will be ignored if javadoc is not
* the 1.4 version. * the 1.4 version.
*
* @param source a <code>String</code> value
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void setSource(String source) { public void setSource(String source) {
@@ -1481,7 +1541,7 @@ public class Javadoc extends Task {
* *
* <p>All included directories will be translated into package * <p>All included directories will be translated into package
* names be converting the directory separator into dots.</p> * names be converting the directory separator into dots.</p>
*
* @param packageSet a directory set
* @since 1.5 * @since 1.5
*/ */
public void addPackageset(DirSet packageSet) { public void addPackageset(DirSet packageSet) {
@@ -1495,7 +1555,7 @@ public class Javadoc extends Task {
* will automatically add * will automatically add
* <code>includes=&quot;**&#47;*.java&quot;</code> to the * <code>includes=&quot;**&#47;*.java&quot;</code> to the
* fileset.</p> * fileset.</p>
*
* @param fs a file set
* @since 1.5 * @since 1.5
*/ */
public void addFileset(FileSet fs) { public void addFileset(FileSet fs) {
@@ -1505,7 +1565,7 @@ public class Javadoc extends Task {
/** /**
* Enables the -linksource switch, will be ignored if javadoc is not * Enables the -linksource switch, will be ignored if javadoc is not
* the 1.4 version. Default is false * the 1.4 version. Default is false
*
* @param b a <code>String</code> value
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void setLinksource(boolean b) { public void setLinksource(boolean b) {
@@ -1519,7 +1579,7 @@ public class Javadoc extends Task {
/** /**
* Enables the -linksource switch, will be ignored if javadoc is not * Enables the -linksource switch, will be ignored if javadoc is not
* the 1.4 version. Default is false * the 1.4 version. Default is false
*
* @param b a <code>String</code> value
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void setBreakiterator(boolean b) { public void setBreakiterator(boolean b) {
@@ -1533,7 +1593,7 @@ public class Javadoc extends Task {
/** /**
* Enables the -noqualifier switch, will be ignored if javadoc is not * Enables the -noqualifier switch, will be ignored if javadoc is not
* the 1.4 version. * the 1.4 version.
*
* @param noqualifier the parameter to the -noqualifier switch
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void setNoqualifier(String noqualifier) { public void setNoqualifier(String noqualifier) {
@@ -1544,6 +1604,10 @@ public class Javadoc extends Task {
this.noqualifier = noqualifier; this.noqualifier = noqualifier;
} }


/**
* Execute the task.
* @throws BuildException on error
*/
public void execute() throws BuildException { public void execute() throws BuildException {
if ("javadoc2".equals(getTaskType())) { if ("javadoc2".equals(getTaskType())) {
log("!! javadoc2 is deprecated. Use javadoc instead. !!"); log("!! javadoc2 is deprecated. Use javadoc instead. !!");
@@ -2122,6 +2186,8 @@ public class Javadoc extends Task {


/** /**
* Convenience method to expand properties. * Convenience method to expand properties.
* @param content the string to expand
* @return the converted string
*/ */
protected String expand(String content) { protected String expand(String content) {
return getProject().replaceProperties(content); return getProject().replaceProperties(content);


+ 4
- 3
src/main/org/apache/tools/ant/taskdefs/Jikes.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2000,2002-2004 The Apache Software Foundation
* Copyright 2000,2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -42,8 +42,9 @@ public class Jikes {


/** /**
* Constructs a new Jikes object. * Constructs a new Jikes object.
* @param jop - Parser to send jike's output to
* @param command - name of jikes executable
* @param jop Parser to send jike's output to
* @param command name of jikes executable
* @param project the current project
*/ */
protected Jikes(JikesOutputParser jop, String command, Project project) { protected Jikes(JikesOutputParser jop, String command, Project project) {
super(); super();


+ 9
- 2
src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2000,2002-2004 The Apache Software Foundation
* Copyright 2000,2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -47,18 +47,22 @@ public class JikesOutputParser implements ExecuteStreamHandler {


/** /**
* Ignore. * Ignore.
* @param os ignored
*/ */
public void setProcessInputStream(OutputStream os) { public void setProcessInputStream(OutputStream os) {
} }


/** /**
* Ignore. * Ignore.
* @param is ignored
*/ */
public void setProcessErrorStream(InputStream is) { public void setProcessErrorStream(InputStream is) {
} }


/** /**
* Set the inputstream * Set the inputstream
* @param is the input stream
* @throws IOException on error
*/ */
public void setProcessOutputStream(InputStream is) throws IOException { public void setProcessOutputStream(InputStream is) throws IOException {
br = new BufferedReader(new InputStreamReader(is)); br = new BufferedReader(new InputStreamReader(is));
@@ -66,6 +70,7 @@ public class JikesOutputParser implements ExecuteStreamHandler {


/** /**
* Invokes parseOutput. * Invokes parseOutput.
* @throws IOException on error
*/ */
public void start() throws IOException { public void start() throws IOException {
parseOutput(br); parseOutput(br);
@@ -79,7 +84,8 @@ public class JikesOutputParser implements ExecuteStreamHandler {


/** /**
* Construct a new Parser object * Construct a new Parser object
* @param task - task in which context we are called
* @param task task in which context we are called
* @param emacsMode if true output in emacs mode
*/ */
protected JikesOutputParser(Task task, boolean emacsMode) { protected JikesOutputParser(Task task, boolean emacsMode) {
super(); super();
@@ -97,6 +103,7 @@ public class JikesOutputParser implements ExecuteStreamHandler {
/** /**
* Parse the output of a jikes compiler * Parse the output of a jikes compiler
* @param reader - Reader used to read jikes's output * @param reader - Reader used to read jikes's output
* @throws IOException on error
*/ */
protected void parseOutput(BufferedReader reader) throws IOException { protected void parseOutput(BufferedReader reader) throws IOException {
if (emacsMode) { if (emacsMode) {


+ 34
- 23
src/main/org/apache/tools/ant/taskdefs/KeySubst.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2000,2002-2004 The Apache Software Foundation
* Copyright 2000,2002-2005 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -45,8 +45,9 @@ public class KeySubst extends Task {
private Hashtable replacements = new Hashtable(); private Hashtable replacements = new Hashtable();


/** /**
Do the execution.
*/
* Do the execution.
* @throws BuildException on error
*/
public void execute() throws BuildException { public void execute() throws BuildException {
log("!! KeySubst is deprecated. Use Filter + Copy instead. !!"); log("!! KeySubst is deprecated. Use Filter + Copy instead. !!");
log("Performing Substitutions"); log("Performing Substitutions");
@@ -96,38 +97,42 @@ public class KeySubst extends Task {
} }


/** /**
Set the source file.
*/
* Set the source file.
* @param s the source file
*/
public void setSrc(File s) { public void setSrc(File s) {
this.source = s; this.source = s;
} }


/** /**
Set the destination file.
*/
* Set the destination file.
* @param dest the destination file
*/
public void setDest(File dest) { public void setDest(File dest) {
this.dest = dest; this.dest = dest;
} }


/** /**
Sets the separator between name=value arguments
in setKeys(). By default it is "*".
*/
* Sets the separator between name=value arguments
* in setKeys(). By default it is "*".
* @param sep the separator string
*/
public void setSep(String sep) { public void setSep(String sep) {
this.sep = sep; this.sep = sep;
} }
/** /**
* Sets the keys. * Sets the keys.
* *
Format string is like this:
<p>
name=value*name2=value
<p>
Names are case sensitive.
<p>
Use the setSep() method to change the * to something else
if you need to use * as a name or value.
*/
* Format string is like this:
* <p>
* name=value*name2=value
* <p>
* Names are case sensitive.
* <p>
* Use the setSep() method to change the * to something else
* if you need to use * as a name or value.
* @param keys a <code>String</code> value
*/
public void setKeys(String keys) { public void setKeys(String keys) {
if (keys != null && keys.length() > 0) { if (keys != null && keys.length() > 0) {
StringTokenizer tok = StringTokenizer tok =
@@ -145,6 +150,10 @@ public class KeySubst extends Task {
} }




/**
* A test method.
* @param args not used
*/
public static void main(String[] args) { public static void main(String[] args) {
try { try {
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
@@ -158,10 +167,12 @@ public class KeySubst extends Task {
} }


/** /**
Does replacement on text using the hashtable of keys.

@return the string with the replacements in it.
*/
* Does replacement on text using the hashtable of keys.
* @param origString an input string
* @param keys mapping of keys to values
* @return the string with the replacements in it.
* @throws BuildException on error
*/
public static String replace(String origString, Hashtable keys) public static String replace(String origString, Hashtable keys)
throws BuildException { throws BuildException {
StringBuffer finalString = new StringBuffer(); StringBuffer finalString = new StringBuffer();


Loading…
Cancel
Save