public static void compare ( final IFileCompareResultBean fileCompareResultBean , final boolean ignoreAbsolutePathEquality , final boolean ignoreExtensionEquality , final boolean ignoreLengthEquality , final boolean ignoreLastModified , final boolean ignoreNameEquality ) { final File source = fileCompareResultBean . getSourceFile ( ) ; final File compare = fileCompareResultBean . getFileToCompare ( ) ; if ( ! ignoreAbsolutePathEquality ) { // check the absolute path from the files... final String sourceAbsolutePath = source . getAbsolutePath ( ) ; final String compareAbsolutePath = compare . getAbsolutePath ( ) ; final boolean absolutePathEquality = sourceAbsolutePath . equals ( compareAbsolutePath ) ; fileCompareResultBean . setAbsolutePathEquality ( absolutePathEquality ) ; } else { fileCompareResultBean . setAbsolutePathEquality ( true ) ; } if ( ! ignoreExtensionEquality ) { // check the file extension... final String sourceFileExtension = FileExtensions . getFilenameSuffix ( source ) ; final String compareFileExtension = FileExtensions . getFilenameSuffix ( compare ) ; final boolean extensionEquality = compareFileExtension . equalsIgnoreCase ( sourceFileExtension ) ; fileCompareResultBean . setFileExtensionEquality ( extensionEquality ) ; } else { fileCompareResultBean . setFileExtensionEquality ( true ) ; } if ( ! ignoreLengthEquality ) { // check the file length... final boolean length = source . length ( ) == compare . length ( ) ; fileCompareResultBean . setLengthEquality ( length ) ; } else { fileCompareResultBean . setLengthEquality ( true ) ; } if ( ! ignoreLastModified ) { // check the last modified date... final boolean lastModified = source . lastModified ( ) == compare . lastModified ( ) ; fileCompareResultBean . setLastModifiedEquality ( lastModified ) ; } else { fileCompareResultBean . setLastModifiedEquality ( true ) ; } if ( ! ignoreNameEquality ) { // check the filename... final String sourceFilename = FileExtensions . getFilenameWithoutExtension ( source ) ; final String compareFilename = FileExtensions . getFilenameWithoutExtension ( compare ) ; final boolean nameEquality = compareFilename . equalsIgnoreCase ( sourceFilename ) ; fileCompareResultBean . setNameEquality ( nameEquality ) ; } else { fileCompareResultBean . setNameEquality ( true ) ; } }
Sets the flags in the FileCompareResultBean object according to the given boolean flag what to ignore .