Java Code Examples for java.io.File.hashCode()

The following are Jave code examples for showing how to use hashCode() of the java.io.File class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: Utils.java   View Source Code Vote up 5 votes
public static int hashCode(final File file) {
    if (SENSITIVE == null) {
        return file.hashCode();
    }
    if (SENSITIVE) {
        // same as in UnixFileSystem
        return file.getPath().hashCode() ^ 1234321;
    } else {
        // same as in Win32FileSystem
        return file.getPath().toLowerCase(Locale.ENGLISH).hashCode() ^ 1234321;
    }
}
 
Example 2
Project: incubator-netbeans   File: DeepListener.java   View Source Code Vote up 5 votes
DeepListener(FileChangeListener listener, File path, FileFilter ff, Callable<Boolean> stop) {
    super(listener, BaseUtilities.activeReferenceQueue());
    this.path = path;
    this.stop = stop;
    this.filter = ff;
    this.hash = 11 * listener.hashCode() + 7 * path.hashCode();
}
 
Example 3
Project: OpenJSharp   File: ProcessBuilder.java   View Source Code Vote up 5 votes
/**
 * Returns a hash code value for this {@code Redirect}.
 * @return a hash code value for this {@code Redirect}
 */
public int hashCode() {
    File file = file();
    if (file == null)
        return super.hashCode();
    else
        return file.hashCode();
}
 
Example 4
Project: jdk8u-jdk   File: ProcessBuilder.java   View Source Code Vote up 5 votes
/**
 * Returns a hash code value for this {@code Redirect}.
 * @return a hash code value for this {@code Redirect}
 */
public int hashCode() {
    File file = file();
    if (file == null)
        return super.hashCode();
    else
        return file.hashCode();
}
 
Example 5
Project: jdk8u-jdk   File: HashCodeEquals.java   View Source Code Vote up 5 votes
static void test(String fn1, String fn2) throws Exception {
    File f1 = new File(fn1);
    File f2 = new File(fn2);
    if (!f1.equals(f2))
        throw new Exception("Instances with equal paths are not equal");
    int h1 = f1.hashCode();
    int h2 = f2.hashCode();
    if (h1 != h2)
        throw new Exception("Hashcodes of equal instances are not equal");
}
 
Example 6
Project: openjdk-jdk10   File: ProcessBuilder.java   View Source Code Vote up 5 votes
/**
 * Returns a hash code value for this {@code Redirect}.
 * @return a hash code value for this {@code Redirect}
 */
public int hashCode() {
    File file = file();
    if (file == null)
        return super.hashCode();
    else
        return file.hashCode();
}
 
Example 7
Project: openjdk-jdk10   File: HashCodeEquals.java   View Source Code Vote up 5 votes
static void test(String fn1, String fn2) throws Exception {
    File f1 = new File(fn1);
    File f2 = new File(fn2);
    if (!f1.equals(f2))
        throw new Exception("Instances with equal paths are not equal");
    int h1 = f1.hashCode();
    int h2 = f2.hashCode();
    if (h1 != h2)
        throw new Exception("Hashcodes of equal instances are not equal");
}
 
Example 8
Project: OpenJSharp   File: OptimisticTypesPersistence.java   View Source Code Vote up 4 votes
private static Object getFileLock(final File file) {
    return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
 
Example 9
Project: openjdk-jdk10   File: OptimisticTypesPersistence.java   View Source Code Vote up 4 votes
private static Object getFileLock(final File file) {
    return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length];
}
 
Example 10
Project: BiglyBT   File: StringInterner.java   View Source Code Vote up 4 votes
public WeakFileEntry(File entry)
{
	// file object with 2 fields, string object with 2 fields, char-array object
	super(entry, entry.hashCode(), 16 + 16 + 8 + entry.getPath().length() * 2);
}