Package org.jboss.vfs.util
Class ExtensibleFilter
java.lang.Object
org.jboss.vfs.util.ExtensibleFilter
- All Implemented Interfaces:
VirtualFileFilter
An extensible filter for VFS files. Three arrays are maintained for checking: a prefix, suffix, and match array. If
the filename starts with any of the prefixes, ends with any of the suffixes, or exactly matches any of the matches,
then the accepts method will return false.
NOTE: the arrays *must* be sorted for the string matching to work, and suffixes use the 'reverseComparator'
- Version:
- $Revision: 57108 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]
the default matches listprivate static final String[]
the default prefix listprivate static final String[]
the default suffix listThe sorted list of disallowed valuesThe sorted list of disallowed prefixesprivate static final Comparator
<String> Compare the strings backwards.The list of disallowed suffixes, sorted using reverse values -
Constructor Summary
ConstructorsConstructorDescriptionUse the default values for suffixes, prefixes, and matchesExtensibleFilter
(String[] matches, String[] prefixes, String[] suffixes) Create using a custom set of matches, prefixes, and suffixes. -
Method Summary
Modifier and TypeMethodDescriptionboolean
accepts
(VirtualFile file) If the filename matches any string in the prefix, suffix, or matches array, return false.void
void
addPrefixes
(String[] prefixes) void
void
addSuffixes
(String[] suffixes) void
void
delPrefixes
(String[] prefixes) void
void
delSuffixes
(String[] suffixes) String[]
String[]
String[]
void
setMatches
(String[] matches) void
setPrefixes
(String[] prefixes) void
setSuffixes
(String[] suffixes)
-
Field Details
-
reverseComparator
Compare the strings backwards. This assists in suffix comparisons. -
DEFAULT_PREFIXES
the default prefix list -
DEFAULT_SUFFIXES
the default suffix list -
DEFAULT_MATCHES
the default matches list -
suffixes
The list of disallowed suffixes, sorted using reverse values -
prefixes
The sorted list of disallowed prefixes -
matches
The sorted list of disallowed values
-
-
Constructor Details
-
ExtensibleFilter
public ExtensibleFilter()Use the default values for suffixes, prefixes, and matches -
ExtensibleFilter
Create using a custom set of matches, prefixes, and suffixes. If any of these arrays are null, then the corresponding default will be substituted.- Parameters:
matches
- the matchesprefixes
- the prefixessuffixes
- the suffixes
-
-
Method Details
-
addPrefix
-
addPrefixes
-
delPrefix
-
delPrefixes
-
addSuffix
-
addSuffixes
-
delSuffix
-
delSuffixes
-
getSuffixes
-
setSuffixes
-
getPrefixes
-
setPrefixes
-
getMatches
-
setMatches
-
accepts
If the filename matches any string in the prefix, suffix, or matches array, return false. Perhaps a bit of overkill, but this method operates in log(n) time, where n is the size of the arrays.- Specified by:
accepts
in interfaceVirtualFileFilter
- Parameters:
file
- The file to be tested- Returns:
false
if the filename matches any of the prefixes, suffixes, or matches.
-