iterateFiles(
File directory, String[] extensions, boolean recursive) {
return listFiles(directory, extensions, recursive).iterator();
}
@@ -531,7 +531,7 @@ public class FileUtils {
URL[] urls = new URL[files.length];
for (int i = 0; i < urls.length; i++) {
- urls[i] = files[i].toURL();
+ urls[i] = files[i].toURI().toURL();
}
return urls;
@@ -594,10 +594,10 @@ public class FileUtils {
* specified destination file. The directory holding the destination file is
* created if it does not exist. If the destination file exists, then this
* method will overwrite it.
- *
+ *
* @param srcFile an existing file to copy, must not be null
* @param destFile the new file, must not be null
- *
+ *
* @throws NullPointerException if source or destination is null
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
@@ -655,7 +655,7 @@ public class FileUtils {
/**
* Internal copy file method.
- *
+ *
* @param srcFile the validated source file, must not be null
* @param destFile the validated destination file, must not be null
* @param preserveFileDate whether to preserve the file date
@@ -780,7 +780,7 @@ public class FileUtils {
* If the destination directory did exist, then this method merges
* the source with the destination, with the source taking precedence.
*
- * Example: Copy directories only
+ * Example: Copy directories only
*
* // only copy the directory structure
* FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY);
@@ -824,7 +824,7 @@ public class FileUtils {
* If the destination directory did exist, then this method merges
* the source with the destination, with the source taking precedence.
*
- * Example: Copy directories only
+ * Example: Copy directories only
*
* // only copy the directory structure
* FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY, false);
@@ -842,7 +842,7 @@ public class FileUtils {
* // Copy using the filter
* FileUtils.copyDirectory(srcDir, destDir, filter, false);
*
- *
+ *
* @param srcDir an existing directory to copy, must not be null
* @param destDir the new directory, must not be null
* @param filter the filter to apply, null means copy all directories and files
@@ -873,11 +873,11 @@ public class FileUtils {
}
// Cater for destination being directory within the source directory (see IO-141)
- List exclusionList = null;
+ List exclusionList = null;
if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) {
File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter);
if (srcFiles != null && srcFiles.length > 0) {
- exclusionList = new ArrayList(srcFiles.length);
+ exclusionList = new ArrayList(srcFiles.length);
for (int i = 0; i < srcFiles.length; i++) {
File copiedFile = new File(destDir, srcFiles[i].getName());
exclusionList.add(copiedFile.getCanonicalPath());
@@ -889,7 +889,7 @@ public class FileUtils {
/**
* Internal copy directory method.
- *
+ *
* @param srcDir the validated source directory, must not be null
* @param destDir the validated destination directory, must not be null
* @param filter the filter to apply, null means copy all directories and files
@@ -899,7 +899,7 @@ public class FileUtils {
* @since Commons IO 1.1
*/
private static void doCopyDirectory(File srcDir, File destDir, FileFilter filter,
- boolean preserveFileDate, List exclusionList) throws IOException {
+ boolean preserveFileDate, List exclusionList) throws IOException {
if (destDir.exists()) {
if (destDir.isDirectory() == false) {
throw new IOException("Destination '" + destDir + "' exists but is not a directory");
@@ -964,7 +964,7 @@ public class FileUtils {
//-----------------------------------------------------------------------
/**
- * Deletes a directory recursively.
+ * Deletes a directory recursively.
*
* @param directory directory to delete
* @throws IOException in case deletion is unsuccessful
@@ -1108,7 +1108,7 @@ public class FileUtils {
/**
- * Reads the contents of a file into a String using the default encoding for the VM.
+ * Reads the contents of a file into a String using the default encoding for the VM.
* The file is always closed.
*
* @param file the file to read, must not be null
@@ -1150,7 +1150,7 @@ public class FileUtils {
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
* @since Commons IO 1.1
*/
- public static List readLines(File file, String encoding) throws IOException {
+ public static List readLines(File file, String encoding) throws IOException {
InputStream in = null;
try {
in = openInputStream(file);
@@ -1169,7 +1169,7 @@ public class FileUtils {
* @throws IOException in case of an I/O error
* @since Commons IO 1.3
*/
- public static List readLines(File file) throws IOException {
+ public static List readLines(File file) throws IOException {
return readLines(file, null);
}
@@ -1256,7 +1256,7 @@ public class FileUtils {
/**
* Writes a String to a file creating the file if it does not exist using the default encoding for the VM.
- *
+ *
* @param file the file to write
* @param data the content to write to the file
* @throws IOException in case of an I/O error
@@ -1301,7 +1301,7 @@ public class FileUtils {
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
* @since Commons IO 1.1
*/
- public static void writeLines(File file, String encoding, Collection lines) throws IOException {
+ public static void writeLines(File file, String encoding, Collection lines) throws IOException {
writeLines(file, encoding, lines, null);
}
@@ -1315,7 +1315,7 @@ public class FileUtils {
* @throws IOException in case of an I/O error
* @since Commons IO 1.3
*/
- public static void writeLines(File file, Collection lines) throws IOException {
+ public static void writeLines(File file, Collection lines) throws IOException {
writeLines(file, null, lines, null);
}
@@ -1335,7 +1335,7 @@ public class FileUtils {
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
* @since Commons IO 1.1
*/
- public static void writeLines(File file, String encoding, Collection lines, String lineEnding) throws IOException {
+ public static void writeLines(File file, String encoding, Collection lines, String lineEnding) throws IOException {
OutputStream out = null;
try {
out = openOutputStream(file);
@@ -1356,7 +1356,7 @@ public class FileUtils {
* @throws IOException in case of an I/O error
* @since Commons IO 1.3
*/
- public static void writeLines(File file, Collection lines, String lineEnding) throws IOException {
+ public static void writeLines(File file, Collection lines, String lineEnding) throws IOException {
writeLines(file, null, lines, lineEnding);
}
@@ -1556,7 +1556,7 @@ public class FileUtils {
/**
* Tests if the specified File
is newer than the specified
* Date
.
- *
+ *
* @param file the File
of which the modification date
* must be compared, must not be null
* @param date the date reference, must not be null
@@ -1623,7 +1623,7 @@ public class FileUtils {
/**
* Tests if the specified File
is older than the specified
* Date
.
- *
+ *
* @param file the File
of which the modification date
* must be compared, must not be null
* @param date the date reference, must not be null
@@ -1779,7 +1779,7 @@ public class FileUtils {
throw new IOException("Destination '" + destDir + "' is not a directory");
}
moveDirectory(src, new File(destDir, src.getName()));
-
+
}
/**
@@ -1862,7 +1862,7 @@ public class FileUtils {
* When the destination is on another file system, do a "copy and delete".
*
* @param src the file or directory to be moved
- * @param destDir the destination directory
+ * @param destDir the destination directory
* @param createDestDir If true
create the destination directory,
* otherwise if false
throw an IOException
* @throws NullPointerException if source or destination is null
diff --git a/src/org/apache/commons/io/FilenameUtils.java b/src/org/apache/commons/io/FilenameUtils.java
index 8e170b147..d8cc78b24 100644
--- a/src/org/apache/commons/io/FilenameUtils.java
+++ b/src/org/apache/commons/io/FilenameUtils.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -141,7 +141,7 @@ public class FilenameUtils {
//-----------------------------------------------------------------------
/**
* Determines if Windows file system is in use.
- *
+ *
* @return true if the system is Windows
*/
static boolean isSystemWindows() {
@@ -151,7 +151,7 @@ public class FilenameUtils {
//-----------------------------------------------------------------------
/**
* Checks if the character is a separator.
- *
+ *
* @param ch the character to check
* @return true if it is a separator character
*/
@@ -269,24 +269,24 @@ public class FilenameUtils {
if (prefix < 0) {
return null;
}
-
+
char[] array = new char[size + 2]; // +1 for possible extra slash, +2 for arraycopy
filename.getChars(0, filename.length(), array, 0);
-
+
// fix separators throughout
for (int i = 0; i < array.length; i++) {
if (array[i] == OTHER_SEPARATOR) {
array[i] = SYSTEM_SEPARATOR;
}
}
-
+
// add extra separator on the end to simplify code below
boolean lastIsDirectory = true;
if (array[size - 1] != SYSTEM_SEPARATOR) {
array[size++] = SYSTEM_SEPARATOR;
lastIsDirectory = false;
}
-
+
// adjoining slashes
for (int i = prefix + 1; i < size; i++) {
if (array[i] == SYSTEM_SEPARATOR && array[i - 1] == SYSTEM_SEPARATOR) {
@@ -295,7 +295,7 @@ public class FilenameUtils {
i--;
}
}
-
+
// dot slash
for (int i = prefix + 1; i < size; i++) {
if (array[i] == SYSTEM_SEPARATOR && array[i - 1] == '.' &&
@@ -308,7 +308,7 @@ public class FilenameUtils {
i--;
}
}
-
+
// double dot slash
outer:
for (int i = prefix + 2; i < size; i++) {
@@ -336,7 +336,7 @@ public class FilenameUtils {
i = prefix + 1;
}
}
-
+
if (size <= 0) { // should never be less than 0
return "";
}
@@ -416,7 +416,7 @@ public class FilenameUtils {
//-----------------------------------------------------------------------
/**
* Converts all separators to the Unix separator of forward slash.
- *
+ *
* @param path the path to be changed, null ignored
* @return the updated path
*/
@@ -429,7 +429,7 @@ public class FilenameUtils {
/**
* Converts all separators to the Windows separator of backslash.
- *
+ *
* @param path the path to be changed, null ignored
* @return the updated path
*/
@@ -442,7 +442,7 @@ public class FilenameUtils {
/**
* Converts all separators to the system separator.
- *
+ *
* @param path the path to be changed, null ignored
* @return the updated path
*/
@@ -527,7 +527,7 @@ public class FilenameUtils {
return 3;
}
return -1;
-
+
} else if (isSeparator(ch0) && isSeparator(ch1)) {
int posUnix = filename.indexOf(UNIX_SEPARATOR, 2);
int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2);
@@ -550,7 +550,7 @@ public class FilenameUtils {
* The position of the last forward or backslash is returned.
*
* The output will be the same irrespective of the machine that the code is running on.
- *
+ *
* @param filename the filename to find the last path separator in, null returns -1
* @return the index of the last separator character, or -1 if there
* is no such character
@@ -572,7 +572,7 @@ public class FilenameUtils {
* handle a file in either Unix or Windows format.
*
* The output will be the same irrespective of the machine that the code is running on.
- *
+ *
* @param filename the filename to find the last path separator in, null returns -1
* @return the index of the last separator character, or -1 if there
* is no such character
@@ -685,7 +685,7 @@ public class FilenameUtils {
/**
* Does the work of getting the path.
- *
+ *
* @param filename the filename
* @param separatorAdd 0 to omit the end separator, 1 to return it
* @return the path
@@ -766,7 +766,7 @@ public class FilenameUtils {
/**
* Does the work of getting the path.
- *
+ *
* @param filename the filename
* @param includeSeparator true to include the end separator
* @return the path
@@ -977,7 +977,7 @@ public class FilenameUtils {
public static boolean equals(
String filename1, String filename2,
boolean normalized, IOCase caseSensitivity) {
-
+
if (filename1 == null || filename2 == null) {
return filename1 == filename2;
}
@@ -1056,7 +1056,7 @@ public class FilenameUtils {
* @param extensions the extensions to check for, null checks for no extension
* @return true if the filename is one of the extensions
*/
- public static boolean isExtension(String filename, Collection extensions) {
+ public static boolean isExtension(String filename, Collection extensions) {
if (filename == null) {
return false;
}
@@ -1064,7 +1064,7 @@ public class FilenameUtils {
return (indexOfExtension(filename) == -1);
}
String fileExt = getExtension(filename);
- for (Iterator it = extensions.iterator(); it.hasNext();) {
+ for (Iterator it = extensions.iterator(); it.hasNext();) {
if (fileExt.equals(it.next())) {
return true;
}
@@ -1088,7 +1088,7 @@ public class FilenameUtils {
* wildcardMatch("c.txt", "*.???") --> true
* wildcardMatch("c.txt", "*.????") --> false
*
- *
+ *
* @param filename the filename to match on
* @param wildcardMatcher the wildcard string to match against
* @return true if the filename matches the wilcard string
@@ -1113,7 +1113,7 @@ public class FilenameUtils {
* wildcardMatch("c.txt", "*.???") --> true
* wildcardMatch("c.txt", "*.????") --> false
*
- *
+ *
* @param filename the filename to match on
* @param wildcardMatcher the wildcard string to match against
* @return true if the filename matches the wilcard string
@@ -1129,7 +1129,7 @@ public class FilenameUtils {
*
* The wildcard matcher uses the characters '?' and '*' to represent a
* single or multiple wildcard characters.
- *
+ *
* @param filename the filename to match on
* @param wildcardMatcher the wildcard string to match against
* @param caseSensitivity what case sensitivity rule to use, null means case-sensitive
@@ -1152,32 +1152,32 @@ public class FilenameUtils {
boolean anyChars = false;
int textIdx = 0;
int wcsIdx = 0;
- Stack backtrack = new Stack();
-
+ Stack backtrack = new Stack();
+
// loop around a backtrack stack, to handle complex * matching
do {
if (backtrack.size() > 0) {
- int[] array = (int[]) backtrack.pop();
+ int[] array = backtrack.pop();
wcsIdx = array[0];
textIdx = array[1];
anyChars = true;
}
-
+
// loop whilst tokens and text left to process
while (wcsIdx < wcs.length) {
-
+
if (wcs[wcsIdx].equals("?")) {
// ? so move to next text char
textIdx++;
anyChars = false;
-
+
} else if (wcs[wcsIdx].equals("*")) {
// set any chars status
anyChars = true;
if (wcsIdx == wcs.length - 1) {
textIdx = filename.length();
}
-
+
} else {
// matching text token
if (anyChars) {
@@ -1198,41 +1198,41 @@ public class FilenameUtils {
break;
}
}
-
+
// matched text token, move text index to end of matched token
textIdx += wcs[wcsIdx].length();
anyChars = false;
}
-
+
wcsIdx++;
}
-
+
// full match
if (wcsIdx == wcs.length && textIdx == filename.length()) {
return true;
}
-
+
} while (backtrack.size() > 0);
-
+
return false;
}
/**
* Splits a string into a number of tokens.
- *
+ *
* @param text the text to split
* @return the tokens, never null
*/
static String[] splitOnTokens(String text) {
// used by wildcardMatch
// package level so a unit test may run on this
-
+
if (text.indexOf("?") == -1 && text.indexOf("*") == -1) {
return new String[] { text };
}
char[] array = text.toCharArray();
- ArrayList list = new ArrayList();
+ ArrayList list = new ArrayList();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < array.length; i++) {
if (array[i] == '?' || array[i] == '*') {
@@ -1254,7 +1254,7 @@ public class FilenameUtils {
list.add(buffer.toString());
}
- return (String[]) list.toArray( new String[ list.size() ] );
+ return list.toArray( new String[ list.size() ] );
}
}
diff --git a/src/org/apache/commons/io/IOUtils.java b/src/org/apache/commons/io/IOUtils.java
index 1f91e2562..3f6c65c13 100644
--- a/src/org/apache/commons/io/IOUtils.java
+++ b/src/org/apache/commons/io/IOUtils.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -207,7 +207,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedInputStream
.
- *
+ *
* @param input the InputStream
to read from
* @return the requested byte array
* @throws NullPointerException if the input is null
@@ -225,7 +225,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedReader
.
- *
+ *
* @param input the Reader
to read from
* @return the requested byte array
* @throws NullPointerException if the input is null
@@ -246,7 +246,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedReader
.
- *
+ *
* @param input the Reader
to read from
* @param encoding the encoding to use, null means platform default
* @return the requested byte array
@@ -266,7 +266,7 @@ public class IOUtils {
* using the default character encoding of the platform.
*
* This is the same as {@link String#getBytes()}.
- *
+ *
* @param input the String
to convert
* @return the requested byte array
* @throws NullPointerException if the input is null
@@ -285,7 +285,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedInputStream
.
- *
+ *
* @param is the InputStream
to read from
* @return the requested character array
* @throws NullPointerException if the input is null
@@ -307,7 +307,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedInputStream
.
- *
+ *
* @param is the InputStream
to read from
* @param encoding the encoding to use, null means platform default
* @return the requested character array
@@ -327,7 +327,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedReader
.
- *
+ *
* @param input the Reader
to read from
* @return the requested character array
* @throws NullPointerException if the input is null
@@ -348,7 +348,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedInputStream
.
- *
+ *
* @param input the InputStream
to read from
* @return the requested String
* @throws NullPointerException if the input is null
@@ -369,7 +369,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedInputStream
.
- *
+ *
* @param input the InputStream
to read from
* @param encoding the encoding to use, null means platform default
* @return the requested String
@@ -388,7 +388,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedReader
.
- *
+ *
* @param input the Reader
to read from
* @return the requested String
* @throws NullPointerException if the input is null
@@ -403,7 +403,7 @@ public class IOUtils {
/**
* Get the contents of a byte[]
as a String
* using the default character encoding of the platform.
- *
+ *
* @param input the byte array to read from
* @return the requested String
* @throws NullPointerException if the input is null
@@ -420,7 +420,7 @@ public class IOUtils {
*
* Character encoding names can be found at
* IANA .
- *
+ *
* @param input the byte array to read from
* @param encoding the encoding to use, null means platform default
* @return the requested String
@@ -452,7 +452,7 @@ public class IOUtils {
* @throws IOException if an I/O error occurs
* @since Commons IO 1.1
*/
- public static List readLines(InputStream input) throws IOException {
+ public static List readLines(InputStream input) throws IOException {
InputStreamReader reader = new InputStreamReader(input);
return readLines(reader);
}
@@ -474,7 +474,7 @@ public class IOUtils {
* @throws IOException if an I/O error occurs
* @since Commons IO 1.1
*/
- public static List readLines(InputStream input, String encoding) throws IOException {
+ public static List readLines(InputStream input, String encoding) throws IOException {
if (encoding == null) {
return readLines(input);
} else {
@@ -496,9 +496,9 @@ public class IOUtils {
* @throws IOException if an I/O error occurs
* @since Commons IO 1.1
*/
- public static List readLines(Reader input) throws IOException {
+ public static List readLines(Reader input) throws IOException {
BufferedReader reader = new BufferedReader(input);
- List list = new ArrayList();
+ List list = new ArrayList();
String line = reader.readLine();
while (line != null) {
list.add(line);
@@ -570,7 +570,7 @@ public class IOUtils {
* @throws IOException if an I/O error occurs, such as if the encoding is invalid
* @since Commons IO 1.2
*/
- public static LineIterator lineIterator(InputStream input, String encoding)
+ public static LineIterator lineIterator(InputStream input, String encoding)
throws IOException {
Reader reader = null;
if (encoding == null) {
@@ -617,7 +617,7 @@ public class IOUtils {
//-----------------------------------------------------------------------
/**
* Writes bytes from a byte[]
to an OutputStream
.
- *
+ *
* @param data the byte array to write, do not modify during output,
* null ignored
* @param output the OutputStream
to write to
@@ -637,7 +637,7 @@ public class IOUtils {
* using the default character encoding of the platform.
*
* This method uses {@link String#String(byte[])}.
- *
+ *
* @param data the byte array to write, do not modify during output,
* null ignored
* @param output the Writer
to write to
@@ -659,7 +659,7 @@ public class IOUtils {
* IANA .
*
* This method uses {@link String#String(byte[], String)}.
- *
+ *
* @param data the byte array to write, do not modify during output,
* null ignored
* @param output the Writer
to write to
@@ -684,7 +684,7 @@ public class IOUtils {
/**
* Writes chars from a char[]
to a Writer
* using the default character encoding of the platform.
- *
+ *
* @param data the char array to write, do not modify during output,
* null ignored
* @param output the Writer
to write to
@@ -704,7 +704,7 @@ public class IOUtils {
*
* This method uses {@link String#String(char[])} and
* {@link String#getBytes()}.
- *
+ *
* @param data the char array to write, do not modify during output,
* null ignored
* @param output the OutputStream
to write to
@@ -728,7 +728,7 @@ public class IOUtils {
*
* This method uses {@link String#String(char[])} and
* {@link String#getBytes(String)}.
- *
+ *
* @param data the char array to write, do not modify during output,
* null ignored
* @param output the OutputStream
to write to
@@ -752,7 +752,7 @@ public class IOUtils {
//-----------------------------------------------------------------------
/**
* Writes chars from a String
to a Writer
.
- *
+ *
* @param data the String
to write, null ignored
* @param output the Writer
to write to
* @throws NullPointerException if output is null
@@ -771,7 +771,7 @@ public class IOUtils {
* platform.
*
* This method uses {@link String#getBytes()}.
- *
+ *
* @param data the String
to write, null ignored
* @param output the OutputStream
to write to
* @throws NullPointerException if output is null
@@ -793,7 +793,7 @@ public class IOUtils {
* IANA .
*
* This method uses {@link String#getBytes(String)}.
- *
+ *
* @param data the String
to write, null ignored
* @param output the OutputStream
to write to
* @param encoding the encoding to use, null means platform default
@@ -816,7 +816,7 @@ public class IOUtils {
//-----------------------------------------------------------------------
/**
* Writes chars from a StringBuffer
to a Writer
.
- *
+ *
* @param data the StringBuffer
to write, null ignored
* @param output the Writer
to write to
* @throws NullPointerException if output is null
@@ -836,7 +836,7 @@ public class IOUtils {
* platform.
*
* This method uses {@link String#getBytes()}.
- *
+ *
* @param data the StringBuffer
to write, null ignored
* @param output the OutputStream
to write to
* @throws NullPointerException if output is null
@@ -858,7 +858,7 @@ public class IOUtils {
* IANA .
*
* This method uses {@link String#getBytes(String)}.
- *
+ *
* @param data the StringBuffer
to write, null ignored
* @param output the OutputStream
to write to
* @param encoding the encoding to use, null means platform default
@@ -891,7 +891,7 @@ public class IOUtils {
* @throws IOException if an I/O error occurs
* @since Commons IO 1.1
*/
- public static void writeLines(Collection lines, String lineEnding,
+ public static void writeLines(Collection lines, String lineEnding,
OutputStream output) throws IOException {
if (lines == null) {
return;
@@ -899,7 +899,7 @@ public class IOUtils {
if (lineEnding == null) {
lineEnding = LINE_SEPARATOR;
}
- for (Iterator it = lines.iterator(); it.hasNext(); ) {
+ for (Iterator it = lines.iterator(); it.hasNext(); ) {
Object line = it.next();
if (line != null) {
output.write(line.toString().getBytes());
@@ -924,7 +924,7 @@ public class IOUtils {
* @throws IOException if an I/O error occurs
* @since Commons IO 1.1
*/
- public static void writeLines(Collection lines, String lineEnding,
+ public static void writeLines(Collection lines, String lineEnding,
OutputStream output, String encoding) throws IOException {
if (encoding == null) {
writeLines(lines, lineEnding, output);
@@ -935,7 +935,7 @@ public class IOUtils {
if (lineEnding == null) {
lineEnding = LINE_SEPARATOR;
}
- for (Iterator it = lines.iterator(); it.hasNext(); ) {
+ for (Iterator it = lines.iterator(); it.hasNext(); ) {
Object line = it.next();
if (line != null) {
output.write(line.toString().getBytes(encoding));
@@ -956,7 +956,7 @@ public class IOUtils {
* @throws IOException if an I/O error occurs
* @since Commons IO 1.1
*/
- public static void writeLines(Collection lines, String lineEnding,
+ public static void writeLines(Collection lines, String lineEnding,
Writer writer) throws IOException {
if (lines == null) {
return;
@@ -964,7 +964,7 @@ public class IOUtils {
if (lineEnding == null) {
lineEnding = LINE_SEPARATOR;
}
- for (Iterator it = lines.iterator(); it.hasNext(); ) {
+ for (Iterator it = lines.iterator(); it.hasNext(); ) {
Object line = it.next();
if (line != null) {
writer.write(line.toString());
@@ -986,7 +986,7 @@ public class IOUtils {
* -1
after the copy has completed since the correct
* number of bytes cannot be returned as an int. For large streams
* use the copyLarge(InputStream, OutputStream)
method.
- *
+ *
* @param input the InputStream
to read from
* @param output the OutputStream
to write to
* @return the number of bytes copied
@@ -1009,7 +1009,7 @@ public class IOUtils {
*
* This method buffers the input internally, so there is no need to use a
* BufferedInputStream
.
- *
+ *
* @param input the InputStream
to read from
* @param output the OutputStream
to write to
* @return the number of bytes copied
diff --git a/src/org/apache/commons/io/comparator/DefaultFileComparator.java b/src/org/apache/commons/io/comparator/DefaultFileComparator.java
index d36076288..8de3cc4e7 100644
--- a/src/org/apache/commons/io/comparator/DefaultFileComparator.java
+++ b/src/org/apache/commons/io/comparator/DefaultFileComparator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,25 +44,23 @@ import java.util.Comparator;
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
* @since Commons IO 1.4
*/
-public class DefaultFileComparator implements Comparator, Serializable {
+public class DefaultFileComparator implements Comparator, Serializable {
/** Singleton default comparator instance */
- public static final Comparator DEFAULT_COMPARATOR = new DefaultFileComparator();
+ public static final Comparator DEFAULT_COMPARATOR = new DefaultFileComparator();
/** Singleton reverse default comparator instance */
- public static final Comparator DEFAULT_REVERSE = new ReverseComparator(DEFAULT_COMPARATOR);
+ public static final Comparator DEFAULT_REVERSE = new ReverseComparator(DEFAULT_COMPARATOR);
/**
* Compare the two files using the {@link File#compareTo(File)} method.
- *
+ *
* @param obj1 The first file to compare
* @param obj2 The second file to compare
* @return the result of calling file1's
* {@link File#compareTo(File)} with file2 as the parameter.
*/
- public int compare(Object obj1, Object obj2) {
- File file1 = (File)obj1;
- File file2 = (File)obj2;
+ public int compare(File file1, File file2) {
return file1.compareTo(file2);
}
}
diff --git a/src/org/apache/commons/io/comparator/ExtensionFileComparator.java b/src/org/apache/commons/io/comparator/ExtensionFileComparator.java
index 158480fb3..5797b02eb 100644
--- a/src/org/apache/commons/io/comparator/ExtensionFileComparator.java
+++ b/src/org/apache/commons/io/comparator/ExtensionFileComparator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -51,26 +51,26 @@ import org.apache.commons.io.IOCase;
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
* @since Commons IO 1.4
*/
-public class ExtensionFileComparator implements Comparator, Serializable {
+public class ExtensionFileComparator implements Comparator, Serializable {
/** Case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */
- public static final Comparator EXTENSION_COMPARATOR = new ExtensionFileComparator();
+ public static final Comparator EXTENSION_COMPARATOR = new ExtensionFileComparator();
/** Reverse case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */
- public static final Comparator EXTENSION_REVERSE = new ReverseComparator(EXTENSION_COMPARATOR);
+ public static final Comparator EXTENSION_REVERSE = new ReverseComparator(EXTENSION_COMPARATOR);
/** Case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */
- public static final Comparator EXTENSION_INSENSITIVE_COMPARATOR = new ExtensionFileComparator(IOCase.INSENSITIVE);
+ public static final Comparator EXTENSION_INSENSITIVE_COMPARATOR = new ExtensionFileComparator(IOCase.INSENSITIVE);
/** Reverse case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */
- public static final Comparator EXTENSION_INSENSITIVE_REVERSE
- = new ReverseComparator(EXTENSION_INSENSITIVE_COMPARATOR);
+ public static final Comparator EXTENSION_INSENSITIVE_REVERSE
+ = new ReverseComparator(EXTENSION_INSENSITIVE_COMPARATOR);
/** System sensitive extension comparator instance (see {@link IOCase#SYSTEM}) */
- public static final Comparator EXTENSION_SYSTEM_COMPARATOR = new ExtensionFileComparator(IOCase.SYSTEM);
+ public static final Comparator EXTENSION_SYSTEM_COMPARATOR = new ExtensionFileComparator(IOCase.SYSTEM);
/** Reverse system sensitive path comparator instance (see {@link IOCase#SYSTEM}) */
- public static final Comparator EXTENSION_SYSTEM_REVERSE = new ReverseComparator(EXTENSION_SYSTEM_COMPARATOR);
+ public static final Comparator EXTENSION_SYSTEM_REVERSE = new ReverseComparator(EXTENSION_SYSTEM_COMPARATOR);
/** Whether the comparison is case sensitive. */
private final IOCase caseSensitivity;
@@ -93,18 +93,16 @@ public class ExtensionFileComparator implements Comparator, Serializable {
/**
* Compare the extensions of two files the specified case sensitivity.
- *
+ *
* @param obj1 The first file to compare
* @param obj2 The second file to compare
* @return a negative value if the first file's extension
* is less than the second, zero if the extensions are the
* same and a positive value if the first files extension
* is greater than the second file.
- *
+ *
*/
- public int compare(Object obj1, Object obj2) {
- File file1 = (File)obj1;
- File file2 = (File)obj2;
+ public int compare(File file1, File file2) {
String suffix1 = FilenameUtils.getExtension(file1.getName());
String suffix2 = FilenameUtils.getExtension(file2.getName());
return caseSensitivity.checkCompareTo(suffix1, suffix2);
diff --git a/src/org/apache/commons/io/comparator/LastModifiedFileComparator.java b/src/org/apache/commons/io/comparator/LastModifiedFileComparator.java
index 8265023d0..0dcd0b242 100644
--- a/src/org/apache/commons/io/comparator/LastModifiedFileComparator.java
+++ b/src/org/apache/commons/io/comparator/LastModifiedFileComparator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,7 @@ import java.io.Serializable;
import java.util.Comparator;
/**
- * Compare the last modified date/time of two files for order
+ * Compare the last modified date/time of two files for order
* (see {@link File#lastModified()}).
*
* This comparator can be used to sort lists or arrays of files
@@ -45,28 +45,26 @@ import java.util.Comparator;
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
* @since Commons IO 1.4
*/
-public class LastModifiedFileComparator implements Comparator, Serializable {
+public class LastModifiedFileComparator implements Comparator, Serializable {
/** Last modified comparator instance */
- public static final Comparator LASTMODIFIED_COMPARATOR = new LastModifiedFileComparator();
+ public static final Comparator LASTMODIFIED_COMPARATOR = new LastModifiedFileComparator();
/** Reverse last modified comparator instance */
- public static final Comparator LASTMODIFIED_REVERSE = new ReverseComparator(LASTMODIFIED_COMPARATOR);
+ public static final Comparator LASTMODIFIED_REVERSE = new ReverseComparator(LASTMODIFIED_COMPARATOR);
/**
* Compare the last the last modified date/time of two files.
- *
+ *
* @param obj1 The first file to compare
* @param obj2 The second file to compare
* @return a negative value if the first file's lastmodified date/time
* is less than the second, zero if the lastmodified date/time are the
* same and a positive value if the first files lastmodified date/time
* is greater than the second file.
- *
+ *
*/
- public int compare(Object obj1, Object obj2) {
- File file1 = (File)obj1;
- File file2 = (File)obj2;
+ public int compare(File file1, File file2) {
long result = file1.lastModified() - file2.lastModified();
if (result < 0) {
return -1;
diff --git a/src/org/apache/commons/io/comparator/NameFileComparator.java b/src/org/apache/commons/io/comparator/NameFileComparator.java
index 76af21eeb..eb64fb589 100644
--- a/src/org/apache/commons/io/comparator/NameFileComparator.java
+++ b/src/org/apache/commons/io/comparator/NameFileComparator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,25 +49,25 @@ import org.apache.commons.io.IOCase;
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
* @since Commons IO 1.4
*/
-public class NameFileComparator implements Comparator, Serializable {
+public class NameFileComparator implements Comparator, Serializable {
/** Case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */
- public static final Comparator NAME_COMPARATOR = new NameFileComparator();
+ public static final Comparator NAME_COMPARATOR = new NameFileComparator();
/** Reverse case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */
- public static final Comparator NAME_REVERSE = new ReverseComparator(NAME_COMPARATOR);
+ public static final Comparator NAME_REVERSE = new ReverseComparator(NAME_COMPARATOR);
/** Case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */
- public static final Comparator NAME_INSENSITIVE_COMPARATOR = new NameFileComparator(IOCase.INSENSITIVE);
+ public static final Comparator NAME_INSENSITIVE_COMPARATOR = new NameFileComparator(IOCase.INSENSITIVE);
/** Reverse case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */
- public static final Comparator NAME_INSENSITIVE_REVERSE = new ReverseComparator(NAME_INSENSITIVE_COMPARATOR);
+ public static final Comparator NAME_INSENSITIVE_REVERSE = new ReverseComparator(NAME_INSENSITIVE_COMPARATOR);
/** System sensitive name comparator instance (see {@link IOCase#SYSTEM}) */
- public static final Comparator NAME_SYSTEM_COMPARATOR = new NameFileComparator(IOCase.SYSTEM);
+ public static final Comparator NAME_SYSTEM_COMPARATOR = new NameFileComparator(IOCase.SYSTEM);
/** Reverse system sensitive name comparator instance (see {@link IOCase#SYSTEM}) */
- public static final Comparator NAME_SYSTEM_REVERSE = new ReverseComparator(NAME_SYSTEM_COMPARATOR);
+ public static final Comparator NAME_SYSTEM_REVERSE = new ReverseComparator(NAME_SYSTEM_COMPARATOR);
/** Whether the comparison is case sensitive. */
private final IOCase caseSensitivity;
@@ -90,7 +90,7 @@ public class NameFileComparator implements Comparator, Serializable {
/**
* Compare the names of two files with the specified case sensitivity.
- *
+ *
* @param obj1 The first file to compare
* @param obj2 The second file to compare
* @return a negative value if the first file's name
@@ -98,9 +98,7 @@ public class NameFileComparator implements Comparator, Serializable {
* same and a positive value if the first files name
* is greater than the second file.
*/
- public int compare(Object obj1, Object obj2) {
- File file1 = (File)obj1;
- File file2 = (File)obj2;
+ public int compare(File file1, File file2) {
return caseSensitivity.checkCompareTo(file1.getName(), file2.getName());
}
}
diff --git a/src/org/apache/commons/io/comparator/PathFileComparator.java b/src/org/apache/commons/io/comparator/PathFileComparator.java
index 0b28b6960..e93113825 100644
--- a/src/org/apache/commons/io/comparator/PathFileComparator.java
+++ b/src/org/apache/commons/io/comparator/PathFileComparator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,25 +49,25 @@ import org.apache.commons.io.IOCase;
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
* @since Commons IO 1.4
*/
-public class PathFileComparator implements Comparator, Serializable {
+public class PathFileComparator implements Comparator, Serializable {
/** Case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */
- public static final Comparator PATH_COMPARATOR = new PathFileComparator();
+ public static final Comparator PATH_COMPARATOR = new PathFileComparator();
/** Reverse case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */
- public static final Comparator PATH_REVERSE = new ReverseComparator(PATH_COMPARATOR);
+ public static final Comparator PATH_REVERSE = new ReverseComparator(PATH_COMPARATOR);
/** Case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */
- public static final Comparator PATH_INSENSITIVE_COMPARATOR = new PathFileComparator(IOCase.INSENSITIVE);
+ public static final Comparator PATH_INSENSITIVE_COMPARATOR = new PathFileComparator(IOCase.INSENSITIVE);
/** Reverse case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */
- public static final Comparator PATH_INSENSITIVE_REVERSE = new ReverseComparator(PATH_INSENSITIVE_COMPARATOR);
+ public static final Comparator PATH_INSENSITIVE_REVERSE = new ReverseComparator(PATH_INSENSITIVE_COMPARATOR);
/** System sensitive path comparator instance (see {@link IOCase#SYSTEM}) */
- public static final Comparator PATH_SYSTEM_COMPARATOR = new PathFileComparator(IOCase.SYSTEM);
+ public static final Comparator PATH_SYSTEM_COMPARATOR = new PathFileComparator(IOCase.SYSTEM);
/** Reverse system sensitive path comparator instance (see {@link IOCase#SYSTEM}) */
- public static final Comparator PATH_SYSTEM_REVERSE = new ReverseComparator(PATH_SYSTEM_COMPARATOR);
+ public static final Comparator PATH_SYSTEM_REVERSE = new ReverseComparator(PATH_SYSTEM_COMPARATOR);
/** Whether the comparison is case sensitive. */
private final IOCase caseSensitivity;
@@ -90,18 +90,16 @@ public class PathFileComparator implements Comparator, Serializable {
/**
* Compare the paths of two files the specified case sensitivity.
- *
+ *
* @param obj1 The first file to compare
* @param obj2 The second file to compare
* @return a negative value if the first file's path
* is less than the second, zero if the paths are the
* same and a positive value if the first files path
* is greater than the second file.
- *
+ *
*/
- public int compare(Object obj1, Object obj2) {
- File file1 = (File)obj1;
- File file2 = (File)obj2;
+ public int compare(File file1, File file2) {
return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath());
}
}
diff --git a/src/org/apache/commons/io/comparator/ReverseComparator.java b/src/org/apache/commons/io/comparator/ReverseComparator.java
index af9749ee3..ab0b38caa 100644
--- a/src/org/apache/commons/io/comparator/ReverseComparator.java
+++ b/src/org/apache/commons/io/comparator/ReverseComparator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,16 +26,16 @@ import java.util.Comparator;
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
* @since Commons IO 1.4
*/
-class ReverseComparator implements Comparator, Serializable {
+class ReverseComparator implements Comparator, Serializable {
- private final Comparator delegate;
+ private final Comparator delegate;
/**
* Construct an instance with the sepecified delegate {@link Comparator}.
*
* @param delegate The comparator to delegate to
*/
- public ReverseComparator(Comparator delegate) {
+ public ReverseComparator(Comparator delegate) {
if (delegate == null) {
throw new IllegalArgumentException("Delegate comparator is missing");
}
@@ -44,13 +44,13 @@ class ReverseComparator implements Comparator, Serializable {
/**
* Compare using the delegate Comparator, but reversing the result.
- *
+ *
* @param obj1 The first object to compare
* @param obj2 The second object to compare
* @return the result from the delegate {@link Comparator#compare(Object, Object)}
* reversing the value (i.e. positive becomes negative and vice versa)
*/
- public int compare(Object obj1, Object obj2) {
+ public int compare(T obj1, T obj2) {
return delegate.compare(obj2, obj1); // parameters switched round
}
diff --git a/src/org/apache/commons/io/comparator/SizeFileComparator.java b/src/org/apache/commons/io/comparator/SizeFileComparator.java
index a1621671c..609c159c9 100644
--- a/src/org/apache/commons/io/comparator/SizeFileComparator.java
+++ b/src/org/apache/commons/io/comparator/SizeFileComparator.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,25 +49,25 @@ import org.apache.commons.io.FileUtils;
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
* @since Commons IO 1.4
*/
-public class SizeFileComparator implements Comparator, Serializable {
+public class SizeFileComparator implements Comparator, Serializable {
/** Size comparator instance - directories are treated as zero size */
- public static final Comparator SIZE_COMPARATOR = new SizeFileComparator();
+ public static final Comparator SIZE_COMPARATOR = new SizeFileComparator();
/** Reverse size comparator instance - directories are treated as zero size */
- public static final Comparator SIZE_REVERSE = new ReverseComparator(SIZE_COMPARATOR);
+ public static final Comparator SIZE_REVERSE = new ReverseComparator(SIZE_COMPARATOR);
/**
* Size comparator instance which sums the size of a directory's contents
* using {@link FileUtils#sizeOfDirectory(File)}
*/
- public static final Comparator SIZE_SUMDIR_COMPARATOR = new SizeFileComparator(true);
+ public static final Comparator SIZE_SUMDIR_COMPARATOR = new SizeFileComparator(true);
/**
* Reverse size comparator instance which sums the size of a directory's contents
* using {@link FileUtils#sizeOfDirectory(File)}
*/
- public static final Comparator SIZE_SUMDIR_REVERSE = new ReverseComparator(SIZE_SUMDIR_COMPARATOR);
+ public static final Comparator SIZE_SUMDIR_REVERSE = new ReverseComparator(SIZE_SUMDIR_COMPARATOR);
/** Whether the sum of the directory's contents should be calculated. */
private final boolean sumDirectoryContents;
@@ -96,18 +96,16 @@ public class SizeFileComparator implements Comparator, Serializable {
/**
* Compare the length of two files.
- *
+ *
* @param obj1 The first file to compare
* @param obj2 The second file to compare
* @return a negative value if the first file's length
* is less than the second, zero if the lengths are the
* same and a positive value if the first files length
* is greater than the second file.
- *
+ *
*/
- public int compare(Object obj1, Object obj2) {
- File file1 = (File)obj1;
- File file2 = (File)obj2;
+ public int compare(File file1, File file2) {
long size1 = 0;
if (file1.isDirectory()) {
size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0;
diff --git a/src/org/apache/commons/io/filefilter/AndFileFilter.java b/src/org/apache/commons/io/filefilter/AndFileFilter.java
index deda11f93..9f3bb06ae 100644
--- a/src/org/apache/commons/io/filefilter/AndFileFilter.java
+++ b/src/org/apache/commons/io/filefilter/AndFileFilter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,7 +40,7 @@ public class AndFileFilter
implements ConditionalFileFilter, Serializable {
/** The list of file filters. */
- private List fileFilters;
+ private List fileFilters;
/**
* Constructs a new instance of AndFileFilter
.
@@ -48,7 +48,7 @@ public class AndFileFilter
* @since Commons IO 1.1
*/
public AndFileFilter() {
- this.fileFilters = new ArrayList();
+ this.fileFilters = new ArrayList();
}
/**
@@ -58,11 +58,11 @@ public class AndFileFilter
* @param fileFilters a List of IOFileFilter instances, copied, null ignored
* @since Commons IO 1.1
*/
- public AndFileFilter(final List fileFilters) {
+ public AndFileFilter(final List fileFilters) {
if (fileFilters == null) {
- this.fileFilters = new ArrayList();
+ this.fileFilters = new ArrayList();
} else {
- this.fileFilters = new ArrayList(fileFilters);
+ this.fileFilters = new ArrayList(fileFilters);
}
}
@@ -77,7 +77,7 @@ public class AndFileFilter
if (filter1 == null || filter2 == null) {
throw new IllegalArgumentException("The filters must not be null");
}
- this.fileFilters = new ArrayList();
+ this.fileFilters = new ArrayList();
addFileFilter(filter1);
addFileFilter(filter2);
}
@@ -92,7 +92,7 @@ public class AndFileFilter
/**
* {@inheritDoc}
*/
- public List getFileFilters() {
+ public List getFileFilters() {
return Collections.unmodifiableList(this.fileFilters);
}
@@ -106,19 +106,21 @@ public class AndFileFilter
/**
* {@inheritDoc}
*/
- public void setFileFilters(final List fileFilters) {
- this.fileFilters = new ArrayList(fileFilters);
+ @Override
+ public void setFileFilters(final List fileFilters) {
+ this.fileFilters = new ArrayList(fileFilters);
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean accept(final File file) {
if (this.fileFilters.size() == 0) {
return false;
}
- for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
- IOFileFilter fileFilter = (IOFileFilter) iter.next();
+ for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
+ IOFileFilter fileFilter = iter.next();
if (!fileFilter.accept(file)) {
return false;
}
@@ -129,12 +131,13 @@ public class AndFileFilter
/**
* {@inheritDoc}
*/
+ @Override
public boolean accept(final File file, final String name) {
if (this.fileFilters.size() == 0) {
return false;
}
- for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
- IOFileFilter fileFilter = (IOFileFilter) iter.next();
+ for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
+ IOFileFilter fileFilter = iter.next();
if (!fileFilter.accept(file, name)) {
return false;
}
@@ -147,6 +150,7 @@ public class AndFileFilter
*
* @return a String representaion
*/
+ @Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
diff --git a/src/org/apache/commons/io/filefilter/ConditionalFileFilter.java b/src/org/apache/commons/io/filefilter/ConditionalFileFilter.java
index ce1419ee8..b1c481368 100644
--- a/src/org/apache/commons/io/filefilter/ConditionalFileFilter.java
+++ b/src/org/apache/commons/io/filefilter/ConditionalFileFilter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@ public interface ConditionalFileFilter {
* @return the file filter list
* @since Commons IO 1.1
*/
- public List getFileFilters();
+ public List getFileFilters();
/**
* Removes the specified file filter.
@@ -62,6 +62,6 @@ public interface ConditionalFileFilter {
* @param fileFilters the list of filters
* @since Commons IO 1.1
*/
- public void setFileFilters(List fileFilters);
+ public void setFileFilters(List fileFilters);
}
diff --git a/src/org/apache/commons/io/filefilter/NameFileFilter.java b/src/org/apache/commons/io/filefilter/NameFileFilter.java
index fa1c80f73..19fe380e1 100644
--- a/src/org/apache/commons/io/filefilter/NameFileFilter.java
+++ b/src/org/apache/commons/io/filefilter/NameFileFilter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ import org.apache.commons.io.IOCase;
/**
* Filters filenames for a certain name.
*
- * For example, to print all files and directories in the
+ * For example, to print all files and directories in the
* current directory whose name is Test
:
*
*
@@ -38,14 +38,14 @@ import org.apache.commons.io.IOCase;
*
* @since Commons IO 1.0
* @version $Revision: 606381 $ $Date: 2007-12-22 02:03:16 +0000 (Sat, 22 Dec 2007) $
- *
+ *
* @author Stephen Colebourne
* @author Federico Barbieri
* @author Serge Knystautas
* @author Peter Donald
*/
public class NameFileFilter extends AbstractFileFilter implements Serializable {
-
+
/** The filenames to search for */
private final String[] names;
/** Whether the comparison is case sensitive. */
@@ -53,7 +53,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
/**
* Constructs a new case-sensitive name file filter for a single name.
- *
+ *
* @param name the name to allow, must not be null
* @throws IllegalArgumentException if the name is null
*/
@@ -81,7 +81,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
*
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
- *
+ *
* @param names the names to allow, must not be null
* @throws IllegalArgumentException if the names array is null
*/
@@ -94,7 +94,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
*
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
- *
+ *
* @param names the names to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the names array is null
@@ -109,38 +109,39 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
/**
* Constructs a new case-sensitive name file filter for a list of names.
- *
+ *
* @param names the names to allow, must not be null
* @throws IllegalArgumentException if the name list is null
* @throws ClassCastException if the list does not contain Strings
*/
- public NameFileFilter(List names) {
+ public NameFileFilter(List names) {
this(names, null);
}
/**
* Constructs a new name file filter for a list of names specifying case-sensitivity.
- *
+ *
* @param names the names to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the name list is null
* @throws ClassCastException if the list does not contain Strings
*/
- public NameFileFilter(List names, IOCase caseSensitivity) {
+ public NameFileFilter(List names, IOCase caseSensitivity) {
if (names == null) {
throw new IllegalArgumentException("The list of names must not be null");
}
- this.names = (String[]) names.toArray(new String[names.size()]);
+ this.names = names.toArray(new String[names.size()]);
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
}
//-----------------------------------------------------------------------
/**
* Checks to see if the filename matches.
- *
+ *
* @param file the File to check
* @return true if the filename matches
*/
+ @Override
public boolean accept(File file) {
String name = file.getName();
for (int i = 0; i < this.names.length; i++) {
@@ -153,11 +154,12 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
/**
* Checks to see if the filename matches.
- *
+ *
* @param file the File directory
* @param name the filename
* @return true if the filename matches
*/
+ @Override
public boolean accept(File file, String name) {
for (int i = 0; i < names.length; i++) {
if (caseSensitivity.checkEquals(name, names[i])) {
@@ -172,6 +174,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
*
* @return a String representaion
*/
+ @Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
diff --git a/src/org/apache/commons/io/filefilter/OrFileFilter.java b/src/org/apache/commons/io/filefilter/OrFileFilter.java
index 59cc0f2b0..520eefa4f 100644
--- a/src/org/apache/commons/io/filefilter/OrFileFilter.java
+++ b/src/org/apache/commons/io/filefilter/OrFileFilter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,7 +40,7 @@ public class OrFileFilter
implements ConditionalFileFilter, Serializable {
/** The list of file filters. */
- private List fileFilters;
+ private List fileFilters;
/**
* Constructs a new instance of OrFileFilter
.
@@ -48,7 +48,7 @@ public class OrFileFilter
* @since Commons IO 1.1
*/
public OrFileFilter() {
- this.fileFilters = new ArrayList();
+ this.fileFilters = new ArrayList();
}
/**
@@ -58,17 +58,17 @@ public class OrFileFilter
* @param fileFilters the file filters for this filter, copied, null ignored
* @since Commons IO 1.1
*/
- public OrFileFilter(final List fileFilters) {
+ public OrFileFilter(final List fileFilters) {
if (fileFilters == null) {
- this.fileFilters = new ArrayList();
+ this.fileFilters = new ArrayList();
} else {
- this.fileFilters = new ArrayList(fileFilters);
+ this.fileFilters = new ArrayList(fileFilters);
}
}
/**
* Constructs a new file filter that ORs the result of two other filters.
- *
+ *
* @param filter1 the first filter, must not be null
* @param filter2 the second filter, must not be null
* @throws IllegalArgumentException if either filter is null
@@ -77,7 +77,7 @@ public class OrFileFilter
if (filter1 == null || filter2 == null) {
throw new IllegalArgumentException("The filters must not be null");
}
- this.fileFilters = new ArrayList();
+ this.fileFilters = new ArrayList();
addFileFilter(filter1);
addFileFilter(filter2);
}
@@ -92,7 +92,7 @@ public class OrFileFilter
/**
* {@inheritDoc}
*/
- public List getFileFilters() {
+ public List getFileFilters() {
return Collections.unmodifiableList(this.fileFilters);
}
@@ -106,16 +106,17 @@ public class OrFileFilter
/**
* {@inheritDoc}
*/
- public void setFileFilters(final List fileFilters) {
+ public void setFileFilters(final List fileFilters) {
this.fileFilters = fileFilters;
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean accept(final File file) {
- for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
- IOFileFilter fileFilter = (IOFileFilter) iter.next();
+ for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
+ IOFileFilter fileFilter = iter.next();
if (fileFilter.accept(file)) {
return true;
}
@@ -126,9 +127,10 @@ public class OrFileFilter
/**
* {@inheritDoc}
*/
+ @Override
public boolean accept(final File file, final String name) {
- for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
- IOFileFilter fileFilter = (IOFileFilter) iter.next();
+ for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
+ IOFileFilter fileFilter = iter.next();
if (fileFilter.accept(file, name)) {
return true;
}
@@ -141,6 +143,7 @@ public class OrFileFilter
*
* @return a String representaion
*/
+ @Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
diff --git a/src/org/apache/commons/io/filefilter/PrefixFileFilter.java b/src/org/apache/commons/io/filefilter/PrefixFileFilter.java
index 0b6fcb961..8c6b737fb 100644
--- a/src/org/apache/commons/io/filefilter/PrefixFileFilter.java
+++ b/src/org/apache/commons/io/filefilter/PrefixFileFilter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ import org.apache.commons.io.IOCase;
/**
* Filters filenames for a certain prefix.
*
- * For example, to print all files and directories in the
+ * For example, to print all files and directories in the
* current directory whose name starts with Test
:
*
*
@@ -38,14 +38,14 @@ import org.apache.commons.io.IOCase;
*
* @since Commons IO 1.0
* @version $Revision: 606381 $ $Date: 2007-12-22 02:03:16 +0000 (Sat, 22 Dec 2007) $
- *
+ *
* @author Stephen Colebourne
* @author Federico Barbieri
* @author Serge Knystautas
* @author Peter Donald
*/
public class PrefixFileFilter extends AbstractFileFilter implements Serializable {
-
+
/** The filename prefixes to search for */
private final String[] prefixes;
@@ -54,7 +54,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
/**
* Constructs a new Prefix file filter for a single prefix.
- *
+ *
* @param prefix the prefix to allow, must not be null
* @throws IllegalArgumentException if the prefix is null
*/
@@ -63,9 +63,9 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
}
/**
- * Constructs a new Prefix file filter for a single prefix
+ * Constructs a new Prefix file filter for a single prefix
* specifying case-sensitivity.
- *
+ *
* @param prefix the prefix to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the prefix is null
@@ -84,7 +84,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
*
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
- *
+ *
* @param prefixes the prefixes to allow, must not be null
* @throws IllegalArgumentException if the prefix array is null
*/
@@ -98,7 +98,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
*
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
- *
+ *
* @param prefixes the prefixes to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the prefix is null
@@ -114,39 +114,40 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
/**
* Constructs a new Prefix file filter for a list of prefixes.
- *
+ *
* @param prefixes the prefixes to allow, must not be null
* @throws IllegalArgumentException if the prefix list is null
* @throws ClassCastException if the list does not contain Strings
*/
- public PrefixFileFilter(List prefixes) {
+ public PrefixFileFilter(List prefixes) {
this(prefixes, IOCase.SENSITIVE);
}
/**
* Constructs a new Prefix file filter for a list of prefixes
* specifying case-sensitivity.
- *
+ *
* @param prefixes the prefixes to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the prefix list is null
* @throws ClassCastException if the list does not contain Strings
* @since Commons IO 1.4
*/
- public PrefixFileFilter(List prefixes, IOCase caseSensitivity) {
+ public PrefixFileFilter(List prefixes, IOCase caseSensitivity) {
if (prefixes == null) {
throw new IllegalArgumentException("The list of prefixes must not be null");
}
- this.prefixes = (String[]) prefixes.toArray(new String[prefixes.size()]);
+ this.prefixes = prefixes.toArray(new String[prefixes.size()]);
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
}
/**
* Checks to see if the filename starts with the prefix.
- *
+ *
* @param file the File to check
* @return true if the filename starts with one of our prefixes
*/
+ @Override
public boolean accept(File file) {
String name = file.getName();
for (int i = 0; i < this.prefixes.length; i++) {
@@ -156,14 +157,15 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
}
return false;
}
-
+
/**
* Checks to see if the filename starts with the prefix.
- *
+ *
* @param file the File directory
* @param name the filename
* @return true if the filename starts with one of our prefixes
*/
+ @Override
public boolean accept(File file, String name) {
for (int i = 0; i < prefixes.length; i++) {
if (caseSensitivity.checkStartsWith(name, prefixes[i])) {
@@ -178,6 +180,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
*
* @return a String representaion
*/
+ @Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
@@ -193,5 +196,5 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
buffer.append(")");
return buffer.toString();
}
-
+
}
diff --git a/src/org/apache/commons/io/filefilter/SuffixFileFilter.java b/src/org/apache/commons/io/filefilter/SuffixFileFilter.java
index bee34402c..8bdf781a4 100644
--- a/src/org/apache/commons/io/filefilter/SuffixFileFilter.java
+++ b/src/org/apache/commons/io/filefilter/SuffixFileFilter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,7 @@ import org.apache.commons.io.IOCase;
* Filters files based on the suffix (what the filename ends with).
* This is used in retrieving all the files of a particular type.
*
- * For example, to retrieve and print all *.java
files
+ * For example, to retrieve and print all *.java
files
* in the current directory:
*
*
@@ -39,14 +39,14 @@ import org.apache.commons.io.IOCase;
*
* @since Commons IO 1.0
* @version $Revision: 606381 $ $Date: 2007-12-22 02:03:16 +0000 (Sat, 22 Dec 2007) $
- *
+ *
* @author Stephen Colebourne
* @author Federico Barbieri
* @author Serge Knystautas
* @author Peter Donald
*/
public class SuffixFileFilter extends AbstractFileFilter implements Serializable {
-
+
/** The filename suffixes to search for */
private final String[] suffixes;
@@ -55,7 +55,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
/**
* Constructs a new Suffix file filter for a single extension.
- *
+ *
* @param suffix the suffix to allow, must not be null
* @throws IllegalArgumentException if the suffix is null
*/
@@ -85,7 +85,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
*
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
- *
+ *
* @param suffixes the suffixes to allow, must not be null
* @throws IllegalArgumentException if the suffix array is null
*/
@@ -99,7 +99,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
*
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
- *
+ *
* @param suffixes the suffixes to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the suffix array is null
@@ -115,39 +115,40 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
/**
* Constructs a new Suffix file filter for a list of suffixes.
- *
+ *
* @param suffixes the suffixes to allow, must not be null
* @throws IllegalArgumentException if the suffix list is null
* @throws ClassCastException if the list does not contain Strings
*/
- public SuffixFileFilter(List suffixes) {
+ public SuffixFileFilter(List suffixes) {
this(suffixes, IOCase.SENSITIVE);
}
/**
* Constructs a new Suffix file filter for a list of suffixes
* specifying case-sensitivity.
- *
+ *
* @param suffixes the suffixes to allow, must not be null
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
* @throws IllegalArgumentException if the suffix list is null
* @throws ClassCastException if the list does not contain Strings
* @since Commons IO 1.4
*/
- public SuffixFileFilter(List suffixes, IOCase caseSensitivity) {
+ public SuffixFileFilter(List suffixes, IOCase caseSensitivity) {
if (suffixes == null) {
throw new IllegalArgumentException("The list of suffixes must not be null");
}
- this.suffixes = (String[]) suffixes.toArray(new String[suffixes.size()]);
+ this.suffixes = suffixes.toArray(new String[suffixes.size()]);
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
}
/**
* Checks to see if the filename ends with the suffix.
- *
+ *
* @param file the File to check
* @return true if the filename ends with one of our suffixes
*/
+ @Override
public boolean accept(File file) {
String name = file.getName();
for (int i = 0; i < this.suffixes.length; i++) {
@@ -157,14 +158,15 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
}
return false;
}
-
+
/**
* Checks to see if the filename ends with the suffix.
- *
+ *
* @param file the File directory
* @param name the filename
* @return true if the filename ends with one of our suffixes
*/
+ @Override
public boolean accept(File file, String name) {
for (int i = 0; i < this.suffixes.length; i++) {
if (caseSensitivity.checkEndsWith(name, suffixes[i])) {
@@ -179,6 +181,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
*
* @return a String representaion
*/
+ @Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
@@ -194,5 +197,5 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
buffer.append(")");
return buffer.toString();
}
-
+
}
diff --git a/src/org/apache/commons/io/filefilter/WildcardFileFilter.java b/src/org/apache/commons/io/filefilter/WildcardFileFilter.java
index 791fe985b..f3a1ee930 100644
--- a/src/org/apache/commons/io/filefilter/WildcardFileFilter.java
+++ b/src/org/apache/commons/io/filefilter/WildcardFileFilter.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -119,7 +119,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
* @throws IllegalArgumentException if the pattern list is null
* @throws ClassCastException if the list does not contain Strings
*/
- public WildcardFileFilter(List wildcards) {
+ public WildcardFileFilter(List wildcards) {
this(wildcards, null);
}
@@ -131,11 +131,11 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
* @throws IllegalArgumentException if the pattern list is null
* @throws ClassCastException if the list does not contain Strings
*/
- public WildcardFileFilter(List wildcards, IOCase caseSensitivity) {
+ public WildcardFileFilter(List wildcards, IOCase caseSensitivity) {
if (wildcards == null) {
throw new IllegalArgumentException("The wildcard list must not be null");
}
- this.wildcards = (String[]) wildcards.toArray(new String[wildcards.size()]);
+ this.wildcards = wildcards.toArray(new String[wildcards.size()]);
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
}
@@ -147,6 +147,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
* @param name the filename
* @return true if the filename matches one of the wildcards
*/
+ @Override
public boolean accept(File dir, String name) {
for (int i = 0; i < wildcards.length; i++) {
if (FilenameUtils.wildcardMatch(name, wildcards[i], caseSensitivity)) {
@@ -162,6 +163,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
* @param file the file to check
* @return true if the filename matches one of the wildcards
*/
+ @Override
public boolean accept(File file) {
String name = file.getName();
for (int i = 0; i < wildcards.length; i++) {
@@ -177,6 +179,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
*
* @return a String representaion
*/
+ @Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
diff --git a/src/org/apache/commons/io/filefilter/WildcardFilter.java b/src/org/apache/commons/io/filefilter/WildcardFilter.java
deleted file mode 100644
index 2a6e0dde0..000000000
--- a/src/org/apache/commons/io/filefilter/WildcardFilter.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.io.filefilter;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.List;
-
-import org.apache.commons.io.FilenameUtils;
-
-/**
- * Filters files using the supplied wildcards.
- *
- * This filter selects files, but not directories, based on one or more wildcards
- * and using case-sensitive comparison.
- *
- * The wildcard matcher uses the characters '?' and '*' to represent a
- * single or multiple wildcard characters.
- * This is the same as often found on Dos/Unix command lines.
- * The extension check is case-sensitive.
- * See {@link FilenameUtils#wildcardMatch} for more information.
- *
- * For example:
- *
- * File dir = new File(".");
- * FileFilter fileFilter = new WildcardFilter("*test*.java~*~");
- * File[] files = dir.listFiles(fileFilter);
- * for (int i = 0; i < files.length; i++) {
- * System.out.println(files[i]);
- * }
- *
- *
- * @author Jason Anderson
- * @version $Revision: 606381 $ $Date: 2007-12-22 02:03:16 +0000 (Sat, 22 Dec 2007) $
- * @since Commons IO 1.1
- * @deprecated Use WilcardFileFilter. Deprecated as this class performs directory
- * filtering which it shouldn't do, but that can't be removed due to compatability.
- */
-public class WildcardFilter extends AbstractFileFilter implements Serializable {
-
- /** The wildcards that will be used to match filenames. */
- private final String[] wildcards;
-
- /**
- * Construct a new case-sensitive wildcard filter for a single wildcard.
- *
- * @param wildcard the wildcard to match
- * @throws IllegalArgumentException if the pattern is null
- */
- public WildcardFilter(String wildcard) {
- if (wildcard == null) {
- throw new IllegalArgumentException("The wildcard must not be null");
- }
- this.wildcards = new String[] { wildcard };
- }
-
- /**
- * Construct a new case-sensitive wildcard filter for an array of wildcards.
- *
- * @param wildcards the array of wildcards to match
- * @throws IllegalArgumentException if the pattern array is null
- */
- public WildcardFilter(String[] wildcards) {
- if (wildcards == null) {
- throw new IllegalArgumentException("The wildcard array must not be null");
- }
- this.wildcards = wildcards;
- }
-
- /**
- * Construct a new case-sensitive wildcard filter for a list of wildcards.
- *
- * @param wildcards the list of wildcards to match
- * @throws IllegalArgumentException if the pattern list is null
- * @throws ClassCastException if the list does not contain Strings
- */
- public WildcardFilter(List wildcards) {
- if (wildcards == null) {
- throw new IllegalArgumentException("The wildcard list must not be null");
- }
- this.wildcards = (String[]) wildcards.toArray(new String[wildcards.size()]);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Checks to see if the filename matches one of the wildcards.
- *
- * @param dir the file directory
- * @param name the filename
- * @return true if the filename matches one of the wildcards
- */
- public boolean accept(File dir, String name) {
- if (dir != null && new File(dir, name).isDirectory()) {
- return false;
- }
-
- for (int i = 0; i < wildcards.length; i++) {
- if (FilenameUtils.wildcardMatch(name, wildcards[i])) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Checks to see if the filename matches one of the wildcards.
- *
- * @param file the file to check
- * @return true if the filename matches one of the wildcards
- */
- public boolean accept(File file) {
- if (file.isDirectory()) {
- return false;
- }
-
- for (int i = 0; i < wildcards.length; i++) {
- if (FilenameUtils.wildcardMatch(file.getName(), wildcards[i])) {
- return true;
- }
- }
-
- return false;
- }
-
-}
diff --git a/src/org/apache/commons/io/input/DemuxInputStream.java b/src/org/apache/commons/io/input/DemuxInputStream.java
index 1ae888916..64b41c4d4 100644
--- a/src/org/apache/commons/io/input/DemuxInputStream.java
+++ b/src/org/apache/commons/io/input/DemuxInputStream.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@ import java.io.InputStream;
public class DemuxInputStream
extends InputStream
{
- private InheritableThreadLocal m_streams = new InheritableThreadLocal();
+ private InheritableThreadLocal m_streams = new InheritableThreadLocal();
/**
* Bind the specified stream to the current thread.
@@ -49,6 +49,7 @@ public class DemuxInputStream
*
* @throws IOException if an error occurs
*/
+ @Override
public void close()
throws IOException
{
@@ -65,6 +66,7 @@ public class DemuxInputStream
* @return the byte read from stream
* @throws IOException if an error occurs
*/
+ @Override
public int read()
throws IOException
{
@@ -86,6 +88,6 @@ public class DemuxInputStream
*/
private InputStream getStream()
{
- return (InputStream)m_streams.get();
+ return m_streams.get();
}
}
diff --git a/src/org/apache/commons/io/output/ByteArrayOutputStream.java b/src/org/apache/commons/io/output/ByteArrayOutputStream.java
index 66d5e8dc3..906a41dd4 100644
--- a/src/org/apache/commons/io/output/ByteArrayOutputStream.java
+++ b/src/org/apache/commons/io/output/ByteArrayOutputStream.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package org.apache.commons.io.output;
-
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -24,10 +24,10 @@ import java.util.ArrayList;
import java.util.List;
/**
- * This class implements an output stream in which the data is
- * written into a byte array. The buffer automatically grows as data
+ * This class implements an output stream in which the data is
+ * written into a byte array. The buffer automatically grows as data
* is written to it.
- *
+ *
* The data can be retrieved using toByteArray()
and
* toString()
.
*
@@ -43,7 +43,7 @@ import java.util.List;
* the contents don't have to be copied to the new buffer. This class is
* designed to behave exactly like the original. The only exception is the
* deprecated toString(int) method that has been ignored.
- *
+ *
* @author Jeremias Maerki
* @author Holger Hoffstatte
* @version $Id: ByteArrayOutputStream.java 610010 2008-01-08 14:50:59Z niallp $
@@ -54,7 +54,7 @@ public class ByteArrayOutputStream extends OutputStream {
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
/** The list of buffers, which grows and never reduces. */
- private List buffers = new ArrayList();
+ private List buffers = new ArrayList();
/** The index of the current buffer. */
private int currentBufferIndex;
/** The total count of bytes in all the filled buffers. */
@@ -65,16 +65,16 @@ public class ByteArrayOutputStream extends OutputStream {
private int count;
/**
- * Creates a new byte array output stream. The buffer capacity is
- * initially 1024 bytes, though its size increases if necessary.
+ * Creates a new byte array output stream. The buffer capacity is
+ * initially 1024 bytes, though its size increases if necessary.
*/
public ByteArrayOutputStream() {
this(1024);
}
/**
- * Creates a new byte array output stream, with a buffer capacity of
- * the specified size, in bytes.
+ * Creates a new byte array output stream, with a buffer capacity of
+ * the specified size, in bytes.
*
* @param size the initial size
* @throws IllegalArgumentException if size is negative
@@ -88,14 +88,14 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
- * Return the appropriate byte[]
buffer
+ * Return the appropriate byte[]
buffer
* specified by index.
*
* @param index the index of the buffer required
* @return the buffer
*/
private byte[] getBuffer(int index) {
- return (byte[]) buffers.get(index);
+ return buffers.get(index);
}
/**
@@ -108,7 +108,7 @@ public class ByteArrayOutputStream extends OutputStream {
if (currentBufferIndex < buffers.size() - 1) {
//Recycling old buffer
filledBufferSum += currentBuffer.length;
-
+
currentBufferIndex++;
currentBuffer = getBuffer(currentBufferIndex);
} else {
@@ -119,11 +119,11 @@ public class ByteArrayOutputStream extends OutputStream {
filledBufferSum = 0;
} else {
newBufferSize = Math.max(
- currentBuffer.length << 1,
+ currentBuffer.length << 1,
newcount - filledBufferSum);
filledBufferSum += currentBuffer.length;
}
-
+
currentBufferIndex++;
currentBuffer = new byte[newBufferSize];
buffers.add(currentBuffer);
@@ -136,11 +136,12 @@ public class ByteArrayOutputStream extends OutputStream {
* @param off The start offset
* @param len The number of bytes to write
*/
+ @Override
public void write(byte[] b, int off, int len) {
- if ((off < 0)
- || (off > b.length)
- || (len < 0)
- || ((off + len) > b.length)
+ if ((off < 0)
+ || (off > b.length)
+ || (len < 0)
+ || ((off + len) > b.length)
|| ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
@@ -167,6 +168,7 @@ public class ByteArrayOutputStream extends OutputStream {
* Write a byte to byte array.
* @param b the byte to write
*/
+ @Override
public synchronized void write(int b) {
int inBufferPos = count - filledBufferSum;
if (inBufferPos == currentBuffer.length) {
@@ -221,6 +223,7 @@ public class ByteArrayOutputStream extends OutputStream {
* @throws IOException never (this method should not declare this exception
* but it has to now due to backwards compatability)
*/
+ @Override
public void close() throws IOException {
//nop
}
@@ -266,7 +269,7 @@ public class ByteArrayOutputStream extends OutputStream {
public synchronized byte[] toByteArray() {
int remaining = count;
if (remaining == 0) {
- return EMPTY_BYTE_ARRAY;
+ return EMPTY_BYTE_ARRAY;
}
byte newbuf[] = new byte[remaining];
int pos = 0;
@@ -288,6 +291,7 @@ public class ByteArrayOutputStream extends OutputStream {
* @return the contents of the byte array as a String
* @see java.io.ByteArrayOutputStream#toString()
*/
+ @Override
public String toString() {
return new String(toByteArray());
}
diff --git a/src/org/apache/commons/io/output/DemuxOutputStream.java b/src/org/apache/commons/io/output/DemuxOutputStream.java
index 086911118..280df14d3 100644
--- a/src/org/apache/commons/io/output/DemuxOutputStream.java
+++ b/src/org/apache/commons/io/output/DemuxOutputStream.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@ import java.io.OutputStream;
public class DemuxOutputStream
extends OutputStream
{
- private InheritableThreadLocal m_streams = new InheritableThreadLocal();
+ private InheritableThreadLocal m_streams = new InheritableThreadLocal();
/**
* Bind the specified stream to the current thread.
@@ -49,6 +49,7 @@ public class DemuxOutputStream
*
* @throws IOException if an error occurs
*/
+ @Override
public void close()
throws IOException
{
@@ -64,6 +65,7 @@ public class DemuxOutputStream
*
* @throws IOException if an error occurs
*/
+ @Override
public void flush()
throws IOException
{
@@ -80,6 +82,7 @@ public class DemuxOutputStream
* @param ch the byte to write to stream
* @throws IOException if an error occurs
*/
+ @Override
public void write( int ch )
throws IOException
{
@@ -97,6 +100,6 @@ public class DemuxOutputStream
*/
private OutputStream getStream()
{
- return (OutputStream)m_streams.get();
+ return m_streams.get();
}
}