uic.widgets.filechooser
Class UICFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by uic.widgets.filechooser.AbstractFileFilter
          extended by uic.widgets.filechooser.UICFileFilter
All Implemented Interfaces:
FileFilter

public class UICFileFilter
extends AbstractFileFilter

A fileFilter that allows you to filter files on regular expressions. Notice that this class also combines an abtract javax.swing.filechooser.FileFilter (with no implementation, which effectively makes it the same as an interface) and the java.io.FileFilter is a real interface, with the same methods but has the first has no reference to the second.

Lets just say that the good authors at Sun missed the obvious; one should extend or implement the other. This class therefor is a good basis to extend further file filters from.

Since:
2.0

Constructor Summary
UICFileFilter(String description, Pattern p)
          Create a FileFilter which matches any file on a regular expression.
UICFileFilter(String description, Pattern p, boolean acceptDirectories)
          Create a FileFilter which matches any file on a regular expression.
UICFileFilter(String description, String regularExpression)
          Create a FileFilter which matches any file on a regular expression.
 
Method Summary
 boolean accept(File f)
          Returns true if the file is accepted by this filter.
 
Methods inherited from class uic.widgets.filechooser.AbstractFileFilter
getDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UICFileFilter

public UICFileFilter(String description,
                     String regularExpression)
              throws PatternSyntaxException
Create a FileFilter which matches any file on a regular expression.

Parameters:
description - the description which will be used in the combo-box of the filechooser.
regularExpression - a correctly formatted regular expression which will be used case incensitive on each filename. Regular expressions are very powerfull and can quickly get unreadable to the untrained eye. Common pitfalls: 1) you need to specify the full name, not a part of it. Add .*around your regular expression if you want just a part of the string.
Throws:
PatternSyntaxException
See Also:
Pattern

UICFileFilter

public UICFileFilter(String description,
                     Pattern p)
Create a FileFilter which matches any file on a regular expression.

Parameters:
description - the description which will be used in the combo-box of the filechooser.
p - a pre-compiled regular-expression pattern. Regular expressions are very powerfull and can quickly get unreadable to the untrained eye. Common pitfalls: 1) you need to specify the full name, not a part of it. Add .*around your regular expression if you want just a part of the string.
See Also:
Pattern

UICFileFilter

public UICFileFilter(String description,
                     Pattern p,
                     boolean acceptDirectories)
Create a FileFilter which matches any file on a regular expression.

Parameters:
description - the description which will be used in the combo-box of the filechooser.
p - a pre-compiled regular-expression pattern. Regular expressions are very powerfull and can quickly get unreadable to the untrained eye. Common pitfalls: 1) you need to specify the full name, not a part of it. Add .*around your regular expression if you want just a part of the string.
acceptDirectories - should directories be accepted
See Also:
Pattern
Method Detail

accept

public boolean accept(File f)
Returns true if the file is accepted by this filter.

Specified by:
accept in interface FileFilter
Specified by:
accept in class FileFilter
Returns:
true if the file is accepted by the pattern provided in the constructor


Copyright © 2002-2004 Thomas Zander Available under the Free Apache licence