Package ucar.unidata.util
Class PatternFileFilter
java.lang.Object
javax.swing.filechooser.FileFilter
ucar.unidata.util.PatternFileFilter
- All Implemented Interfaces:
FileFilter,FilenameFilter
This holds a set of regular expression patterns that are used for file filters in a JFileChooser.
You can also pass in an Object id (which can be used as the client code sees fit) and a directoriesOk
flag.
- Author:
- Metapps development team
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPatternFileFilter(String patternsString) Create a new PatternFileFilter.PatternFileFilter(String patternsString, boolean dirsOk) Create a new PatternFileFilter.PatternFileFilter(String patternsString, boolean dirsOk, boolean hiddenOk) Create a new PatternFileFilter.PatternFileFilter(String patternsString, Object id, String description) Create a new PatternFileFilter.PatternFileFilter(String patternsString, Object id, String description, String suffix) Create a new PatternFileFilter.PatternFileFilter(String patternsString, String description) Create a new PatternFileFilter.PatternFileFilter(String patternsString, String description, String suffix) Create a new PatternFileFilter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDoes this pattern match the given file.booleanImplement the FilenameFilter methodstatic ListcreateFilters(String filterString) Parse the given string and return a list of PatternFileFilter-s The string is a ";" delimited list of pattern specifications of the form: pattern":"description or: just the pattern.Return the description.getId()Return the object id.Get the PreferredSuffix property.static voidTestbooleanDoes this pattern match the given file.voidsetPreferredSuffix(String value) Set the PreferedSuffix property.toString()Override base class method.
-
Field Details
-
NULL_OBJECT_ID
Used for passing in a null object id
-
-
Constructor Details
-
PatternFileFilter
Create a new PatternFileFilter.- Parameters:
patternsString- A comma separated list of regular expressions.description- The label to use in the JFileChooser
-
PatternFileFilter
Create a new PatternFileFilter.- Parameters:
patternsString- A comma separated list of regular expressions.description- The label to use in the JFileChoosersuffix- The preferred suffix if none is provided.
-
PatternFileFilter
Create a new PatternFileFilter.- Parameters:
patternsString- A comma separated list of regular expressions.
-
PatternFileFilter
Create a new PatternFileFilter.- Parameters:
patternsString- A comma separated list of regular expressions.dirsOk- Are directories ok to display.
-
PatternFileFilter
Create a new PatternFileFilter.- Parameters:
patternsString- A comma separated list of regular expressions.dirsOk- Are directories ok to display.hiddenOk- true if hidden files are okay.
-
PatternFileFilter
Create a new PatternFileFilter.- Parameters:
patternsString- A comma separated list of regular expressions.id- An arbitary Object for client code to use.description- The label to use in the JFileChooser
-
PatternFileFilter
Create a new PatternFileFilter.- Parameters:
patternsString- A comma separated list of regular expressions.id- An arbitary Object for client code to use.description- The label to use in the JFileChoosersuffix- The preferred suffix if none is provided.
-
-
Method Details
-
createFilters
Parse the given string and return a list of PatternFileFilter-s The string is a ";" delimited list of pattern specifications of the form: pattern":"description or: just the pattern. E.g.: ".*\.nc:Netcdf files;.*\.html;.*\.txt:Text files"- Parameters:
filterString- The string of semi-colon delimited filters.- Returns:
- List of PatternFileFilter objects.
-
getId
Return the object id.- Returns:
- the object id.
-
toString
Override base class method. -
accept
Does this pattern match the given file.- Specified by:
acceptin interfaceFileFilter- Specified by:
acceptin classFileFilter- Parameters:
file- The given file.- Returns:
- Does this pattern match the given file.
-
accept
Implement the FilenameFilter method- Specified by:
acceptin interfaceFilenameFilter- Parameters:
dir- directory to checkname- name of file- Returns:
- true if we should accept this.
-
match
Does this pattern match the given file.- Parameters:
name- The given file.- Returns:
- Does this pattern match the given file.
-
getDescription
Return the description.- Specified by:
getDescriptionin classFileFilter- Returns:
- the description.
-
setPreferredSuffix
Set the PreferedSuffix property.- Parameters:
value- The new value for PreferedSuffix
-
getPreferredSuffix
Get the PreferredSuffix property.- Returns:
- The PreferredSuffix
-
main
Test- Parameters:
args- Command line args.
-