public abstract class FileList
extends java.lang.Object
File
objects. No
directories will be returned in this list. The list is sorted
lexicographically with controllable case-sensitivity (defaults to
case-insensitive).
Once list()
, listFilenames()
or size()
is called
once, the results are cached for fast subsequent access. Please note that
this means that any file system changes (e.g. directories or files
deleted/added) after that point will not be reflected in this instance's
data.
Modifier and Type | Field and Description |
---|---|
private boolean |
caseSens
Determines if sorting should be case-sensitive.
|
protected static java.util.Comparator |
compare
Provides a comparator for sorting filenames.
|
private java.io.File[] |
files
Stores cached results so subsequent access is fast.
|
Modifier | Constructor and Description |
---|---|
protected |
FileList()
Default constructor (provides a case-insensitive sort).
|
|
FileList(boolean caseSensitive)
Base constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isCaseSensitive()
Gets the case-sensitivity of the sorting algorithm for this instance.
|
java.io.File[] |
list()
Create and return the list of files based on user input specified
during construction.
|
java.lang.String[] |
listFilenames()
Create and return the list of files based on user input specified
during construction.
|
protected abstract void |
listImpl(java.util.ArrayList results)
Core implementation of the listing algorithm which must make a filtered
list of just those files that exist (excluding any directories).
|
void |
setCaseSensitive(boolean caseSens)
Sets the case-sensitivity of the sorting algorithm for this instance.
|
int |
size()
Gets the size of the list of files.
|
private boolean caseSens
private java.io.File[] files
protected static java.util.Comparator compare
public FileList(boolean caseSensitive)
caseSensitive
- Sets the case-sensitivity of the sorting algorithm.protected FileList()
public boolean isCaseSensitive()
true
if the sorting would be done on a case-
sensitive basis.public void setCaseSensitive(boolean caseSens)
caseSens
- true
if the sorting should be done on a case-
sensitive basis.public java.io.File[] list()
public java.lang.String[] listFilenames()
public int size()
protected abstract void listImpl(java.util.ArrayList results)
results
- The list to which all matching files must be appended.