protected void validate ( File file , ValidationOptions option ) { if ( ! file . exists ( ) ) { this . errors . addError ( "file <{}> does not exist in file system" , file . getAbsolutePath ( ) ) ; } else if ( ! file . isFile ( ) ) { this . errors . addError ( "file <{}> is not a file" , file . getAbsolutePath ( ) ) ; } if ( file . isHidden ( ) ) { this . errors . addError ( "file <{}> is a hidden file" , file . getAbsolutePath ( ) ) ; } else { switch ( option ) { case AS_SOURCE : if ( ! file . canRead ( ) ) { this . errors . addError ( "file <{}> is not readable" , file . getAbsolutePath ( ) ) ; } break ; case AS_SOURCE_AND_TARGET : if ( ! file . canRead ( ) ) { this . errors . addError ( "file <{}> is not readable" , file . getAbsolutePath ( ) ) ; } if ( ! file . canWrite ( ) ) { this . errors . addError ( "file <{}> is not writable" , file . getAbsolutePath ( ) ) ; } break ; case AS_TARGET : if ( ! file . canWrite ( ) ) { this . errors . addError ( "file <{}> is not writable" , file . getAbsolutePath ( ) ) ; } break ; } } }
Does the actual validation .