Resolve build warnings; part 1
Change-Id: I80ca98ef80a427229ab5feb41568e34b257f32ce
This commit is contained in:
parent
045f91e94f
commit
44de127691
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
package com.beetstra.jutf7;
|
package com.beetstra.jutf7;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -55,10 +54,10 @@ public class CharsetProvider extends java.nio.charset.spi.CharsetProvider {
|
||||||
private Charset utf7charset = new UTF7Charset(UTF7_NAME, UTF7_ALIASES, false);
|
private Charset utf7charset = new UTF7Charset(UTF7_NAME, UTF7_ALIASES, false);
|
||||||
private Charset utf7oCharset = new UTF7Charset(UTF7_O_NAME, UTF7_O_ALIASES, true);
|
private Charset utf7oCharset = new UTF7Charset(UTF7_O_NAME, UTF7_O_ALIASES, true);
|
||||||
private Charset imap4charset = new ModifiedUTF7Charset(UTF7_M_NAME, UTF7_M_ALIASES);
|
private Charset imap4charset = new ModifiedUTF7Charset(UTF7_M_NAME, UTF7_M_ALIASES);
|
||||||
private List charsets;
|
private List<Charset> charsets;
|
||||||
|
|
||||||
public CharsetProvider() {
|
public CharsetProvider() {
|
||||||
charsets = Arrays.asList(new Object[] {
|
charsets = Arrays.asList(new Charset[] {
|
||||||
utf7charset, imap4charset, utf7oCharset
|
utf7charset, imap4charset, utf7oCharset
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -66,15 +65,16 @@ public class CharsetProvider extends java.nio.charset.spi.CharsetProvider {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Charset charsetForName(String charsetName) {
|
public Charset charsetForName(String charsetName) {
|
||||||
charsetName = charsetName.toUpperCase();
|
charsetName = charsetName.toUpperCase();
|
||||||
for (Iterator iter = charsets.iterator(); iter.hasNext();) {
|
for (Iterator<Charset> iter = charsets.iterator(); iter.hasNext();) {
|
||||||
Charset charset = (Charset)iter.next();
|
Charset charset = iter.next();
|
||||||
if (charset.name().equals(charsetName))
|
if (charset.name().equals(charsetName))
|
||||||
return charset;
|
return charset;
|
||||||
}
|
}
|
||||||
for (Iterator iter = charsets.iterator(); iter.hasNext();) {
|
for (Iterator<Charset> iter = charsets.iterator(); iter.hasNext();) {
|
||||||
Charset charset = (Charset)iter.next();
|
Charset charset = iter.next();
|
||||||
if (charset.aliases().contains(charsetName))
|
if (charset.aliases().contains(charsetName))
|
||||||
return charset;
|
return charset;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,8 @@ public class CharsetProvider extends java.nio.charset.spi.CharsetProvider {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public Iterator charsets() {
|
@Override
|
||||||
|
public Iterator<Charset> charsets() {
|
||||||
return charsets.iterator();
|
return charsets.iterator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,11 @@ public class FileCleaningTracker {
|
||||||
/**
|
/**
|
||||||
* Queue of <code>Tracker</code> instances being watched.
|
* Queue of <code>Tracker</code> instances being watched.
|
||||||
*/
|
*/
|
||||||
ReferenceQueue /* Tracker */ q = new ReferenceQueue();
|
ReferenceQueue<Object> /* Tracker */ q = new ReferenceQueue<Object>();
|
||||||
/**
|
/**
|
||||||
* Collection of <code>Tracker</code> instances in existence.
|
* Collection of <code>Tracker</code> instances in existence.
|
||||||
*/
|
*/
|
||||||
final Collection /* Tracker */ trackers = new Vector(); // synchronized
|
final Collection<Tracker> /* Tracker */ trackers = new Vector<Tracker>(); // synchronized
|
||||||
/**
|
/**
|
||||||
* Whether to terminate the thread when the tracking is complete.
|
* Whether to terminate the thread when the tracking is complete.
|
||||||
*/
|
*/
|
||||||
|
@ -196,6 +196,7 @@ public class FileCleaningTracker {
|
||||||
* Run the reaper thread that will delete files as their associated
|
* Run the reaper thread that will delete files as their associated
|
||||||
* marker objects are reclaimed by the garbage collector.
|
* marker objects are reclaimed by the garbage collector.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// thread exits when exitWhenFinished is true and there are no more tracked objects
|
// thread exits when exitWhenFinished is true and there are no more tracked objects
|
||||||
while (exitWhenFinished == false || trackers.size() > 0) {
|
while (exitWhenFinished == false || trackers.size() > 0) {
|
||||||
|
@ -219,7 +220,7 @@ public class FileCleaningTracker {
|
||||||
/**
|
/**
|
||||||
* Inner class which acts as the reference for a file pending deletion.
|
* Inner class which acts as the reference for a file pending deletion.
|
||||||
*/
|
*/
|
||||||
private static final class Tracker extends PhantomReference {
|
private static final class Tracker extends PhantomReference<Object> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The full path to the file being tracked.
|
* The full path to the file being tracked.
|
||||||
|
@ -238,7 +239,7 @@ public class FileCleaningTracker {
|
||||||
* @param marker the marker object used to track the file, not null
|
* @param marker the marker object used to track the file, not null
|
||||||
* @param queue the queue on to which the tracker will be pushed, not null
|
* @param queue the queue on to which the tracker will be pushed, not null
|
||||||
*/
|
*/
|
||||||
Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue queue) {
|
Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue<Object> queue) {
|
||||||
super(marker, queue);
|
super(marker, queue);
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy);
|
this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy);
|
||||||
|
|
|
@ -222,14 +222,14 @@ public class FileSystemUtils {
|
||||||
String[] cmdAttribs = new String[] {"cmd.exe", "/C", "dir /-c " + path};
|
String[] cmdAttribs = new String[] {"cmd.exe", "/C", "dir /-c " + path};
|
||||||
|
|
||||||
// read in the output of the command to an ArrayList
|
// read in the output of the command to an ArrayList
|
||||||
List lines = performCommand(cmdAttribs, Integer.MAX_VALUE);
|
List<String> lines = performCommand(cmdAttribs, Integer.MAX_VALUE);
|
||||||
|
|
||||||
// now iterate over the lines we just read and find the LAST
|
// now iterate over the lines we just read and find the LAST
|
||||||
// non-empty line (the free space bytes should be in the last element
|
// non-empty line (the free space bytes should be in the last element
|
||||||
// of the ArrayList anyway, but this will ensure it works even if it's
|
// of the ArrayList anyway, but this will ensure it works even if it's
|
||||||
// not, still assuming it is on the last non-blank line)
|
// not, still assuming it is on the last non-blank line)
|
||||||
for (int i = lines.size() - 1; i >= 0; i--) {
|
for (int i = lines.size() - 1; i >= 0; i--) {
|
||||||
String line = (String) lines.get(i);
|
String line = lines.get(i);
|
||||||
if (line.length() > 0) {
|
if (line.length() > 0) {
|
||||||
return parseDir(line, path);
|
return parseDir(line, path);
|
||||||
}
|
}
|
||||||
|
@ -320,21 +320,21 @@ public class FileSystemUtils {
|
||||||
(flags.length() > 1 ? new String[] {"df", flags, path} : new String[] {"df", path});
|
(flags.length() > 1 ? new String[] {"df", flags, path} : new String[] {"df", path});
|
||||||
|
|
||||||
// perform the command, asking for up to 3 lines (header, interesting, overflow)
|
// perform the command, asking for up to 3 lines (header, interesting, overflow)
|
||||||
List lines = performCommand(cmdAttribs, 3);
|
List<String> lines = performCommand(cmdAttribs, 3);
|
||||||
if (lines.size() < 2) {
|
if (lines.size() < 2) {
|
||||||
// unknown problem, throw exception
|
// unknown problem, throw exception
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"Command line 'df' did not return info as expected " +
|
"Command line 'df' did not return info as expected " +
|
||||||
"for path '" + path + "'- response was " + lines);
|
"for path '" + path + "'- response was " + lines);
|
||||||
}
|
}
|
||||||
String line2 = (String) lines.get(1); // the line we're interested in
|
String line2 = lines.get(1); // the line we're interested in
|
||||||
|
|
||||||
// Now, we tokenize the string. The fourth element is what we want.
|
// Now, we tokenize the string. The fourth element is what we want.
|
||||||
StringTokenizer tok = new StringTokenizer(line2, " ");
|
StringTokenizer tok = new StringTokenizer(line2, " ");
|
||||||
if (tok.countTokens() < 4) {
|
if (tok.countTokens() < 4) {
|
||||||
// could be long Filesystem, thus data on third line
|
// could be long Filesystem, thus data on third line
|
||||||
if (tok.countTokens() == 1 && lines.size() >= 3) {
|
if (tok.countTokens() == 1 && lines.size() >= 3) {
|
||||||
String line3 = (String) lines.get(2); // the line may be interested in
|
String line3 = lines.get(2); // the line may be interested in
|
||||||
tok = new StringTokenizer(line3, " ");
|
tok = new StringTokenizer(line3, " ");
|
||||||
} else {
|
} else {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
|
@ -385,7 +385,7 @@ public class FileSystemUtils {
|
||||||
* @return the parsed data
|
* @return the parsed data
|
||||||
* @throws IOException if an error occurs
|
* @throws IOException if an error occurs
|
||||||
*/
|
*/
|
||||||
List performCommand(String[] cmdAttribs, int max) throws IOException {
|
List<String> performCommand(String[] cmdAttribs, int max) throws IOException {
|
||||||
// this method does what it can to avoid the 'Too many open files' error
|
// this method does what it can to avoid the 'Too many open files' error
|
||||||
// based on trial and error and these links:
|
// based on trial and error and these links:
|
||||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692
|
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692
|
||||||
|
@ -394,7 +394,7 @@ public class FileSystemUtils {
|
||||||
// however, its still not perfect as the JDK support is so poor
|
// however, its still not perfect as the JDK support is so poor
|
||||||
// (see commond-exec or ant for a better multi-threaded multi-os solution)
|
// (see commond-exec or ant for a better multi-threaded multi-os solution)
|
||||||
|
|
||||||
List lines = new ArrayList(20);
|
List<String> lines = new ArrayList<String>(20);
|
||||||
Process proc = null;
|
Process proc = null;
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
|
|
|
@ -235,8 +235,8 @@ public class FileUtils {
|
||||||
* @param files a Collection containing java.io.File instances
|
* @param files a Collection containing java.io.File instances
|
||||||
* @return an array of java.io.File
|
* @return an array of java.io.File
|
||||||
*/
|
*/
|
||||||
public static File[] convertFileCollectionToFileArray(Collection files) {
|
public static File[] convertFileCollectionToFileArray(Collection<File> files) {
|
||||||
return (File[]) files.toArray(new File[files.size()]);
|
return files.toArray(new File[files.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -248,7 +248,7 @@ public class FileUtils {
|
||||||
* @param directory the directory to search in.
|
* @param directory the directory to search in.
|
||||||
* @param filter the filter to apply to files and directories.
|
* @param filter the filter to apply to files and directories.
|
||||||
*/
|
*/
|
||||||
private static void innerListFiles(Collection files, File directory,
|
private static void innerListFiles(Collection<File> files, File directory,
|
||||||
IOFileFilter filter) {
|
IOFileFilter filter) {
|
||||||
File[] found = directory.listFiles((FileFilter) filter);
|
File[] found = directory.listFiles((FileFilter) filter);
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
|
@ -287,7 +287,7 @@ public class FileUtils {
|
||||||
* @see org.apache.commons.io.filefilter.FileFilterUtils
|
* @see org.apache.commons.io.filefilter.FileFilterUtils
|
||||||
* @see org.apache.commons.io.filefilter.NameFileFilter
|
* @see org.apache.commons.io.filefilter.NameFileFilter
|
||||||
*/
|
*/
|
||||||
public static Collection listFiles(
|
public static Collection<File> listFiles(
|
||||||
File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) {
|
File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) {
|
||||||
if (!directory.isDirectory()) {
|
if (!directory.isDirectory()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
@ -311,7 +311,7 @@ public class FileUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Find files
|
//Find files
|
||||||
Collection files = new java.util.LinkedList();
|
Collection<File> files = new java.util.LinkedList<File>();
|
||||||
innerListFiles(files, directory,
|
innerListFiles(files, directory,
|
||||||
FileFilterUtils.orFileFilter(effFileFilter, effDirFilter));
|
FileFilterUtils.orFileFilter(effFileFilter, effDirFilter));
|
||||||
return files;
|
return files;
|
||||||
|
@ -334,7 +334,7 @@ public class FileUtils {
|
||||||
* @see org.apache.commons.io.filefilter.NameFileFilter
|
* @see org.apache.commons.io.filefilter.NameFileFilter
|
||||||
* @since Commons IO 1.2
|
* @since Commons IO 1.2
|
||||||
*/
|
*/
|
||||||
public static Iterator iterateFiles(
|
public static Iterator<File> iterateFiles(
|
||||||
File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) {
|
File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) {
|
||||||
return listFiles(directory, fileFilter, dirFilter).iterator();
|
return listFiles(directory, fileFilter, dirFilter).iterator();
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ public class FileUtils {
|
||||||
* @param recursive if true all subdirectories are searched as well
|
* @param recursive if true all subdirectories are searched as well
|
||||||
* @return an collection of java.io.File with the matching files
|
* @return an collection of java.io.File with the matching files
|
||||||
*/
|
*/
|
||||||
public static Collection listFiles(
|
public static Collection<File> listFiles(
|
||||||
File directory, String[] extensions, boolean recursive) {
|
File directory, String[] extensions, boolean recursive) {
|
||||||
IOFileFilter filter;
|
IOFileFilter filter;
|
||||||
if (extensions == null) {
|
if (extensions == null) {
|
||||||
|
@ -391,7 +391,7 @@ public class FileUtils {
|
||||||
* @return an iterator of java.io.File with the matching files
|
* @return an iterator of java.io.File with the matching files
|
||||||
* @since Commons IO 1.2
|
* @since Commons IO 1.2
|
||||||
*/
|
*/
|
||||||
public static Iterator iterateFiles(
|
public static Iterator<File> iterateFiles(
|
||||||
File directory, String[] extensions, boolean recursive) {
|
File directory, String[] extensions, boolean recursive) {
|
||||||
return listFiles(directory, extensions, recursive).iterator();
|
return listFiles(directory, extensions, recursive).iterator();
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ public class FileUtils {
|
||||||
URL[] urls = new URL[files.length];
|
URL[] urls = new URL[files.length];
|
||||||
|
|
||||||
for (int i = 0; i < urls.length; i++) {
|
for (int i = 0; i < urls.length; i++) {
|
||||||
urls[i] = files[i].toURL();
|
urls[i] = files[i].toURI().toURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
return urls;
|
return urls;
|
||||||
|
@ -873,11 +873,11 @@ public class FileUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cater for destination being directory within the source directory (see IO-141)
|
// Cater for destination being directory within the source directory (see IO-141)
|
||||||
List exclusionList = null;
|
List<String> exclusionList = null;
|
||||||
if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) {
|
if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) {
|
||||||
File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter);
|
File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter);
|
||||||
if (srcFiles != null && srcFiles.length > 0) {
|
if (srcFiles != null && srcFiles.length > 0) {
|
||||||
exclusionList = new ArrayList(srcFiles.length);
|
exclusionList = new ArrayList<String>(srcFiles.length);
|
||||||
for (int i = 0; i < srcFiles.length; i++) {
|
for (int i = 0; i < srcFiles.length; i++) {
|
||||||
File copiedFile = new File(destDir, srcFiles[i].getName());
|
File copiedFile = new File(destDir, srcFiles[i].getName());
|
||||||
exclusionList.add(copiedFile.getCanonicalPath());
|
exclusionList.add(copiedFile.getCanonicalPath());
|
||||||
|
@ -899,7 +899,7 @@ public class FileUtils {
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
private static void doCopyDirectory(File srcDir, File destDir, FileFilter filter,
|
private static void doCopyDirectory(File srcDir, File destDir, FileFilter filter,
|
||||||
boolean preserveFileDate, List exclusionList) throws IOException {
|
boolean preserveFileDate, List<String> exclusionList) throws IOException {
|
||||||
if (destDir.exists()) {
|
if (destDir.exists()) {
|
||||||
if (destDir.isDirectory() == false) {
|
if (destDir.isDirectory() == false) {
|
||||||
throw new IOException("Destination '" + destDir + "' exists but is not a directory");
|
throw new IOException("Destination '" + destDir + "' exists but is not a directory");
|
||||||
|
@ -1150,7 +1150,7 @@ public class FileUtils {
|
||||||
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
|
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public static List readLines(File file, String encoding) throws IOException {
|
public static List<String> readLines(File file, String encoding) throws IOException {
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
in = openInputStream(file);
|
in = openInputStream(file);
|
||||||
|
@ -1169,7 +1169,7 @@ public class FileUtils {
|
||||||
* @throws IOException in case of an I/O error
|
* @throws IOException in case of an I/O error
|
||||||
* @since Commons IO 1.3
|
* @since Commons IO 1.3
|
||||||
*/
|
*/
|
||||||
public static List readLines(File file) throws IOException {
|
public static List<String> readLines(File file) throws IOException {
|
||||||
return readLines(file, null);
|
return readLines(file, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1301,7 +1301,7 @@ public class FileUtils {
|
||||||
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
|
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
|
||||||
* @since Commons IO 1.1
|
* @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<Object> lines) throws IOException {
|
||||||
writeLines(file, encoding, lines, null);
|
writeLines(file, encoding, lines, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1315,7 +1315,7 @@ public class FileUtils {
|
||||||
* @throws IOException in case of an I/O error
|
* @throws IOException in case of an I/O error
|
||||||
* @since Commons IO 1.3
|
* @since Commons IO 1.3
|
||||||
*/
|
*/
|
||||||
public static void writeLines(File file, Collection lines) throws IOException {
|
public static void writeLines(File file, Collection<Object> lines) throws IOException {
|
||||||
writeLines(file, null, lines, null);
|
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
|
* @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM
|
||||||
* @since Commons IO 1.1
|
* @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<Object> lines, String lineEnding) throws IOException {
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
try {
|
try {
|
||||||
out = openOutputStream(file);
|
out = openOutputStream(file);
|
||||||
|
@ -1356,7 +1356,7 @@ public class FileUtils {
|
||||||
* @throws IOException in case of an I/O error
|
* @throws IOException in case of an I/O error
|
||||||
* @since Commons IO 1.3
|
* @since Commons IO 1.3
|
||||||
*/
|
*/
|
||||||
public static void writeLines(File file, Collection lines, String lineEnding) throws IOException {
|
public static void writeLines(File file, Collection<Object> lines, String lineEnding) throws IOException {
|
||||||
writeLines(file, null, lines, lineEnding);
|
writeLines(file, null, lines, lineEnding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1056,7 +1056,7 @@ public class FilenameUtils {
|
||||||
* @param extensions the extensions to check for, null checks for no extension
|
* @param extensions the extensions to check for, null checks for no extension
|
||||||
* @return true if the filename is one of the extensions
|
* @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<String> extensions) {
|
||||||
if (filename == null) {
|
if (filename == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1064,7 +1064,7 @@ public class FilenameUtils {
|
||||||
return (indexOfExtension(filename) == -1);
|
return (indexOfExtension(filename) == -1);
|
||||||
}
|
}
|
||||||
String fileExt = getExtension(filename);
|
String fileExt = getExtension(filename);
|
||||||
for (Iterator it = extensions.iterator(); it.hasNext();) {
|
for (Iterator<String> it = extensions.iterator(); it.hasNext();) {
|
||||||
if (fileExt.equals(it.next())) {
|
if (fileExt.equals(it.next())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1152,12 +1152,12 @@ public class FilenameUtils {
|
||||||
boolean anyChars = false;
|
boolean anyChars = false;
|
||||||
int textIdx = 0;
|
int textIdx = 0;
|
||||||
int wcsIdx = 0;
|
int wcsIdx = 0;
|
||||||
Stack backtrack = new Stack();
|
Stack<int[]> backtrack = new Stack<int[]>();
|
||||||
|
|
||||||
// loop around a backtrack stack, to handle complex * matching
|
// loop around a backtrack stack, to handle complex * matching
|
||||||
do {
|
do {
|
||||||
if (backtrack.size() > 0) {
|
if (backtrack.size() > 0) {
|
||||||
int[] array = (int[]) backtrack.pop();
|
int[] array = backtrack.pop();
|
||||||
wcsIdx = array[0];
|
wcsIdx = array[0];
|
||||||
textIdx = array[1];
|
textIdx = array[1];
|
||||||
anyChars = true;
|
anyChars = true;
|
||||||
|
@ -1232,7 +1232,7 @@ public class FilenameUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] array = text.toCharArray();
|
char[] array = text.toCharArray();
|
||||||
ArrayList list = new ArrayList();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
if (array[i] == '?' || array[i] == '*') {
|
if (array[i] == '?' || array[i] == '*') {
|
||||||
|
@ -1254,7 +1254,7 @@ public class FilenameUtils {
|
||||||
list.add(buffer.toString());
|
list.add(buffer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (String[]) list.toArray( new String[ list.size() ] );
|
return list.toArray( new String[ list.size() ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,7 +452,7 @@ public class IOUtils {
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public static List readLines(InputStream input) throws IOException {
|
public static List<String> readLines(InputStream input) throws IOException {
|
||||||
InputStreamReader reader = new InputStreamReader(input);
|
InputStreamReader reader = new InputStreamReader(input);
|
||||||
return readLines(reader);
|
return readLines(reader);
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ public class IOUtils {
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public static List readLines(InputStream input, String encoding) throws IOException {
|
public static List<String> readLines(InputStream input, String encoding) throws IOException {
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
return readLines(input);
|
return readLines(input);
|
||||||
} else {
|
} else {
|
||||||
|
@ -496,9 +496,9 @@ public class IOUtils {
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public static List readLines(Reader input) throws IOException {
|
public static List<String> readLines(Reader input) throws IOException {
|
||||||
BufferedReader reader = new BufferedReader(input);
|
BufferedReader reader = new BufferedReader(input);
|
||||||
List list = new ArrayList();
|
List<String> list = new ArrayList<String>();
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
list.add(line);
|
list.add(line);
|
||||||
|
@ -891,7 +891,7 @@ public class IOUtils {
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public static void writeLines(Collection lines, String lineEnding,
|
public static void writeLines(Collection<Object> lines, String lineEnding,
|
||||||
OutputStream output) throws IOException {
|
OutputStream output) throws IOException {
|
||||||
if (lines == null) {
|
if (lines == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -899,7 +899,7 @@ public class IOUtils {
|
||||||
if (lineEnding == null) {
|
if (lineEnding == null) {
|
||||||
lineEnding = LINE_SEPARATOR;
|
lineEnding = LINE_SEPARATOR;
|
||||||
}
|
}
|
||||||
for (Iterator it = lines.iterator(); it.hasNext(); ) {
|
for (Iterator<Object> it = lines.iterator(); it.hasNext(); ) {
|
||||||
Object line = it.next();
|
Object line = it.next();
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
output.write(line.toString().getBytes());
|
output.write(line.toString().getBytes());
|
||||||
|
@ -924,7 +924,7 @@ public class IOUtils {
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public static void writeLines(Collection lines, String lineEnding,
|
public static void writeLines(Collection<Object> lines, String lineEnding,
|
||||||
OutputStream output, String encoding) throws IOException {
|
OutputStream output, String encoding) throws IOException {
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
writeLines(lines, lineEnding, output);
|
writeLines(lines, lineEnding, output);
|
||||||
|
@ -935,7 +935,7 @@ public class IOUtils {
|
||||||
if (lineEnding == null) {
|
if (lineEnding == null) {
|
||||||
lineEnding = LINE_SEPARATOR;
|
lineEnding = LINE_SEPARATOR;
|
||||||
}
|
}
|
||||||
for (Iterator it = lines.iterator(); it.hasNext(); ) {
|
for (Iterator<Object> it = lines.iterator(); it.hasNext(); ) {
|
||||||
Object line = it.next();
|
Object line = it.next();
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
output.write(line.toString().getBytes(encoding));
|
output.write(line.toString().getBytes(encoding));
|
||||||
|
@ -956,7 +956,7 @@ public class IOUtils {
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public static void writeLines(Collection lines, String lineEnding,
|
public static void writeLines(Collection<Object> lines, String lineEnding,
|
||||||
Writer writer) throws IOException {
|
Writer writer) throws IOException {
|
||||||
if (lines == null) {
|
if (lines == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -964,7 +964,7 @@ public class IOUtils {
|
||||||
if (lineEnding == null) {
|
if (lineEnding == null) {
|
||||||
lineEnding = LINE_SEPARATOR;
|
lineEnding = LINE_SEPARATOR;
|
||||||
}
|
}
|
||||||
for (Iterator it = lines.iterator(); it.hasNext(); ) {
|
for (Iterator<Object> it = lines.iterator(); it.hasNext(); ) {
|
||||||
Object line = it.next();
|
Object line = it.next();
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
writer.write(line.toString());
|
writer.write(line.toString());
|
||||||
|
|
|
@ -44,13 +44,13 @@ import java.util.Comparator;
|
||||||
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public class DefaultFileComparator implements Comparator, Serializable {
|
public class DefaultFileComparator implements Comparator<File>, Serializable {
|
||||||
|
|
||||||
/** Singleton default comparator instance */
|
/** Singleton default comparator instance */
|
||||||
public static final Comparator DEFAULT_COMPARATOR = new DefaultFileComparator();
|
public static final Comparator<File> DEFAULT_COMPARATOR = new DefaultFileComparator();
|
||||||
|
|
||||||
/** Singleton reverse default comparator instance */
|
/** Singleton reverse default comparator instance */
|
||||||
public static final Comparator DEFAULT_REVERSE = new ReverseComparator(DEFAULT_COMPARATOR);
|
public static final Comparator<File> DEFAULT_REVERSE = new ReverseComparator<File>(DEFAULT_COMPARATOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the two files using the {@link File#compareTo(File)} method.
|
* Compare the two files using the {@link File#compareTo(File)} method.
|
||||||
|
@ -60,9 +60,7 @@ public class DefaultFileComparator implements Comparator, Serializable {
|
||||||
* @return the result of calling file1's
|
* @return the result of calling file1's
|
||||||
* {@link File#compareTo(File)} with file2 as the parameter.
|
* {@link File#compareTo(File)} with file2 as the parameter.
|
||||||
*/
|
*/
|
||||||
public int compare(Object obj1, Object obj2) {
|
public int compare(File file1, File file2) {
|
||||||
File file1 = (File)obj1;
|
|
||||||
File file2 = (File)obj2;
|
|
||||||
return file1.compareTo(file2);
|
return file1.compareTo(file2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) $
|
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public class ExtensionFileComparator implements Comparator, Serializable {
|
public class ExtensionFileComparator implements Comparator<File>, Serializable {
|
||||||
|
|
||||||
/** Case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */
|
/** Case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */
|
||||||
public static final Comparator EXTENSION_COMPARATOR = new ExtensionFileComparator();
|
public static final Comparator<File> EXTENSION_COMPARATOR = new ExtensionFileComparator();
|
||||||
|
|
||||||
/** Reverse case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */
|
/** Reverse case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */
|
||||||
public static final Comparator EXTENSION_REVERSE = new ReverseComparator(EXTENSION_COMPARATOR);
|
public static final Comparator<File> EXTENSION_REVERSE = new ReverseComparator<File>(EXTENSION_COMPARATOR);
|
||||||
|
|
||||||
/** Case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */
|
/** Case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */
|
||||||
public static final Comparator EXTENSION_INSENSITIVE_COMPARATOR = new ExtensionFileComparator(IOCase.INSENSITIVE);
|
public static final Comparator<File> EXTENSION_INSENSITIVE_COMPARATOR = new ExtensionFileComparator(IOCase.INSENSITIVE);
|
||||||
|
|
||||||
/** Reverse case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */
|
/** Reverse case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */
|
||||||
public static final Comparator EXTENSION_INSENSITIVE_REVERSE
|
public static final Comparator<File> EXTENSION_INSENSITIVE_REVERSE
|
||||||
= new ReverseComparator(EXTENSION_INSENSITIVE_COMPARATOR);
|
= new ReverseComparator<File>(EXTENSION_INSENSITIVE_COMPARATOR);
|
||||||
|
|
||||||
/** System sensitive extension comparator instance (see {@link IOCase#SYSTEM}) */
|
/** System sensitive extension comparator instance (see {@link IOCase#SYSTEM}) */
|
||||||
public static final Comparator EXTENSION_SYSTEM_COMPARATOR = new ExtensionFileComparator(IOCase.SYSTEM);
|
public static final Comparator<File> EXTENSION_SYSTEM_COMPARATOR = new ExtensionFileComparator(IOCase.SYSTEM);
|
||||||
|
|
||||||
/** Reverse system sensitive path comparator instance (see {@link 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<File> EXTENSION_SYSTEM_REVERSE = new ReverseComparator<File>(EXTENSION_SYSTEM_COMPARATOR);
|
||||||
|
|
||||||
/** Whether the comparison is case sensitive. */
|
/** Whether the comparison is case sensitive. */
|
||||||
private final IOCase caseSensitivity;
|
private final IOCase caseSensitivity;
|
||||||
|
@ -102,9 +102,7 @@ public class ExtensionFileComparator implements Comparator, Serializable {
|
||||||
* is greater than the second file.
|
* is greater than the second file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public int compare(Object obj1, Object obj2) {
|
public int compare(File file1, File file2) {
|
||||||
File file1 = (File)obj1;
|
|
||||||
File file2 = (File)obj2;
|
|
||||||
String suffix1 = FilenameUtils.getExtension(file1.getName());
|
String suffix1 = FilenameUtils.getExtension(file1.getName());
|
||||||
String suffix2 = FilenameUtils.getExtension(file2.getName());
|
String suffix2 = FilenameUtils.getExtension(file2.getName());
|
||||||
return caseSensitivity.checkCompareTo(suffix1, suffix2);
|
return caseSensitivity.checkCompareTo(suffix1, suffix2);
|
||||||
|
|
|
@ -45,13 +45,13 @@ import java.util.Comparator;
|
||||||
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public class LastModifiedFileComparator implements Comparator, Serializable {
|
public class LastModifiedFileComparator implements Comparator<File>, Serializable {
|
||||||
|
|
||||||
/** Last modified comparator instance */
|
/** Last modified comparator instance */
|
||||||
public static final Comparator LASTMODIFIED_COMPARATOR = new LastModifiedFileComparator();
|
public static final Comparator<File> LASTMODIFIED_COMPARATOR = new LastModifiedFileComparator();
|
||||||
|
|
||||||
/** Reverse last modified comparator instance */
|
/** Reverse last modified comparator instance */
|
||||||
public static final Comparator LASTMODIFIED_REVERSE = new ReverseComparator(LASTMODIFIED_COMPARATOR);
|
public static final Comparator<File> LASTMODIFIED_REVERSE = new ReverseComparator<File>(LASTMODIFIED_COMPARATOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the last the last modified date/time of two files.
|
* Compare the last the last modified date/time of two files.
|
||||||
|
@ -64,9 +64,7 @@ public class LastModifiedFileComparator implements Comparator, Serializable {
|
||||||
* is greater than the second file.
|
* is greater than the second file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public int compare(Object obj1, Object obj2) {
|
public int compare(File file1, File file2) {
|
||||||
File file1 = (File)obj1;
|
|
||||||
File file2 = (File)obj2;
|
|
||||||
long result = file1.lastModified() - file2.lastModified();
|
long result = file1.lastModified() - file2.lastModified();
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -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) $
|
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public class NameFileComparator implements Comparator, Serializable {
|
public class NameFileComparator implements Comparator<File>, Serializable {
|
||||||
|
|
||||||
/** Case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */
|
/** Case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */
|
||||||
public static final Comparator NAME_COMPARATOR = new NameFileComparator();
|
public static final Comparator<File> NAME_COMPARATOR = new NameFileComparator();
|
||||||
|
|
||||||
/** Reverse case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */
|
/** Reverse case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */
|
||||||
public static final Comparator NAME_REVERSE = new ReverseComparator(NAME_COMPARATOR);
|
public static final Comparator<File> NAME_REVERSE = new ReverseComparator<File>(NAME_COMPARATOR);
|
||||||
|
|
||||||
/** Case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */
|
/** Case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */
|
||||||
public static final Comparator NAME_INSENSITIVE_COMPARATOR = new NameFileComparator(IOCase.INSENSITIVE);
|
public static final Comparator<File> NAME_INSENSITIVE_COMPARATOR = new NameFileComparator(IOCase.INSENSITIVE);
|
||||||
|
|
||||||
/** Reverse case-insensitive name comparator instance (see {@link 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<File> NAME_INSENSITIVE_REVERSE = new ReverseComparator<File>(NAME_INSENSITIVE_COMPARATOR);
|
||||||
|
|
||||||
/** System sensitive name comparator instance (see {@link IOCase#SYSTEM}) */
|
/** System sensitive name comparator instance (see {@link IOCase#SYSTEM}) */
|
||||||
public static final Comparator NAME_SYSTEM_COMPARATOR = new NameFileComparator(IOCase.SYSTEM);
|
public static final Comparator<File> NAME_SYSTEM_COMPARATOR = new NameFileComparator(IOCase.SYSTEM);
|
||||||
|
|
||||||
/** Reverse system sensitive name comparator instance (see {@link 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<File> NAME_SYSTEM_REVERSE = new ReverseComparator<File>(NAME_SYSTEM_COMPARATOR);
|
||||||
|
|
||||||
/** Whether the comparison is case sensitive. */
|
/** Whether the comparison is case sensitive. */
|
||||||
private final IOCase caseSensitivity;
|
private final IOCase caseSensitivity;
|
||||||
|
@ -98,9 +98,7 @@ public class NameFileComparator implements Comparator, Serializable {
|
||||||
* same and a positive value if the first files name
|
* same and a positive value if the first files name
|
||||||
* is greater than the second file.
|
* is greater than the second file.
|
||||||
*/
|
*/
|
||||||
public int compare(Object obj1, Object obj2) {
|
public int compare(File file1, File file2) {
|
||||||
File file1 = (File)obj1;
|
|
||||||
File file2 = (File)obj2;
|
|
||||||
return caseSensitivity.checkCompareTo(file1.getName(), file2.getName());
|
return caseSensitivity.checkCompareTo(file1.getName(), file2.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) $
|
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public class PathFileComparator implements Comparator, Serializable {
|
public class PathFileComparator implements Comparator<File>, Serializable {
|
||||||
|
|
||||||
/** Case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */
|
/** Case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */
|
||||||
public static final Comparator PATH_COMPARATOR = new PathFileComparator();
|
public static final Comparator<File> PATH_COMPARATOR = new PathFileComparator();
|
||||||
|
|
||||||
/** Reverse case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */
|
/** Reverse case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */
|
||||||
public static final Comparator PATH_REVERSE = new ReverseComparator(PATH_COMPARATOR);
|
public static final Comparator<File> PATH_REVERSE = new ReverseComparator<File>(PATH_COMPARATOR);
|
||||||
|
|
||||||
/** Case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */
|
/** Case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */
|
||||||
public static final Comparator PATH_INSENSITIVE_COMPARATOR = new PathFileComparator(IOCase.INSENSITIVE);
|
public static final Comparator<File> PATH_INSENSITIVE_COMPARATOR = new PathFileComparator(IOCase.INSENSITIVE);
|
||||||
|
|
||||||
/** Reverse case-insensitive path comparator instance (see {@link 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<File> PATH_INSENSITIVE_REVERSE = new ReverseComparator<File>(PATH_INSENSITIVE_COMPARATOR);
|
||||||
|
|
||||||
/** System sensitive path comparator instance (see {@link IOCase#SYSTEM}) */
|
/** System sensitive path comparator instance (see {@link IOCase#SYSTEM}) */
|
||||||
public static final Comparator PATH_SYSTEM_COMPARATOR = new PathFileComparator(IOCase.SYSTEM);
|
public static final Comparator<File> PATH_SYSTEM_COMPARATOR = new PathFileComparator(IOCase.SYSTEM);
|
||||||
|
|
||||||
/** Reverse system sensitive path comparator instance (see {@link 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<File> PATH_SYSTEM_REVERSE = new ReverseComparator<File>(PATH_SYSTEM_COMPARATOR);
|
||||||
|
|
||||||
/** Whether the comparison is case sensitive. */
|
/** Whether the comparison is case sensitive. */
|
||||||
private final IOCase caseSensitivity;
|
private final IOCase caseSensitivity;
|
||||||
|
@ -99,9 +99,7 @@ public class PathFileComparator implements Comparator, Serializable {
|
||||||
* is greater than the second file.
|
* is greater than the second file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public int compare(Object obj1, Object obj2) {
|
public int compare(File file1, File file2) {
|
||||||
File file1 = (File)obj1;
|
|
||||||
File file2 = (File)obj2;
|
|
||||||
return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath());
|
return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,16 +26,16 @@ import java.util.Comparator;
|
||||||
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
class ReverseComparator implements Comparator, Serializable {
|
class ReverseComparator<T> implements Comparator<T>, Serializable {
|
||||||
|
|
||||||
private final Comparator delegate;
|
private final Comparator<T> delegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance with the sepecified delegate {@link Comparator}.
|
* Construct an instance with the sepecified delegate {@link Comparator}.
|
||||||
*
|
*
|
||||||
* @param delegate The comparator to delegate to
|
* @param delegate The comparator to delegate to
|
||||||
*/
|
*/
|
||||||
public ReverseComparator(Comparator delegate) {
|
public ReverseComparator(Comparator<T> delegate) {
|
||||||
if (delegate == null) {
|
if (delegate == null) {
|
||||||
throw new IllegalArgumentException("Delegate comparator is missing");
|
throw new IllegalArgumentException("Delegate comparator is missing");
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class ReverseComparator implements Comparator, Serializable {
|
||||||
* @return the result from the delegate {@link Comparator#compare(Object, Object)}
|
* @return the result from the delegate {@link Comparator#compare(Object, Object)}
|
||||||
* reversing the value (i.e. positive becomes negative and vice versa)
|
* 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
|
return delegate.compare(obj2, obj1); // parameters switched round
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) $
|
* @version $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public class SizeFileComparator implements Comparator, Serializable {
|
public class SizeFileComparator implements Comparator<File>, Serializable {
|
||||||
|
|
||||||
/** Size comparator instance - directories are treated as zero size */
|
/** Size comparator instance - directories are treated as zero size */
|
||||||
public static final Comparator SIZE_COMPARATOR = new SizeFileComparator();
|
public static final Comparator<File> SIZE_COMPARATOR = new SizeFileComparator();
|
||||||
|
|
||||||
/** Reverse size comparator instance - directories are treated as zero size */
|
/** Reverse size comparator instance - directories are treated as zero size */
|
||||||
public static final Comparator SIZE_REVERSE = new ReverseComparator(SIZE_COMPARATOR);
|
public static final Comparator<File> SIZE_REVERSE = new ReverseComparator<File>(SIZE_COMPARATOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Size comparator instance which sums the size of a directory's contents
|
* Size comparator instance which sums the size of a directory's contents
|
||||||
* using {@link FileUtils#sizeOfDirectory(File)}
|
* using {@link FileUtils#sizeOfDirectory(File)}
|
||||||
*/
|
*/
|
||||||
public static final Comparator SIZE_SUMDIR_COMPARATOR = new SizeFileComparator(true);
|
public static final Comparator<File> SIZE_SUMDIR_COMPARATOR = new SizeFileComparator(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse size comparator instance which sums the size of a directory's contents
|
* Reverse size comparator instance which sums the size of a directory's contents
|
||||||
* using {@link FileUtils#sizeOfDirectory(File)}
|
* using {@link FileUtils#sizeOfDirectory(File)}
|
||||||
*/
|
*/
|
||||||
public static final Comparator SIZE_SUMDIR_REVERSE = new ReverseComparator(SIZE_SUMDIR_COMPARATOR);
|
public static final Comparator<File> SIZE_SUMDIR_REVERSE = new ReverseComparator<File>(SIZE_SUMDIR_COMPARATOR);
|
||||||
|
|
||||||
/** Whether the sum of the directory's contents should be calculated. */
|
/** Whether the sum of the directory's contents should be calculated. */
|
||||||
private final boolean sumDirectoryContents;
|
private final boolean sumDirectoryContents;
|
||||||
|
@ -105,9 +105,7 @@ public class SizeFileComparator implements Comparator, Serializable {
|
||||||
* is greater than the second file.
|
* is greater than the second file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public int compare(Object obj1, Object obj2) {
|
public int compare(File file1, File file2) {
|
||||||
File file1 = (File)obj1;
|
|
||||||
File file2 = (File)obj2;
|
|
||||||
long size1 = 0;
|
long size1 = 0;
|
||||||
if (file1.isDirectory()) {
|
if (file1.isDirectory()) {
|
||||||
size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0;
|
size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0;
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class AndFileFilter
|
||||||
implements ConditionalFileFilter, Serializable {
|
implements ConditionalFileFilter, Serializable {
|
||||||
|
|
||||||
/** The list of file filters. */
|
/** The list of file filters. */
|
||||||
private List fileFilters;
|
private List<IOFileFilter> fileFilters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance of <code>AndFileFilter</code>.
|
* Constructs a new instance of <code>AndFileFilter</code>.
|
||||||
|
@ -48,7 +48,7 @@ public class AndFileFilter
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public AndFileFilter() {
|
public AndFileFilter() {
|
||||||
this.fileFilters = new ArrayList();
|
this.fileFilters = new ArrayList<IOFileFilter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,11 +58,11 @@ public class AndFileFilter
|
||||||
* @param fileFilters a List of IOFileFilter instances, copied, null ignored
|
* @param fileFilters a List of IOFileFilter instances, copied, null ignored
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public AndFileFilter(final List fileFilters) {
|
public AndFileFilter(final List<IOFileFilter> fileFilters) {
|
||||||
if (fileFilters == null) {
|
if (fileFilters == null) {
|
||||||
this.fileFilters = new ArrayList();
|
this.fileFilters = new ArrayList<IOFileFilter>();
|
||||||
} else {
|
} else {
|
||||||
this.fileFilters = new ArrayList(fileFilters);
|
this.fileFilters = new ArrayList<IOFileFilter>(fileFilters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class AndFileFilter
|
||||||
if (filter1 == null || filter2 == null) {
|
if (filter1 == null || filter2 == null) {
|
||||||
throw new IllegalArgumentException("The filters must not be null");
|
throw new IllegalArgumentException("The filters must not be null");
|
||||||
}
|
}
|
||||||
this.fileFilters = new ArrayList();
|
this.fileFilters = new ArrayList<IOFileFilter>();
|
||||||
addFileFilter(filter1);
|
addFileFilter(filter1);
|
||||||
addFileFilter(filter2);
|
addFileFilter(filter2);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class AndFileFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public List getFileFilters() {
|
public List<IOFileFilter> getFileFilters() {
|
||||||
return Collections.unmodifiableList(this.fileFilters);
|
return Collections.unmodifiableList(this.fileFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,19 +106,21 @@ public class AndFileFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setFileFilters(final List fileFilters) {
|
@Override
|
||||||
this.fileFilters = new ArrayList(fileFilters);
|
public void setFileFilters(final List<IOFileFilter> fileFilters) {
|
||||||
|
this.fileFilters = new ArrayList<IOFileFilter>(fileFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(final File file) {
|
public boolean accept(final File file) {
|
||||||
if (this.fileFilters.size() == 0) {
|
if (this.fileFilters.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
|
for (Iterator<IOFileFilter> iter = this.fileFilters.iterator(); iter.hasNext();) {
|
||||||
IOFileFilter fileFilter = (IOFileFilter) iter.next();
|
IOFileFilter fileFilter = iter.next();
|
||||||
if (!fileFilter.accept(file)) {
|
if (!fileFilter.accept(file)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -129,12 +131,13 @@ public class AndFileFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(final File file, final String name) {
|
public boolean accept(final File file, final String name) {
|
||||||
if (this.fileFilters.size() == 0) {
|
if (this.fileFilters.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
|
for (Iterator<IOFileFilter> iter = this.fileFilters.iterator(); iter.hasNext();) {
|
||||||
IOFileFilter fileFilter = (IOFileFilter) iter.next();
|
IOFileFilter fileFilter = iter.next();
|
||||||
if (!fileFilter.accept(file, name)) {
|
if (!fileFilter.accept(file, name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +150,7 @@ public class AndFileFilter
|
||||||
*
|
*
|
||||||
* @return a String representaion
|
* @return a String representaion
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(super.toString());
|
buffer.append(super.toString());
|
||||||
|
|
|
@ -43,7 +43,7 @@ public interface ConditionalFileFilter {
|
||||||
* @return the file filter list
|
* @return the file filter list
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public List getFileFilters();
|
public List<IOFileFilter> getFileFilters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified file filter.
|
* Removes the specified file filter.
|
||||||
|
@ -62,6 +62,6 @@ public interface ConditionalFileFilter {
|
||||||
* @param fileFilters the list of filters
|
* @param fileFilters the list of filters
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public void setFileFilters(List fileFilters);
|
public void setFileFilters(List<IOFileFilter> fileFilters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
|
||||||
* @throws IllegalArgumentException if the name list is null
|
* @throws IllegalArgumentException if the name list is null
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
*/
|
*/
|
||||||
public NameFileFilter(List names) {
|
public NameFileFilter(List<String> names) {
|
||||||
this(names, null);
|
this(names, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +126,11 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
|
||||||
* @throws IllegalArgumentException if the name list is null
|
* @throws IllegalArgumentException if the name list is null
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
*/
|
*/
|
||||||
public NameFileFilter(List names, IOCase caseSensitivity) {
|
public NameFileFilter(List<String> names, IOCase caseSensitivity) {
|
||||||
if (names == null) {
|
if (names == null) {
|
||||||
throw new IllegalArgumentException("The list of names must not be 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);
|
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +141,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
|
||||||
* @param file the File to check
|
* @param file the File to check
|
||||||
* @return true if the filename matches
|
* @return true if the filename matches
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
for (int i = 0; i < this.names.length; i++) {
|
for (int i = 0; i < this.names.length; i++) {
|
||||||
|
@ -158,6 +159,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
|
||||||
* @param name the filename
|
* @param name the filename
|
||||||
* @return true if the filename matches
|
* @return true if the filename matches
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File file, String name) {
|
public boolean accept(File file, String name) {
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
if (caseSensitivity.checkEquals(name, names[i])) {
|
if (caseSensitivity.checkEquals(name, names[i])) {
|
||||||
|
@ -172,6 +174,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
|
||||||
*
|
*
|
||||||
* @return a String representaion
|
* @return a String representaion
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(super.toString());
|
buffer.append(super.toString());
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class OrFileFilter
|
||||||
implements ConditionalFileFilter, Serializable {
|
implements ConditionalFileFilter, Serializable {
|
||||||
|
|
||||||
/** The list of file filters. */
|
/** The list of file filters. */
|
||||||
private List fileFilters;
|
private List<IOFileFilter> fileFilters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance of <code>OrFileFilter</code>.
|
* Constructs a new instance of <code>OrFileFilter</code>.
|
||||||
|
@ -48,7 +48,7 @@ public class OrFileFilter
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public OrFileFilter() {
|
public OrFileFilter() {
|
||||||
this.fileFilters = new ArrayList();
|
this.fileFilters = new ArrayList<IOFileFilter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,11 +58,11 @@ public class OrFileFilter
|
||||||
* @param fileFilters the file filters for this filter, copied, null ignored
|
* @param fileFilters the file filters for this filter, copied, null ignored
|
||||||
* @since Commons IO 1.1
|
* @since Commons IO 1.1
|
||||||
*/
|
*/
|
||||||
public OrFileFilter(final List fileFilters) {
|
public OrFileFilter(final List<IOFileFilter> fileFilters) {
|
||||||
if (fileFilters == null) {
|
if (fileFilters == null) {
|
||||||
this.fileFilters = new ArrayList();
|
this.fileFilters = new ArrayList<IOFileFilter>();
|
||||||
} else {
|
} else {
|
||||||
this.fileFilters = new ArrayList(fileFilters);
|
this.fileFilters = new ArrayList<IOFileFilter>(fileFilters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class OrFileFilter
|
||||||
if (filter1 == null || filter2 == null) {
|
if (filter1 == null || filter2 == null) {
|
||||||
throw new IllegalArgumentException("The filters must not be null");
|
throw new IllegalArgumentException("The filters must not be null");
|
||||||
}
|
}
|
||||||
this.fileFilters = new ArrayList();
|
this.fileFilters = new ArrayList<IOFileFilter>();
|
||||||
addFileFilter(filter1);
|
addFileFilter(filter1);
|
||||||
addFileFilter(filter2);
|
addFileFilter(filter2);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class OrFileFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public List getFileFilters() {
|
public List<IOFileFilter> getFileFilters() {
|
||||||
return Collections.unmodifiableList(this.fileFilters);
|
return Collections.unmodifiableList(this.fileFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,16 +106,17 @@ public class OrFileFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setFileFilters(final List fileFilters) {
|
public void setFileFilters(final List<IOFileFilter> fileFilters) {
|
||||||
this.fileFilters = fileFilters;
|
this.fileFilters = fileFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(final File file) {
|
public boolean accept(final File file) {
|
||||||
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
|
for (Iterator<IOFileFilter> iter = this.fileFilters.iterator(); iter.hasNext();) {
|
||||||
IOFileFilter fileFilter = (IOFileFilter) iter.next();
|
IOFileFilter fileFilter = iter.next();
|
||||||
if (fileFilter.accept(file)) {
|
if (fileFilter.accept(file)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -126,9 +127,10 @@ public class OrFileFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(final File file, final String name) {
|
public boolean accept(final File file, final String name) {
|
||||||
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
|
for (Iterator<IOFileFilter> iter = this.fileFilters.iterator(); iter.hasNext();) {
|
||||||
IOFileFilter fileFilter = (IOFileFilter) iter.next();
|
IOFileFilter fileFilter = iter.next();
|
||||||
if (fileFilter.accept(file, name)) {
|
if (fileFilter.accept(file, name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -141,6 +143,7 @@ public class OrFileFilter
|
||||||
*
|
*
|
||||||
* @return a String representaion
|
* @return a String representaion
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(super.toString());
|
buffer.append(super.toString());
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @throws IllegalArgumentException if the prefix list is null
|
* @throws IllegalArgumentException if the prefix list is null
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
*/
|
*/
|
||||||
public PrefixFileFilter(List prefixes) {
|
public PrefixFileFilter(List<String> prefixes) {
|
||||||
this(prefixes, IOCase.SENSITIVE);
|
this(prefixes, IOCase.SENSITIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,11 +133,11 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public PrefixFileFilter(List prefixes, IOCase caseSensitivity) {
|
public PrefixFileFilter(List<String> prefixes, IOCase caseSensitivity) {
|
||||||
if (prefixes == null) {
|
if (prefixes == null) {
|
||||||
throw new IllegalArgumentException("The list of prefixes must not be 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);
|
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @param file the File to check
|
* @param file the File to check
|
||||||
* @return true if the filename starts with one of our prefixes
|
* @return true if the filename starts with one of our prefixes
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
for (int i = 0; i < this.prefixes.length; i++) {
|
for (int i = 0; i < this.prefixes.length; i++) {
|
||||||
|
@ -164,6 +165,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @param name the filename
|
* @param name the filename
|
||||||
* @return true if the filename starts with one of our prefixes
|
* @return true if the filename starts with one of our prefixes
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File file, String name) {
|
public boolean accept(File file, String name) {
|
||||||
for (int i = 0; i < prefixes.length; i++) {
|
for (int i = 0; i < prefixes.length; i++) {
|
||||||
if (caseSensitivity.checkStartsWith(name, prefixes[i])) {
|
if (caseSensitivity.checkStartsWith(name, prefixes[i])) {
|
||||||
|
@ -178,6 +180,7 @@ public class PrefixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
*
|
*
|
||||||
* @return a String representaion
|
* @return a String representaion
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(super.toString());
|
buffer.append(super.toString());
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @throws IllegalArgumentException if the suffix list is null
|
* @throws IllegalArgumentException if the suffix list is null
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
*/
|
*/
|
||||||
public SuffixFileFilter(List suffixes) {
|
public SuffixFileFilter(List<String> suffixes) {
|
||||||
this(suffixes, IOCase.SENSITIVE);
|
this(suffixes, IOCase.SENSITIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,11 +134,11 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
* @since Commons IO 1.4
|
* @since Commons IO 1.4
|
||||||
*/
|
*/
|
||||||
public SuffixFileFilter(List suffixes, IOCase caseSensitivity) {
|
public SuffixFileFilter(List<String> suffixes, IOCase caseSensitivity) {
|
||||||
if (suffixes == null) {
|
if (suffixes == null) {
|
||||||
throw new IllegalArgumentException("The list of suffixes must not be 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);
|
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +148,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @param file the File to check
|
* @param file the File to check
|
||||||
* @return true if the filename ends with one of our suffixes
|
* @return true if the filename ends with one of our suffixes
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
for (int i = 0; i < this.suffixes.length; i++) {
|
for (int i = 0; i < this.suffixes.length; i++) {
|
||||||
|
@ -165,6 +166,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
* @param name the filename
|
* @param name the filename
|
||||||
* @return true if the filename ends with one of our suffixes
|
* @return true if the filename ends with one of our suffixes
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File file, String name) {
|
public boolean accept(File file, String name) {
|
||||||
for (int i = 0; i < this.suffixes.length; i++) {
|
for (int i = 0; i < this.suffixes.length; i++) {
|
||||||
if (caseSensitivity.checkEndsWith(name, suffixes[i])) {
|
if (caseSensitivity.checkEndsWith(name, suffixes[i])) {
|
||||||
|
@ -179,6 +181,7 @@ public class SuffixFileFilter extends AbstractFileFilter implements Serializable
|
||||||
*
|
*
|
||||||
* @return a String representaion
|
* @return a String representaion
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(super.toString());
|
buffer.append(super.toString());
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
|
||||||
* @throws IllegalArgumentException if the pattern list is null
|
* @throws IllegalArgumentException if the pattern list is null
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
*/
|
*/
|
||||||
public WildcardFileFilter(List wildcards) {
|
public WildcardFileFilter(List<String> wildcards) {
|
||||||
this(wildcards, null);
|
this(wildcards, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,11 +131,11 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
|
||||||
* @throws IllegalArgumentException if the pattern list is null
|
* @throws IllegalArgumentException if the pattern list is null
|
||||||
* @throws ClassCastException if the list does not contain Strings
|
* @throws ClassCastException if the list does not contain Strings
|
||||||
*/
|
*/
|
||||||
public WildcardFileFilter(List wildcards, IOCase caseSensitivity) {
|
public WildcardFileFilter(List<String> wildcards, IOCase caseSensitivity) {
|
||||||
if (wildcards == null) {
|
if (wildcards == null) {
|
||||||
throw new IllegalArgumentException("The wildcard list must not be 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);
|
this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +147,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
|
||||||
* @param name the filename
|
* @param name the filename
|
||||||
* @return true if the filename matches one of the wildcards
|
* @return true if the filename matches one of the wildcards
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
for (int i = 0; i < wildcards.length; i++) {
|
for (int i = 0; i < wildcards.length; i++) {
|
||||||
if (FilenameUtils.wildcardMatch(name, wildcards[i], caseSensitivity)) {
|
if (FilenameUtils.wildcardMatch(name, wildcards[i], caseSensitivity)) {
|
||||||
|
@ -162,6 +163,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
|
||||||
* @param file the file to check
|
* @param file the file to check
|
||||||
* @return true if the filename matches one of the wildcards
|
* @return true if the filename matches one of the wildcards
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
for (int i = 0; i < wildcards.length; i++) {
|
for (int i = 0; i < wildcards.length; i++) {
|
||||||
|
@ -177,6 +179,7 @@ public class WildcardFileFilter extends AbstractFileFilter implements Serializab
|
||||||
*
|
*
|
||||||
* @return a String representaion
|
* @return a String representaion
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append(super.toString());
|
buffer.append(super.toString());
|
||||||
|
|
|
@ -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.
|
|
||||||
* <p>
|
|
||||||
* This filter selects files, but not directories, based on one or more wildcards
|
|
||||||
* and using case-sensitive comparison.
|
|
||||||
* <p>
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* For example:
|
|
||||||
* <pre>
|
|
||||||
* 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]);
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -29,7 +29,7 @@ import java.io.InputStream;
|
||||||
public class DemuxInputStream
|
public class DemuxInputStream
|
||||||
extends InputStream
|
extends InputStream
|
||||||
{
|
{
|
||||||
private InheritableThreadLocal m_streams = new InheritableThreadLocal();
|
private InheritableThreadLocal<InputStream> m_streams = new InheritableThreadLocal<InputStream>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind the specified stream to the current thread.
|
* Bind the specified stream to the current thread.
|
||||||
|
@ -49,6 +49,7 @@ public class DemuxInputStream
|
||||||
*
|
*
|
||||||
* @throws IOException if an error occurs
|
* @throws IOException if an error occurs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void close()
|
public void close()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -65,6 +66,7 @@ public class DemuxInputStream
|
||||||
* @return the byte read from stream
|
* @return the byte read from stream
|
||||||
* @throws IOException if an error occurs
|
* @throws IOException if an error occurs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int read()
|
public int read()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -86,6 +88,6 @@ public class DemuxInputStream
|
||||||
*/
|
*/
|
||||||
private InputStream getStream()
|
private InputStream getStream()
|
||||||
{
|
{
|
||||||
return (InputStream)m_streams.get();
|
return m_streams.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||||
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
|
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
|
||||||
|
|
||||||
/** The list of buffers, which grows and never reduces. */
|
/** The list of buffers, which grows and never reduces. */
|
||||||
private List buffers = new ArrayList();
|
private List<byte[]> buffers = new ArrayList<byte[]>();
|
||||||
/** The index of the current buffer. */
|
/** The index of the current buffer. */
|
||||||
private int currentBufferIndex;
|
private int currentBufferIndex;
|
||||||
/** The total count of bytes in all the filled buffers. */
|
/** The total count of bytes in all the filled buffers. */
|
||||||
|
@ -95,7 +95,7 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||||
* @return the buffer
|
* @return the buffer
|
||||||
*/
|
*/
|
||||||
private byte[] getBuffer(int index) {
|
private byte[] getBuffer(int index) {
|
||||||
return (byte[]) buffers.get(index);
|
return buffers.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,6 +136,7 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||||
* @param off The start offset
|
* @param off The start offset
|
||||||
* @param len The number of bytes to write
|
* @param len The number of bytes to write
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void write(byte[] b, int off, int len) {
|
public void write(byte[] b, int off, int len) {
|
||||||
if ((off < 0)
|
if ((off < 0)
|
||||||
|| (off > b.length)
|
|| (off > b.length)
|
||||||
|
@ -167,6 +168,7 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||||
* Write a byte to byte array.
|
* Write a byte to byte array.
|
||||||
* @param b the byte to write
|
* @param b the byte to write
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void write(int b) {
|
public synchronized void write(int b) {
|
||||||
int inBufferPos = count - filledBufferSum;
|
int inBufferPos = count - filledBufferSum;
|
||||||
if (inBufferPos == currentBuffer.length) {
|
if (inBufferPos == currentBuffer.length) {
|
||||||
|
@ -221,6 +223,7 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||||
* @throws IOException never (this method should not declare this exception
|
* @throws IOException never (this method should not declare this exception
|
||||||
* but it has to now due to backwards compatability)
|
* but it has to now due to backwards compatability)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
//nop
|
//nop
|
||||||
}
|
}
|
||||||
|
@ -288,6 +291,7 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||||
* @return the contents of the byte array as a String
|
* @return the contents of the byte array as a String
|
||||||
* @see java.io.ByteArrayOutputStream#toString()
|
* @see java.io.ByteArrayOutputStream#toString()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new String(toByteArray());
|
return new String(toByteArray());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.io.OutputStream;
|
||||||
public class DemuxOutputStream
|
public class DemuxOutputStream
|
||||||
extends OutputStream
|
extends OutputStream
|
||||||
{
|
{
|
||||||
private InheritableThreadLocal m_streams = new InheritableThreadLocal();
|
private InheritableThreadLocal<OutputStream> m_streams = new InheritableThreadLocal<OutputStream>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind the specified stream to the current thread.
|
* Bind the specified stream to the current thread.
|
||||||
|
@ -49,6 +49,7 @@ public class DemuxOutputStream
|
||||||
*
|
*
|
||||||
* @throws IOException if an error occurs
|
* @throws IOException if an error occurs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void close()
|
public void close()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -64,6 +65,7 @@ public class DemuxOutputStream
|
||||||
*
|
*
|
||||||
* @throws IOException if an error occurs
|
* @throws IOException if an error occurs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void flush()
|
public void flush()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -80,6 +82,7 @@ public class DemuxOutputStream
|
||||||
* @param ch the byte to write to stream
|
* @param ch the byte to write to stream
|
||||||
* @throws IOException if an error occurs
|
* @throws IOException if an error occurs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void write( int ch )
|
public void write( int ch )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -97,6 +100,6 @@ public class DemuxOutputStream
|
||||||
*/
|
*/
|
||||||
private OutputStream getStream()
|
private OutputStream getStream()
|
||||||
{
|
{
|
||||||
return (OutputStream)m_streams.get();
|
return m_streams.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue