Example usage for org.apache.commons.io IOCase checkEquals

List of usage examples for org.apache.commons.io IOCase checkEquals

Introduction

In this page you can find the example usage for org.apache.commons.io IOCase checkEquals.

Prototype

public boolean checkEquals(String str1, String str2) 

Source Link

Document

Compares two strings using the case-sensitivity rule.

Usage

From source file:com.matteoveroni.model.copy.FilenameUtils.java

/**
 * Checks whether two filenames are equal, optionally normalizing and providing
 * control over the case-sensitivity.//from ww w . j ava  2  s  .co m
 *
 * @param filename1  the first filename to query, may be null
 * @param filename2  the second filename to query, may be null
 * @param normalized  whether to normalize the filenames
 * @param caseSensitivity  what case sensitivity rule to use, null means case-sensitive
 * @return true if the filenames are equal, null equals null
 * @since 1.3
 */
public static boolean equals(String filename1, String filename2, boolean normalized, IOCase caseSensitivity) {

    if (filename1 == null || filename2 == null) {
        return filename1 == null && filename2 == null;
    }
    if (normalized) {
        filename1 = normalize(filename1);
        filename2 = normalize(filename2);
        if (filename1 == null || filename2 == null) {
            throw new NullPointerException("Error normalizing one or both of the file names");
        }
    }
    if (caseSensitivity == null) {
        caseSensitivity = IOCase.SENSITIVE;
    }
    return caseSensitivity.checkEquals(filename1, filename2);
}