org.devaki.nextobjects.util
Class NOFileFilter

java.lang.Object
  extended byjavax.swing.filechooser.FileFilter
      extended byorg.devaki.nextobjects.util.NOFileFilter

public class NOFileFilter
extends javax.swing.filechooser.FileFilter

FileFilter that filters out all files except for those type extensions Extensions are of the type ".foo", which is typically found on Windows and Unix boxes, but not on Macinthosh. Case is ignored. Example - create a new filter that filerts out all files but gif and jpg image files: JFileChooser chooser = new JFileChooser(); ExampleFileFilter filter = new ExampleFileFilter( new String{"gif", "jpg"}, "JPEG & GIF Images") chooser.addChoosableFileFilter(filter); chooser.showOpenDialog(this);

Author:
Emmanuel Florent

Constructor Summary
NOFileFilter()
          Creates a file filter.
NOFileFilter(java.lang.String extension)
          Creates a file filter that accepts files with the given extension.
NOFileFilter(java.lang.String[] pFilters)
          Creates a file filter from the given string array.
NOFileFilter(java.lang.String[] pFilters, java.lang.String pDescription)
          Creates a file filter from the given string array and description.
NOFileFilter(java.lang.String extension, java.lang.String pDescription)
          Creates a file filter that accepts the given file type.
 
Method Summary
 boolean accept(java.io.File f)
          Return true if this file should be shown in the directory pane, false if it shouldn't.
 void addExtension(java.lang.String extension)
          Adds a filetype "dot" extension to filter against.
 java.lang.String getDescription()
          Returns the human readable description of this filter.
 java.lang.String getExtension(java.io.File f)
          Return the extension portion of the file's name .
 boolean isExtensionListInDescription()
          Returns whether the extension list (.jpg, .gif, etc) should show up in the human readable description.
 void setDescription(java.lang.String pDescription)
          Sets the human readable description of this filter.
 void setExtensionListInDescription(boolean b)
          Determines whether the extension list (.jpg, .gif, etc) should show up in the human readable description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NOFileFilter

public NOFileFilter()
Creates a file filter. If no filters are added, then all files are accepted.

See Also:
addExtension(java.lang.String)

NOFileFilter

public NOFileFilter(java.lang.String extension)
Creates a file filter that accepts files with the given extension. Example: new ExampleFileFilter("jpg");

Parameters:
extension - Description of the Parameter
See Also:
addExtension(java.lang.String)

NOFileFilter

public NOFileFilter(java.lang.String extension,
                    java.lang.String pDescription)
Creates a file filter that accepts the given file type. Example: new ExampleFileFilter("jpg", "JPEG Image Images"); Note that the "." before the extension is not needed. If provided, it will be ignored.

Parameters:
extension - Description of the Parameter
pDescription - Description of the Parameter
See Also:
addExtension(java.lang.String)

NOFileFilter

public NOFileFilter(java.lang.String[] pFilters)
Creates a file filter from the given string array. Example: new ExampleFileFilter(String {"gif", "jpg"}); Note that the "." before the extension is not needed adn will be ignored.

Parameters:
pFilters - Description of the Parameter
See Also:
addExtension(java.lang.String)

NOFileFilter

public NOFileFilter(java.lang.String[] pFilters,
                    java.lang.String pDescription)
Creates a file filter from the given string array and description. Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images"); Note that the "." before the extension is not needed and will be ignored.

Parameters:
pFilters - filters
pDescription - description
See Also:
addExtension(java.lang.String)
Method Detail

accept

public final boolean accept(java.io.File f)
Return true if this file should be shown in the directory pane, false if it shouldn't. Files that begin with "." are ignored.

Parameters:
f - file
Returns:
accept
See Also:
getExtension(java.io.File), FileFilter#accepts

getExtension

public final java.lang.String getExtension(java.io.File f)
Return the extension portion of the file's name .

Parameters:
f - file
Returns:
extension
See Also:
getExtension(java.io.File), FileFilter.accept(java.io.File)

addExtension

public final void addExtension(java.lang.String extension)
Adds a filetype "dot" extension to filter against. For example: the following code will create a filter that filters out all files except those that end in ".jpg" and ".tif": ExampleFileFilter filter = new ExampleFileFilter(); filter.addExtension("jpg"); filter.addExtension("tif"); Note that the "." before the extension is not needed and will be ignored.

Parameters:
extension - extension

getDescription

public final java.lang.String getDescription()
Returns the human readable description of this filter. For example: "JPEG and GIF Image Files (*.jpg, *.gif)"

Returns:
description
See Also:
setDescription, setExtensionListInDescription, isExtensionListInDescription, FileFilter.getDescription()

setDescription

public final void setDescription(java.lang.String pDescription)
Sets the human readable description of this filter. For example: filter.setDescription("Gif and JPG Images");

Parameters:
pDescription - description
See Also:
setDescription, setExtensionListInDescription, isExtensionListInDescription

setExtensionListInDescription

public final void setExtensionListInDescription(boolean b)
Determines whether the extension list (.jpg, .gif, etc) should show up in the human readable description. Only relevent if a description was provided in the constructor or using setDescription();

Parameters:
b - ExtensionListInDescription
See Also:
getDescription, setDescription, isExtensionListInDescription

isExtensionListInDescription

public final boolean isExtensionListInDescription()
Returns whether the extension list (.jpg, .gif, etc) should show up in the human readable description. Only relevent if a description was provided in the constructor or using setDescription();

Returns:
isExtensionListInDescription
See Also:
getDescription, setDescription, setExtensionListInDescription


Copyright © 2002-2004 devaki.org. All Rights Reserved.