com.sun.interview
Class ExtensionFileFilter

java.lang.Object
  extended by com.sun.interview.ExtensionFileFilter
All Implemented Interfaces:
FileFilter

public class ExtensionFileFilter
extends java.lang.Object
implements FileFilter

A filter which accepts files based on their extension.


Constructor Summary
ExtensionFileFilter(java.lang.String[] extns, java.lang.String description)
          Create a filter which accepts files based on their extension.
ExtensionFileFilter(java.lang.String extn, java.lang.String description)
          Create a filter which accepts files based on their extension.
 
Method Summary
 boolean accept(java.io.File f)
          Check if a file is accepted by this filter.
 boolean acceptsDirectories()
          Check if (all) directories are accepted by this filter.
 java.io.File ensureExtension(java.io.File file)
          Ensure that a filename ends with one of the extensions accepted by this filter.
 java.lang.String ensureExtension(java.lang.String path)
          Ensure that a pathname ends with one of the extensions accepted by this filter.
 java.lang.String getDescription()
          Get a short description for this filter.
 boolean isCaseSensitive()
          Check whether or not this filter should perform case-sensitive matching for extensions.
 void setCaseSensitive(boolean b)
          Specify whether or not this filter should perform case-sensitive matching for extensions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionFileFilter

public ExtensionFileFilter(java.lang.String extn,
                           java.lang.String description)
Create a filter which accepts files based on their extension.

Parameters:
extn - The required extension for files that are to be accepted by this filter.
description - A short string describing the filter.

ExtensionFileFilter

public ExtensionFileFilter(java.lang.String[] extns,
                           java.lang.String description)
Create a filter which accepts files based on their extension.

Parameters:
extns - Any array of permissible extensions for files that are to be accepted by this filter.
description - A short string describing the filter.
Method Detail

setCaseSensitive

public void setCaseSensitive(boolean b)
Specify whether or not this filter should perform case-sensitive matching for extensions.

Parameters:
b - true if this filter should perform case-sensitive matching for extensions, and false otherwise
See Also:
isCaseSensitive()

isCaseSensitive

public boolean isCaseSensitive()
Check whether or not this filter should perform case-sensitive matching for extensions.

Returns:
true if this filter should perform case-sensitive matching for extensions, and false otherwise
See Also:
setCaseSensitive(boolean)

accept

public boolean accept(java.io.File f)
Description copied from interface: FileFilter
Check if a file is accepted by this filter.

Specified by:
accept in interface FileFilter
Parameters:
f - The file to be tested.
Returns:
true if the file is accepted by this filter

acceptsDirectories

public boolean acceptsDirectories()
Description copied from interface: FileFilter
Check if (all) directories are accepted by this filter.

Specified by:
acceptsDirectories in interface FileFilter
Returns:
true if directories are accepted by this filter

getDescription

public java.lang.String getDescription()
Get a short description for this filter.

Specified by:
getDescription in interface FileFilter
Returns:
a short description of this filter

ensureExtension

public java.lang.String ensureExtension(java.lang.String path)
Ensure that a pathname ends with one of the extensions accepted by this filter. If it does not, one is appended

Parameters:
path - The path to be checked.
Returns:
the original path if it already ended with a valid extension, or if it was null or empty; otherwise, a copy of the path is returned, with a valid extension added on.

ensureExtension

public java.io.File ensureExtension(java.io.File file)
Ensure that a filename ends with one of the extensions accepted by this filter. If it does not, one is appended

Parameters:
file - The file to be checked.
Returns:
the original file if it already ended with a valid extension, or if it was null or empty; otherwise, a new file is returned, whose path is a copy of the original, with a valid extension added on.


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.