Package ghidra.util.filechooser
Class ExtensionFileFilter
- java.lang.Object
-
- ghidra.util.filechooser.ExtensionFileFilter
-
- All Implemented Interfaces:
GhidraFileFilter
public class ExtensionFileFilter extends java.lang.Object implements GhidraFileFilter
A convenience implementation of FileFilter that filters out all files except for those type extensions that it knows about.Extensions are of the type "foo" (no leading dot). Case is ignored.
Example - create a new filter that filters out all files but gif and jpg image files:
GhidraFileChooser chooser = new GhidraFileChooser(); chooser.addFileFilter(ExtensionFilFilter.forExtensions("JPEG and GIF Images", "gif", "jpg"));
-
-
Field Summary
-
Fields inherited from interface ghidra.util.filechooser.GhidraFileFilter
ALL
-
-
Constructor Summary
Constructors Constructor Description ExtensionFileFilter(java.lang.String[] filters, java.lang.String description)Creates a file filter from the given string array and description.ExtensionFileFilter(java.lang.String extension, java.lang.String description)Creates a file filter that accepts the given file type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(java.io.File f, GhidraFileChooserModel model)Return true if this file should be shown in the directory pane, false if it shouldn't.static ExtensionFileFilterforExtensions(java.lang.String description, java.lang.String... exts)Creates aExtensionFileFilterin a varargs friendly way.java.lang.StringgetDescription()Returns the description of this filter.
-
-
-
Constructor Detail
-
ExtensionFileFilter
public ExtensionFileFilter(java.lang.String extension, java.lang.String description)Creates a file filter that accepts the given file type. Example: new ExtensionFileFilter("jpg", "JPEG Images");- Parameters:
extension- file extension to match, without leading dotdescription- descriptive string of the filter
-
ExtensionFileFilter
public ExtensionFileFilter(java.lang.String[] filters, java.lang.String description)Creates a file filter from the given string array and description. Example: new ExtensionFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");- Parameters:
filters- array of file name extensions, each without a leading dotdescription- descriptive string of the filter
-
-
Method Detail
-
forExtensions
public static ExtensionFileFilter forExtensions(java.lang.String description, java.lang.String... exts)
Creates aExtensionFileFilterin a varargs friendly way.- Parameters:
description- String description of this set of file extensions.exts- variable length list of file extensions, without leading dot.- Returns:
- new
ExtensionFileFilterinstance.
-
accept
public boolean accept(java.io.File f, GhidraFileChooserModel model)Return true if this file should be shown in the directory pane, false if it shouldn't. Files that begin with "." are ignored.- Specified by:
acceptin interfaceGhidraFileFilter- Parameters:
f- The abstract pathname to be testedmodel- The underlying file chooser model- Returns:
trueif and only ifpathnameshould be included- See Also:
FileFilter.accept(java.io.File)
-
getDescription
public java.lang.String getDescription()
Description copied from interface:GhidraFileFilterReturns the description of this filter.- Specified by:
getDescriptionin interfaceGhidraFileFilter- Returns:
- the description of this filter
-
-