Sorry, helps if I attach the file eh?
- Added javadoc (@param etc)
- changed from <CODE> to <code> for XHTML compliance
- removed unnecessary nesting
if (condition) {
return foo;
} else { <-- not required - although I can see that in some ways it
helps readability
if (conition) {
return bar;
}
No unit tests with this
Kev
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Index: DirectoryScanner.java
===================================================================
RCS file:
/home/cvspublic/ant/src/main/org/apache/tools/ant/DirectoryScanner.java,v
retrieving revision 1.75
diff -u -r1.75 DirectoryScanner.java
--- DirectoryScanner.java 3 Dec 2004 08:04:43 -0000 1.75
+++ DirectoryScanner.java 8 Dec 2004 05:19:23 -0000
@@ -447,16 +447,16 @@
* Add a pattern to the default excludes unless it is already a
* default exclude.
*
- * @param s A string to add as an exclude pattern.
+ * @param pattern A string to add as an exclude pattern.
* @return <code>true</code> if the string was added
* <code>false</code> if it already
* existed.
*
* @since Ant 1.6
*/
- public static boolean addDefaultExclude(String s) {
- if (defaultExcludes.indexOf(s) == -1) {
- defaultExcludes.add(s);
+ public static boolean addDefaultExclude(String pattern) {
+ if (defaultExcludes.indexOf(pattern) == -1) {
+ defaultExcludes.add(pattern);
return true;
}
return false;
@@ -465,7 +465,7 @@
/**
* Remove a string if it is a default exclude.
*
- * @param s The string to attempt to remove.
+ * @param pattern The string to attempt to remove.
* @return <code>true</code> if <code>s</code> was a default
* exclude (and thus was removed),
* <code>false</code> if <code>s</code> was not
@@ -473,8 +473,8 @@
*
* @since Ant 1.6
*/
- public static boolean removeDefaultExclude(String s) {
- return defaultExcludes.remove(s);
+ public static boolean removeDefaultExclude(String pattern) {
+ return defaultExcludes.remove(pattern);
}
/**
@@ -508,7 +508,7 @@
* Sets the base directory to be scanned. This is the directory which is
* scanned recursively.
*
- * @param basedir The base directory for scanning.
+ * @param basedir The base directory to scan.
* Should not be <code>null</code>.
*/
public void setBasedir(File basedir) {
@@ -546,9 +546,9 @@
}
/**
- * gets whether or not a DirectoryScanner follows symbolic links
+ * Sets whether or not a DirectoryScanner follows symbolic links
*
- * @return flag indicating whether symbolic links should be followed
+ * @return whether or not symbolic links should be followed
*
* @since ant 1.6
*/
@@ -578,7 +578,7 @@
* list is given, all elements must be
* non-<code>null</code>.
*/
- public void setIncludes(String[] includes) {
+ public void setIncludes(final String[] includes) {
if (includes == null) {
this.includes = null;
} else {
@@ -608,7 +608,7 @@
* should be excluded. If a non-<code>null</code> list is
* given, all elements must be non-<code>null</code>.
*/
- public void setExcludes(String[] excludes) {
+ public void setExcludes(final String[] excludes) {
if (excludes == null) {
this.excludes = null;
} else {
@@ -705,7 +705,7 @@
}
/**
- * this routine is actually checking all the include patterns in
+ * This routine is actually checking all the include patterns in
* order to avoid scanning everything under base dir
* @since ant1.6
*/
@@ -944,7 +944,7 @@
}
}
/**
- * process included file
+ * Process included file
* @param name path of the file relative to the directory of the fileset
* @param file included file
*/
@@ -968,11 +968,11 @@
}
/**
- *
+ * Checks included directories
* @param name path of the directory relative to the directory of
* the fileset
* @param file directory as file
- * @param fast
+ * @param fast use fast scan
*/
private void accountForIncludedDir(String name, File file, boolean fast) {
if (!dirsIncluded.contains(name)
@@ -1142,7 +1142,7 @@
/**
* Return the count of included files.
- * @return <CODE>int</CODE>.
+ * @return <code>int</code>.
* @since Ant 1.6.3
*/
public int getIncludedFilesCount() {
@@ -1222,7 +1222,7 @@
/**
* Return the count of included directories.
- * @return <CODE>int</CODE>.
+ * @return <code>int</code>.
* @since Ant 1.6.3
*/
public int getIncludedDirsCount() {
@@ -1327,7 +1327,7 @@
/**
* Returns a cached result of list performed on file, if
* available. Invokes the method and caches the result otherwise.
- *
+ * @return array of files
* @since Ant 1.6
*/
private String[] list(File file) {
@@ -1345,7 +1345,7 @@
* From <code>base</code> traverse the filesystem in a case
* insensitive manner in order to find a file that matches the
* given name.
- *
+ * @param base The base directory to scan.
* @return File object that points to the file in question. if it
* hasn't been found it will simply be <code>new File(base,
* path)</code>.
@@ -1362,7 +1362,8 @@
* From <code>base</code> traverse the filesystem in a case
* insensitive manner in order to find a file that matches the
* given stack of names.
- *
+ * @param base The base directory to scan.
+ * @param pathElements a vector of elements making up the path
* @return File object that points to the file in question or null.
*
* @since Ant 1.6
@@ -1370,27 +1371,26 @@
private File findFileCaseInsensitive(File base, Vector pathElements) {
if (pathElements.size() == 0) {
return base;
- } else {
- if (!base.isDirectory()) {
- return null;
- }
- String[] files = list(base);
- if (files == null) {
- throw new BuildException("IO error scanning directory "
- + base.getAbsolutePath());
- }
- String current = (String) pathElements.remove(0);
- for (int i = 0; i < files.length; i++) {
- if (files[i].equals(current)) {
- base = new File(base, files[i]);
- return findFileCaseInsensitive(base, pathElements);
- }
+ }
+ if (!base.isDirectory()) {
+ return null;
+ }
+ String[] files = list(base);
+ if (files == null) {
+ throw new BuildException("IO error scanning directory "
+ + base.getAbsolutePath());
+ }
+ String current = (String) pathElements.remove(0);
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].equals(current)) {
+ base = new File(base, files[i]);
+ return findFileCaseInsensitive(base, pathElements);
}
- for (int i = 0; i < files.length; i++) {
- if (files[i].equalsIgnoreCase(current)) {
- base = new File(base, files[i]);
- return findFileCaseInsensitive(base, pathElements);
- }
+ }
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].equalsIgnoreCase(current)) {
+ base = new File(base, files[i]);
+ return findFileCaseInsensitive(base, pathElements);
}
}
return null;
@@ -1399,7 +1399,8 @@
/**
* From <code>base</code> traverse the filesystem in order to find
* a file that matches the given name.
- *
+ * @param base The base directory.
+ * @param path a String representing the path.
* @return File object that points to the file in question or null.
*
* @since Ant 1.6
@@ -1411,7 +1412,8 @@
/**
* From <code>base</code> traverse the filesystem in order to find
* a file that matches the given stack of names.
- *
+ * @param base The base directory.
+ * @param pathElements a vector of elements making up the path.
* @return File object that points to the file in question or null.
*
* @since Ant 1.6
@@ -1419,21 +1421,20 @@
private File findFile(File base, Vector pathElements) {
if (pathElements.size() == 0) {
return base;
- } else {
- if (!base.isDirectory()) {
- return null;
- }
- String[] files = list(base);
- if (files == null) {
- throw new BuildException("IO error scanning directory "
- + base.getAbsolutePath());
- }
- String current = (String) pathElements.remove(0);
- for (int i = 0; i < files.length; i++) {
- if (files[i].equals(current)) {
- base = new File(base, files[i]);
- return findFile(base, pathElements);
- }
+ }
+ if (!base.isDirectory()) {
+ return null;
+ }
+ String[] files = list(base);
+ if (files == null) {
+ throw new BuildException("IO error scanning directory "
+ + base.getAbsolutePath());
+ }
+ String current = (String) pathElements.remove(0);
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].equals(current)) {
+ base = new File(base, files[i]);
+ return findFile(base, pathElements);
}
}
return null;
@@ -1442,6 +1443,8 @@
/**
* Do we have to traverse a symlink when trying to reach path from
* basedir?
+ * @param base The base directory.
+ * @param path A String representing the path.
* @since Ant 1.6
*/
private boolean isSymlink(File base, String path) {
@@ -1451,6 +1454,8 @@
/**
* Do we have to traverse a symlink when trying to reach path from
* basedir?
+ * @param base The base directory.
+ * @param pathElements A vector of elements making up the path.
* @since Ant 1.6
*/
private boolean isSymlink(File base, Vector pathElements) {
@@ -1459,10 +1464,9 @@
try {
if (FILE_UTILS.isSymbolicLink(base, current)) {
return true;
- } else {
- base = new File(base, current);
- return isSymlink(base, pathElements);
- }
+ }
+ base = new File(base, current);
+ return isSymlink(base, pathElements);
} catch (IOException ioe) {
String msg = "IOException caught while checking "
+ "for links, couldn't get canonical path!";
@@ -1484,7 +1488,8 @@
/**
* Has the directory with the given path relative to the base
* directory already been scanned?
- *
+ * @param vpath A String representing the directory to check.
+ * @return whether or not the directory has been checked.
* <p>Registers the given directory as scanned as a side effect.</p>
*
* @since Ant 1.6
@@ -1510,7 +1515,9 @@
/**
* Adds all patterns that are no real patterns (doesn't contain
* wildcards) to the set and returns the real patterns.
- *
+ * @param set The set of patterns to add to.
+ * @param patterns The patterns to add.
+ * @return An array containing the patterns
* @since Ant 1.7
*/
private String[] fillNonPatternSet(Set set, String[] patterns) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]