Back to index

wims  3.65+svn20090927
Public Member Functions | Private Member Functions | Private Attributes
fr.ove.utils.GenericFileFilter Class Reference

A file filter for the specified extension. More...

Inheritance diagram for fr.ove.utils.GenericFileFilter:
Inheritance graph
[legend]
Collaboration diagram for fr.ove.utils.GenericFileFilter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GenericFileFilter ()
 The default constructor.
 GenericFileFilter (String type, String extension)
 The constructor.
void setType (String type)
 Sets the file type.
String getType ()
 Gets the file type.
void setExtension (String extension)
 Sets the file extension.
String getExtension ()
 Gets the file extension.
boolean accept (File file)
 Whether the given file is accepted by this filter.
String getDescription ()
 The description of this filter.

Private Member Functions

String getSuffix (File file)
 Gets the suffix of the specified file.

Private Attributes

String type
 The type of files to filter.
String extension
 The extension of files to filter.

Detailed Description

A file filter for the specified extension.

Definition at line 14 of file GenericFileFilter.java.


Constructor & Destructor Documentation

The default constructor.

Builds a text files (with a txt extension) filter.

Definition at line 28 of file GenericFileFilter.java.

                               {
        this("Text", "txt");
    }
fr.ove.utils.GenericFileFilter.GenericFileFilter ( String  type,
String  extension 
) [inline]

The constructor.

Parameters:
typethe file type (e.g. Text, JPEG, etc).
extensionthe file extension (e.g. txt, jpeg, etc).

Definition at line 37 of file GenericFileFilter.java.

                                                            {
        this.type = type;
        this.extension = extension;
    }

Member Function Documentation

Whether the given file is accepted by this filter.

Parameters:
filethe given file.

Definition at line 76 of file GenericFileFilter.java.

                                     {
        boolean accept = file.isDirectory();
        
        if (!accept) {
            String suffix = getSuffix(file);
            if (suffix != null)
                accept = suffix.equals(extension);
        }
        
        return accept;
    }

Here is the call graph for this function:

The description of this filter.

Definition at line 91 of file GenericFileFilter.java.

                                   {
        return type + " Files (*." + extension + ")";
    }

Gets the file extension.

Definition at line 68 of file GenericFileFilter.java.

                                 {
        return extension;
    }
String fr.ove.utils.GenericFileFilter.getSuffix ( File  file) [inline, private]

Gets the suffix of the specified file.

Parameters:
filethe file.

Definition at line 99 of file GenericFileFilter.java.

                                        {
        String path = file.getPath();
        String suffix = null;
        int index = path.lastIndexOf('.');
        if ((index > 0) && (index < (path.length() - 1)))
            suffix = path.substring(index + 1).toLowerCase();
            
        return suffix;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the file type.

Definition at line 53 of file GenericFileFilter.java.

                            {
        return type;
    }
void fr.ove.utils.GenericFileFilter.setExtension ( String  extension) [inline]

Sets the file extension.

Parameters:
extensionthe file extension (e.g. txt, jpeg, etc);

Definition at line 61 of file GenericFileFilter.java.

                                               {
        this.extension = extension;
    }
void fr.ove.utils.GenericFileFilter.setType ( String  type) [inline]

Sets the file type.

Parameters:
typethe file type (e.g. Text, JPEG, etc).

Definition at line 46 of file GenericFileFilter.java.

                                     {
        this.type = type;
    }

Member Data Documentation

The extension of files to filter.

Definition at line 23 of file GenericFileFilter.java.

The type of files to filter.

Definition at line 18 of file GenericFileFilter.java.


The documentation for this class was generated from the following file: