amber.type.server
Class FileDirFilter

java.lang.Object
  |
  +--amber.type.server.FileDirFilter
All Implemented Interfaces:
java.io.FilenameFilter

public class FileDirFilter
extends java.lang.Object
implements java.io.FilenameFilter

This class implements the FilenameFilter interface. It is used by File dialogs to specify only files rather than files/directories. By specifying the correct argument only directories or only files can be selected.

See Also:
FileDialog, FileHandler

Field Summary
protected  java.io.File baseDirectory
          This holds the base directory below which the object will fail the accept.
 
Constructor Summary
FileDirFilter()
          Default Constructor.
FileDirFilter(boolean matchFiles)
          Initialising Constructor.
FileDirFilter(boolean matchFiles, java.lang.String baseDirectory)
          Initialising Constructor.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Tests if a specified file should be included in a file list.
 java.io.File getBaseDirectory()
          This returns the base directory for this filter.
 boolean isFilesOnly()
          Gets the data in the following variable: boolean containing the filter selection state.
protected  boolean isHigherDirectory(java.io.File dir)
          Checks to see if the directory is higher than the base directory.
 void setBaseDirectory(java.io.File directory)
          This sets the base directory for this filter.
 void setFilesOnly(boolean data)
          Sets the data in the following variable: boolean containing the filter selection state.
 java.lang.String toString()
          This function returns the String form of the data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

baseDirectory

protected java.io.File baseDirectory
This holds the base directory below which the object will fail the accept.
Constructor Detail

FileDirFilter

public FileDirFilter()
Default Constructor.

FileDirFilter

public FileDirFilter(boolean matchFiles)
Initialising Constructor.
Parameters:
matchFiles - boolean when true the filter will only return files otherwise will only return directories.

FileDirFilter

public FileDirFilter(boolean matchFiles,
                     java.lang.String baseDirectory)
Initialising Constructor.
Parameters:
matchFiles - boolean when true the filter will only return files otherwise will only return directories.
baseDirectory - String containing the base directory for this object. The filter will fail to accept any file higher than this directory.
Method Detail

isFilesOnly

public boolean isFilesOnly()
Gets the data in the following variable: boolean containing the filter selection state. When true only files are selected. When false only directories.
Returns:
boolean containing the required information.

setFilesOnly

public void setFilesOnly(boolean data)
Sets the data in the following variable: boolean containing the filter selection state. When true only files are selected. When false only directories.
Parameters:
data - boolean containing the data to set the variable to.

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Tests if a specified file should be included in a file list.
Specified by:
accept in interface java.io.FilenameFilter
Parameters:
dir - File directory in which the file was found.
name - String name of the file to test.
Returns:
boolean true if the name should be included in the file list else false.

isHigherDirectory

protected boolean isHigherDirectory(java.io.File dir)
Checks to see if the directory is higher than the base directory.
Parameters:
dir - File containing the directory to check.
Returns:
boolean with the state of the check. true if the input directory is higher than the base directory.

setBaseDirectory

public void setBaseDirectory(java.io.File directory)
This sets the base directory for this filter. ALL files higher than this directory will fail the accept function.
Parameters:
directory - File containing the base directory.

getBaseDirectory

public java.io.File getBaseDirectory()
This returns the base directory for this filter. ALL files higher than this directory will fail the accept function.
Returns:
File containing the base directory.

toString

public java.lang.String toString()
This function returns the String form of the data.
Overrides:
toString in class java.lang.Object
Returns:
String containing the string version of this class.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.