visualmodeler
Class DefaultFileFilter

Object
  |
  +--javax.swing.filechooser.FileFilter
        |
        +--visualmodeler.DefaultFileFilter

public class DefaultFileFilter
extends javax.swing.filechooser.FileFilter

A DefaultFileFilter, once implemented, can be set on a JFileChooser to keep unwanted files from appearing in the directory listing.

Version:
1.1
Author:
Anthony Sulistio and Chee Shin Yeo
Invariant:
$none

Constructor Summary
DefaultFileFilter(String[] ext, String desc)
          Overloaded method.
DefaultFileFilter(String ext, String desc)
          Constructs a default file filter to filter a file extension
 
Method Summary
 boolean accept(File file)
          Checks whether the given file is accepted by this filter or not
 String getDescription()
          Gets the description of this filter
 String getExtension(File file)
          Gets the file extension of a given File object
 String getFileNameOnly(String fileName)
          Gets the file name without its file extension
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileFilter

public DefaultFileFilter(String ext,
                         String desc)
Constructs a default file filter to filter a file extension

Parameters:
ext - File extension to filter
desc - Description of this filter, eg. "JPG and GIF Images"
Pre Condition:
ext != null, desc != null
Post Condition:
$none

DefaultFileFilter

public DefaultFileFilter(String[] ext,
                         String desc)
Overloaded method. Constructs a default file filter to filter file extensions.

Parameters:
ext - File extensions to filter
desc - Description of this filter, eg. "JPG and GIF Images"
Pre Condition:
ext != null, desc != null
Post Condition:
$none
Method Detail

accept

public boolean accept(File file)
Checks whether the given file is accepted by this filter or not

Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
file - A File object
Returns:
true if it is accepted, false otherwise.
Pre Condition:
$none
Post Condition:
$none

getExtension

public String getExtension(File file)
Gets the file extension of a given File object

Parameters:
file - A File extension
Returns:
file extension or null if the given file is empty.
Pre Condition:
$none
Post Condition:
$none

getFileNameOnly

public String getFileNameOnly(String fileName)
Gets the file name without its file extension

Parameters:
fileName - A filename with file extension
Returns:
a filename without file extension
Pre Condition:
$none
Post Condition:
$none

getDescription

public String getDescription()
Gets the description of this filter

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
description
Pre Condition:
$none
Post Condition:
$none