/** * This method is equivalent to calling {@link #equals(Object, boolean, boolean)} with credentials and properties * comparisons enabled. * * @param o object to compare against this FileURL instance. * @return true if both FileURL instances are equal. */ public boolean equals(Object o) { return equals(o, true, true); }
@Override public boolean equals(Object obj) { if (obj instanceof RecentLocation) return url.equals(((RecentLocation) obj).url); return false; } }
/** * Returns <code>true</code> if the given Object is a {@link com.mucommander.auth.CredentialsMapping} instance * whose credentials and realm are equals to those of this instance. * * @param o the Object to test for equality * @return true if both CredentialsMapping instances are equal */ public boolean equals(Object o) { if(!(o instanceof CredentialsMapping)) // Note: CredentialsMapping is final, no need to test classes return false; CredentialsMapping cm = (CredentialsMapping)o; return cm.credentials.equals(this.credentials, false) && cm.realm.equals(this.realm, false, true); }
/** * Asserts that both URLs are not equal, comparing credentials and properties as requested. * * @param url1 first url to test * @param url2 second url to test * @param compareCredentials if <code>true</code>, the login and password parts of both FileURL need to be * equal (case-sensitive) for the FileURL instances to be equal * @param compareProperties if <code>true</code>, all properties need to be equal (case-sensitive) in both * FileURL for them to be equal */ protected void assertNotEquals(FileURL url1, FileURL url2, boolean compareCredentials, boolean compareProperties) { assert !url1.equals(url2, compareCredentials, compareProperties); assert !url2.equals(url1, compareCredentials, compareProperties); }
@Override public boolean equals(Object obj) { if (obj instanceof FileTableTab) { FileTableTab other = (FileTableTab) obj; return location.equals(other.getLocation()) && locked == other.isLocked(); } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof FileTableTab) { FileTableTab other = ((FileTableTab) obj); return location.equals(other.getLocation()) && locked == ((FileTableTab) obj).isLocked(); } return false; }
/** * Returns <code>true</code> if both the given realm and credentials are equal to those of this ConnectionHandler. * The credentials comparison is password-sensitive. * * @param realm the FileURL to compare against this ConnectionHandler's * @param credentials the Credentials to compare against this ConnectionHandler's * @return true if both the given realm and credentials are equal to those of this ConnectionHandler * @see Credentials#equals(Object, boolean) */ public boolean equals(FileURL realm, Credentials credentials) { if(!this.realm.equals(realm, false, true)) return false; // Compare credentials. One or both Credentials instances may be null. // Note: Credentials.equals() considers null as equal to empty Credentials (see Credentials#isEmpty()) return (this.credentials==null && credentials==null) || (this.credentials!=null && this.credentials.equals(credentials, true)) || (credentials!=null && credentials.equals(this.credentials, true)); }
@Override public RecentLocation[] getData() { List<RecentLocation> list = new LinkedList<RecentLocation>(); for (FileURL url : GlobalLocationHistory.Instance().getHistory()) { // Don't include the currently presented location in the list if (!url.equals(folderPanel.getCurrentFolder().getURL())) list.add(0, new RecentLocation(url)); } return list.toArray(new RecentLocation[0]); }
/** * Tests a file for equality by comparing both files' {@link #getURL() URL}. Returns <code>true</code> if the URL * of this file and the specified one are equal according to {@link FileURL#equals(Object, boolean, boolean)} called * with credentials and properties comparison enabled. * * <p> * Unlike {@link #equalsCanonical(Object)}, this method <b>is not</b> allowed to perform I/O operations and block * the caller thread. * </p> * * @param o the object to compare against this instance * @return Returns <code>true</code> if the URL of this file and the specified one are equal * @see FileURL#equals(Object, boolean, boolean) * @see #equalsCanonical(Object) */ public boolean equals(Object o) { if(o==null || !(o instanceof AbstractFile)) return false; return getURL().equals(((AbstractFile)o).getURL(), true, true); }
/** * Asserts that both URLs are equal, and that their hashcodes are the same. * * @param url1 first url to test * @param url2 second url to test */ protected void assertEquals(FileURL url1, FileURL url2) { assert url1.equals(url2); assert url2.equals(url1); assert url1.hashCode()==url2.hashCode(); }
/** * Asserts that both URLs are equal, comparing credentials and properties as requested. If both the * <code>compareCredentials</code> and <code>compareProperties</code> parameters are <code>true</code>, this method * asserts that the hashcode of both URLs are the same. * * @param url1 first url to test * @param url2 second url to test * @param compareCredentials if <code>true</code>, the login and password parts of both FileURL need to be * equal (case-sensitive) for the FileURL instances to be equal * @param compareProperties if <code>true</code>, all properties need to be equal (case-sensitive) in both * FileURL for them to be equal */ protected void assertEquals(FileURL url1, FileURL url2, boolean compareCredentials, boolean compareProperties) { assert url1.equals(url2, compareCredentials, compareProperties); assert url2.equals(url1, compareCredentials, compareProperties); // Compare hash codes only if both flags are true. if(compareCredentials && compareProperties) assert url1.hashCode()==url2.hashCode(); }
/** * Adds the specified folder to history. The folder won't be added if the previous folder is the same. * * <p>This method is called by FolderPanel each time a folder is changed. */ public void tryToAddToHistory(FileURL folderURL) { // Do not add folder to history if new current folder is the same as previous folder if (historyIndex<0 || !folderURL.equals(history.get(historyIndex), false, false)) addToHistory(folderURL); // Save last recallable folder on startup, only if : // - it is a directory on a local filesytem // - it doesn't look like a removable media drive (cd/dvd/floppy), especially in order to prevent // Java from triggering that dreaded 'Drive not ready' popup. LOGGER.trace("folder="+folderURL); if(folderURL.getScheme().equals(FileProtocols.FILE)) { AbstractFile folder = FileFactory.getFile(folderURL); if (folder.isDirectory() && (folder instanceof LocalFile) && !((LocalFile)folder.getRoot()).guessRemovableDrive()) { this.lastRecallableFolder = folder.getAbsolutePath(); LOGGER.trace("lastRecallableFolder= "+lastRecallableFolder); } } }