class IrisFileName {

   public static boolean isValid(String fileName) {
      if (fileName == null) return false;

      //. and .. have special meaning on all platforms
      if (fileName.equals(".") || fileName.equals("..")) return false;

      //empty names are not valid
      final int length = fileName.length();
      if (length == 0 || length > MAX_FILENAME_LENGTH) return false;

      final char lastChar = fileName.charAt(length - 1);
      // filenames ending in dot are not valid
      if (lastChar == '.') return false;

      //file names ending with whitespace are truncated
      if (Character.isWhitespace(lastChar)) return false;

      //if the file name contains an invalid character
      if (containsInvalidCharacter(fileName)) return false;

      int dot = fileName.indexOf('.');
      //on windows, filename suffixes are not relevant to name validity
      String basename = dot == -1 ? fileName : fileName.substring(0, dot);
      if (Arrays.binarySearch(INVALID_RESOURCE_BASENAMES, basename.toLowerCase()) >= 0) {
         return false;
      }

      return Arrays.binarySearch(INVALID_RESOURCE_FULLNAMES, fileName.toLowerCase()) < 0;
   }

}