diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index d44cc0a81..b4805b4b4 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -175,6 +175,10 @@ public class AntClassLoader extends ClassLoader implements BuildListener { * The size of buffers to be used in this classloader. */ private static final int BUFFER_SIZE = 8192; + /** + * Number of array elements in a test array of strings + */ + private static final int NUMBER_OF_STRINGS = 256; /** * The components of the classpath that the classloader searches @@ -549,7 +553,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { //At least one constructor is guaranteed to be there, but check anyway. if (cons != null) { if (cons.length > 0 && cons[0] != null) { - final String[] strs = new String[256]; + final String[] strs = new String[NUMBER_OF_STRINGS]; try { cons[0].newInstance(strs); // Expecting an exception to be thrown by this call: diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java index 23e79507c..e846ae0f5 100644 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -70,7 +70,6 @@ import org.apache.tools.ant.types.selectors.FileSelector; import org.apache.tools.ant.types.selectors.SelectorScanner; import org.apache.tools.ant.types.selectors.SelectorUtils; import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.taskdefs.condition.Os; /** * Class for scanning a directory for files/directories which match certain @@ -707,7 +706,7 @@ public class DirectoryScanner if (!path.equals(currentelement)) { myfile = findFile(basedir, currentelement); if (myfile != null) { - currentelement = + currentelement = fileUtils.removeLeadingPath(basedir, myfile); } @@ -716,7 +715,7 @@ public class DirectoryScanner throw new BuildException(ex); } } - + if ((myfile == null || !myfile.exists()) && !isCaseSensitive) { File f = findFileCaseInsensitive(basedir, currentelement); if (f.exists()) { @@ -729,7 +728,7 @@ public class DirectoryScanner } if (myfile != null && myfile.exists()) { - if (!followSymlinks + if (!followSymlinks && isSymlink(basedir, currentelement)) { continue; } @@ -902,7 +901,7 @@ public class DirectoryScanner if (!filesIncluded.contains(name) && !filesExcluded.contains(name) && !filesDeselected.contains(name)) { - + if (!isExcluded(name)) { if (isSelected(name, file)) { filesIncluded.addElement(name); @@ -942,7 +941,7 @@ public class DirectoryScanner scandir(file, name + File.separator, fast); } } - + } else { everythingIncluded = false; dirsExcluded.addElement(name); diff --git a/src/main/org/apache/tools/ant/helper/AntXMLContext.java b/src/main/org/apache/tools/ant/helper/AntXMLContext.java index 24d73adaf..ae26d1bba 100644 --- a/src/main/org/apache/tools/ant/helper/AntXMLContext.java +++ b/src/main/org/apache/tools/ant/helper/AntXMLContext.java @@ -120,38 +120,70 @@ public class AntXMLContext { * when processing a particular build file. */ private boolean ignoreProjectTag = false; - + /** + * constructor + * @param project the project to which this antxml context belongs to + */ public AntXMLContext(Project project) { this.project = project; implicitTarget.setName(""); targetVector.addElement(implicitTarget); } + /** + * sets the build file to which the XML context belongs + * @param buildFile ant build file + */ public void setBuildFile(File buildFile) { this.buildFile = buildFile; this.buildFileParent = new File(buildFile.getParent()); } + /** + * find out the build file + * @return the build file to which the xml context belongs + */ public File getBuildFile() { return buildFile; } + /** + * find out the parent build file of this build file + * @return the parent build file of this build file + */ public File getBuildFileParent() { return buildFileParent; } + /** + * find out the project to which this antxml context belongs + * @return project + */ public Project getProject() { return project; } + /** + * find out the current project name + * @return current project name + */ public String getCurrentProjectName() { return currentProjectName; } + /** + * set the name of the current project + * @param name name of the current project + */ public void setCurrentProjectName(String name) { this.currentProjectName = name; } + /** + * get the current runtime configurable wrapper + * can return null + * @return runtime configurable wrapper + */ public RuntimeConfigurable currentWrapper() { if (wStack.size() < 1) { return null; @@ -159,6 +191,11 @@ public class AntXMLContext { return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1); } + /** + * get the runtime configurable wrapper of the parent project + * can return null + * @return runtime configurable wrapper of the parent project + */ public RuntimeConfigurable parentWrapper() { if (wStack.size() < 2) { return null; @@ -166,41 +203,76 @@ public class AntXMLContext { return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2); } + /** + * add a runtime configurable wrapper to the internal stack + * @param wrapper runtime configurable wrapper + */ public void pushWrapper(RuntimeConfigurable wrapper) { wStack.addElement(wrapper); } + /** + * remove a runtime configurable wrapper from the stack + */ public void popWrapper() { if (wStack.size() > 0) { wStack.removeElementAt(wStack.size() - 1); } } + /** + * access the stack of wrappers + * @return the stack of wrappers + */ public Vector getWrapperStack() { return wStack; } + /** + * add a new target + * @param target target to add + */ public void addTarget(Target target) { targetVector.addElement(target); currentTarget = target; } + /** + * get the current target + * @return current target + */ public Target getCurrentTarget() { return currentTarget; } + /** + * get the implicit target + * @return implicit target + */ public Target getImplicitTarget() { return implicitTarget; } + /** + * sets the current target + * @param target current target + */ public void setCurrentTarget(Target target) { this.currentTarget = target; } + /** + * sets the implicit target + * @param target + */ public void setImplicitTarget(Target target) { this.implicitTarget = target; } + /** + * access the vector of targets + * @return vector of targets + */ public Vector getTargets() { return targetVector; } @@ -212,8 +284,6 @@ public class AntXMLContext { *
* This method was moved out of the configure method to allow
* it to be executed at parse time.
- *
- * @see #configure(java.lang.Object,org.xml.sax.AttributeList,org.apache.tools.ant.Project)
*/
public void configureId(Object element, Attributes attr) {
String id = attr.getValue("id");
@@ -222,18 +292,34 @@ public class AntXMLContext {
}
}
+ /**
+ * access the locator
+ * @return locator
+ */
public Locator getLocator() {
return locator;
}
+ /**
+ * sets the locator
+ * @param locator locator
+ */
public void setLocator(Locator locator) {
this.locator = locator;
}
+ /**
+ * tells whether the project tag is being ignored
+ * @return whether the project tag is being ignored
+ */
public boolean isIgnoringProjectTag() {
return ignoreProjectTag;
}
+ /**
+ * sets the flag to ignore the project tag
+ * @param flag to ignore the project tag
+ */
public void setIgnoreProjectTag(boolean flag) {
this.ignoreProjectTag = flag;
}
diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
index d3ccb5d79..b2d970550 100644
--- a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
+++ b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
@@ -121,6 +121,9 @@ public class ProjectHelperImpl extends ProjectHelper {
*/
private static FileUtils fu = FileUtils.newFileUtils();
+ /**
+ * default constructor
+ */
public ProjectHelperImpl() {
implicitTarget.setName("");
}
diff --git a/src/main/org/apache/tools/ant/input/DefaultInputHandler.java b/src/main/org/apache/tools/ant/input/DefaultInputHandler.java
index a88f0fe09..b9791ce7c 100644
--- a/src/main/org/apache/tools/ant/input/DefaultInputHandler.java
+++ b/src/main/org/apache/tools/ant/input/DefaultInputHandler.java
@@ -79,12 +79,14 @@ public class DefaultInputHandler implements InputHandler {
/**
* Prompts and requests input. May loop until a valid input has
* been entered.
+ * @param request the request to handle
+ * @throws BuildException if not possible to read from console
*/
public void handleInput(InputRequest request) throws BuildException {
String prompt = getPrompt(request);
DataInputStream in = null;
try {
- in =
+ in =
new DataInputStream(new KeepAliveInputStream(getInputStream()));
do {
System.err.println(prompt);
@@ -115,6 +117,7 @@ public class DefaultInputHandler implements InputHandler {
*
* @param request the request to construct the prompt for.
* Must not be null
.
+ * @return the prompt to ask the user
*/
protected String getPrompt(InputRequest request) {
String prompt = request.getPrompt();
@@ -139,6 +142,7 @@ public class DefaultInputHandler implements InputHandler {
/**
* Returns the input stream from which the user input should be read.
+ * @return the input stream from which the user input should be read.
*/
protected InputStream getInputStream() {
return System.in;
diff --git a/src/main/org/apache/tools/ant/input/InputHandler.java b/src/main/org/apache/tools/ant/input/InputHandler.java
index a9535daaf..4699b15e3 100644
--- a/src/main/org/apache/tools/ant/input/InputHandler.java
+++ b/src/main/org/apache/tools/ant/input/InputHandler.java
@@ -71,6 +71,8 @@ public interface InputHandler {
*
*
Postcondition: request.getInput will return a non-null * value, request.isInputValid will return true.
+ * @param request the request to be processed + * @throws org.apache.tools.ant.BuildException if the input cannot be read from the console */ void handleInput(InputRequest request) throws org.apache.tools.ant.BuildException;