public class SuffixFilter
extends javax.swing.filechooser.FileFilter
implements java.io.FileFilter
JFileChooser
objects and for use with
File
objects (interface FileFilter
).
The String[]
parameter may contain file suffices to be recognized. The description
parameter denotes little metadata for the user.
The parameter suffices may contain "class" or "CLASS" for Java class file suffices for example.
It is not case sensitive, the lower-case forms will be used for checking. The second parameter
could be something like "Java CLASS (*.class, *.CLASS)" for Java class files.
This class is used by TransformationPlugIn
implementations. The BDTTumorTrafo for
CARAMEL 2000 for example exports the instance of this class which accepts BDT files.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
description
Description of the type represented by filter instances.
|
protected java.lang.String |
id
Unique ID for the represented file format ("png", "gif" etc.)
|
protected java.lang.String |
pattern
Pattern to be matched,
suffices is set otherwise. |
static int |
PATTERN_REGEX
Represents the regex pattern.
|
static int |
PATTERN_SIMPLE_WITH_CASE
Represents the simple pattern (case sensitive).
|
static int |
PATTERN_SIMPLE_WITHOUT_CASE
Represents the simple pattern (case insensitive).
|
protected java.lang.String[] |
suffices
Array with suffices to be used,
pattern is set otherwise. |
protected int |
type
The pattern type (
PATTERN_SIMPLE_WITHOUT_CASE |...). |
Constructor and Description |
---|
SuffixFilter()
Constructor method for i18n purposes only.
|
SuffixFilter(java.lang.String[] suffices,
java.lang.String description,
boolean autosuffix,
java.lang.String id)
Classic constructor based on the simple pattern type (case insensitive).
|
SuffixFilter(java.lang.String pattern,
int type,
java.lang.String description,
boolean autosuffix,
java.lang.String id)
Enhanced constructor to build a more configurable filter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File file)
Extends the
FileFilter class. |
boolean |
accept(org.apache.commons.vfs2.FileObject url)
Extends the
FileFilter class. |
boolean |
accept(java.lang.String filename)
Extends the
FileFilter class. |
static boolean |
checkPatternType(int type)
Convenience method to check a given pattern type against the available types.
|
static SuffixFilter |
createAcceptAllFileFilter(boolean autosuffix)
Convenience method to create the "accept all" file filter.
|
boolean |
equals(SuffixFilter tocheck)
Checks whether another
SuffixFilter instance does the same job. |
java.lang.String |
getDescription()
Extends the
FileFilter class. |
java.lang.String |
getID()
Getter for the ID.
|
java.lang.String |
getPattern()
Getter for the pattern.
|
java.lang.String[] |
getSuffices()
Exports the internal array of suffices (
String objects). |
java.lang.String |
getSufficesList()
Exports the internal array of suffices.
|
int |
getType()
Getter for the type.
|
boolean |
hasSuffices()
Checks if this object is based on suffices instead of patterns.
|
java.lang.String |
toString()
Prints the file filter name.
|
public static final int PATTERN_SIMPLE_WITHOUT_CASE
public static final int PATTERN_SIMPLE_WITH_CASE
public static final int PATTERN_REGEX
protected java.lang.String[] suffices
pattern
is set otherwise.protected java.lang.String description
protected int type
PATTERN_SIMPLE_WITHOUT_CASE
|...).protected java.lang.String pattern
suffices
is set otherwise.protected java.lang.String id
public SuffixFilter() throws java.lang.InstantiationException
I18NExtractor
).
java.lang.InstantiationException
- Error indicationpublic SuffixFilter(java.lang.String[] suffices, java.lang.String description, boolean autosuffix, java.lang.String id)
suffices
- These suffices shall be recognizeddescription
- The description for the combo boxautosuffix
- Add the suffices automatically like [class] -> "(*.class)" ?id
- Unique ID for the represented file format ("png", "gif" etc.)public SuffixFilter(java.lang.String pattern, int type, java.lang.String description, boolean autosuffix, java.lang.String id)
pattern
- The pattern to be matchedtype
- The pattern type (PATTERN_SIMPLE_WITHOUT_CASE
|...)description
- The description for the combo boxautosuffix
- Add the suffices automatically like [class] -> "(*.class)" ?id
- Unique ID for the represented file format ("png", "gif" etc.)java.lang.IllegalArgumentException
- If a parameter is invalidpublic boolean accept(java.io.File file)
FileFilter
class.
accept
in interface java.io.FileFilter
accept
in class javax.swing.filechooser.FileFilter
file
- The file checkpublic boolean accept(org.apache.commons.vfs2.FileObject url)
FileFilter
class.
url
- The URL checkpublic boolean accept(java.lang.String filename)
FileFilter
class.
filename
- The filename to check (without path)public java.lang.String getDescription()
FileFilter
class.
getDescription
in class javax.swing.filechooser.FileFilter
public java.lang.String[] getSuffices()
String
objects).
String
array, may be null
if pattern is usedpublic java.lang.String getSufficesList()
null
if pattern is usedgetPattern()
public boolean equals(SuffixFilter tocheck)
SuffixFilter
instance does the same job.
We check both the suffices and the type description for this.
tocheck
- The other SuffixFilter
to be checkedpublic java.lang.String toString()
toString
in class java.lang.Object
public static SuffixFilter createAcceptAllFileFilter(boolean autosuffix)
autosuffix
- Add the suffices automatically like [class] -> "(*.class)" ?public static boolean checkPatternType(int type)
type
- The pattern typepublic int getType()
PATTERN_SIMPLE_WITHOUT_CASE
|...)public java.lang.String getPattern()
suffices
is set otherwisegetSufficesList()
public boolean hasSuffices()
public java.lang.String getID()
Copyright © 2005-2023 Leisenfels GmbH. All rights reserved.