com.huguesjohnson.hapsby
Class SaveGameFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by com.huguesjohnson.hapsby.SaveGameFilter

public class SaveGameFilter
extends javax.swing.filechooser.FileFilter

Customizable filter for save game files.

Author:
Hugues Johnson

Constructor Summary
SaveGameFilter(java.lang.String filePattern, java.lang.String gameTitle)
          Creates a filter based on file pattern passed.
 
Method Summary
 boolean accept(java.io.File f)
          Tests if a file fits the filter defined in the constructor.
 java.lang.String getDescription()
          Returns the description of file accepted by the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaveGameFilter

public SaveGameFilter(java.lang.String filePattern,
                      java.lang.String gameTitle)
Creates a filter based on file pattern passed. Only leading and trailing wildcard characters are accepted. For example: *.txt, name.*, and *.da* are all acceptible, but qw*.ert is not.

Parameters:
filePattern - Pattern, or specific name, to apply to filter.
gameTitle - Title of game the pattern is for, used to set the description.
Method Detail

accept

public boolean accept(java.io.File f)
Tests if a file fits the filter defined in the constructor.

Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
f - The file to check.
Returns:
True if the file path matches the defined filter or is a directory, false if it does not match the filter.

getDescription

public java.lang.String getDescription()
Returns the description of file accepted by the filter.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
The description of file accepted by the filter.


Copyright © 2000-2009 Hugues Johnson