com.gridsystems.config.tools
Class FileVerifier

java.lang.Object
  extended by javax.swing.InputVerifier
      extended by com.gridsystems.config.tools.TextVerifier
          extended by com.gridsystems.config.tools.FileVerifier

public class FileVerifier
extends TextVerifier

Verifies that a String is a valid path to a file that exists. Verifies that a String is a valid path to a file that exists. Also checks the file type. Subclasses of this class can refine the filter by reimplementing the checkPattern(File) method.

Author:
SJM

Field Summary
static int DIRECTORIES_ONLY
          Allows only directories.
static int FILE_ALL
          Allows paths to existing and non-existing files.
static int FILE_EXIST
          Allows paths to existing files.
static int FILE_NOT_EXIST
          Allows paths to non-existing files.
static int FILES_AND_DIRECTORIES
          Allows both files and directories.
static int FILES_ONLY
          Allows only files.
protected  java.lang.String id
          Error identifier.
static java.lang.String ID_ERROR
          Errors detected by this verifier.
 
Fields inherited from class com.gridsystems.config.tools.TextVerifier
support
 
Constructor Summary
FileVerifier(ErrorSupport support, java.lang.String id)
          Creates an instance.
FileVerifier(ErrorSupport support, java.lang.String id, int mode, int constraint)
          Creates an instance.
 
Method Summary
 boolean checkPattern(java.io.File file)
          Checks the restrictions in the file name/path.
 void cleanErrors()
          Removes from the error support manager the list of errors of this verifier.
 boolean verify(java.lang.String text)
          Validates a text string.
 
Methods inherited from class com.gridsystems.config.tools.TextVerifier
updateError, verify
 
Methods inherited from class javax.swing.InputVerifier
shouldYieldFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_ERROR

public static final java.lang.String ID_ERROR
Errors detected by this verifier.

See Also:
Constant Field Values

FILES_AND_DIRECTORIES

public static final int FILES_AND_DIRECTORIES
Allows both files and directories.

See Also:
Constant Field Values

FILES_ONLY

public static final int FILES_ONLY
Allows only files.

See Also:
Constant Field Values

DIRECTORIES_ONLY

public static final int DIRECTORIES_ONLY
Allows only directories.

See Also:
Constant Field Values

FILE_ALL

public static final int FILE_ALL
Allows paths to existing and non-existing files.

See Also:
Constant Field Values

FILE_EXIST

public static final int FILE_EXIST
Allows paths to existing files.

See Also:
Constant Field Values

FILE_NOT_EXIST

public static final int FILE_NOT_EXIST
Allows paths to non-existing files.

See Also:
Constant Field Values

id

protected java.lang.String id
Error identifier.

Constructor Detail

FileVerifier

public FileVerifier(ErrorSupport support,
                    java.lang.String id)
Creates an instance.

Parameters:
support - The ErrorSupport instance
id - The error identifier

FileVerifier

public FileVerifier(ErrorSupport support,
                    java.lang.String id,
                    int mode,
                    int constraint)
Creates an instance.

Parameters:
support - The Error support instance
id - The error identifier
mode - The type of files that will be accepted. Valid values are FILES_AND_DIRECTORIES, DIRECTORIES_ONLY, and FILES_ONLY. If it is neither of them, it defaults to FILES_AND_DIRECTORIES
constraint - The existence checks that the files must pass to be accepted. It can be FILE_ALL, FILE_EXIST and FILE_NOT_EXIST. If it is neither of them, it defaults to FILE_ALL
Method Detail

verify

public boolean verify(java.lang.String text)
Validates a text string.

Specified by:
verify in class TextVerifier
Parameters:
text - The string to validate
Returns:
true if the text is valid

cleanErrors

public void cleanErrors()
Description copied from class: TextVerifier
Removes from the error support manager the list of errors of this verifier.

This method will be used on field deactivation.

Specified by:
cleanErrors in class TextVerifier
See Also:
TextVerifier.cleanErrors()

checkPattern

public boolean checkPattern(java.io.File file)
Checks the restrictions in the file name/path. Checks the restrictions in the file name/path. This basic implementation allways returns true; subclasses of FileVerifier that need pattern match can reimplement this method. The files that cause this method to return false will cause the verification to fail.

Parameters:
file - the File object to check.
Returns:
a boolean that is true if and only if the file matches the desired pattern/s.


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.