diff options
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java')
-rw-r--r-- | bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java deleted file mode 100644 index b152f44e8..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.core.variants; - -import org.eclipse.core.resources.IResource; -import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.TeamPlugin; - -/** - * A resource comparator that uses the <code>ThreeWaySynchronizer</code> - * to compare local resources to their resource variants. - */ -public class ThreeWayResourceComparator implements IResourceVariantComparator { - - private ThreeWaySynchronizer synchronizer; - - /** - * Create a three-way resource comparator that uses the <code>ThreeWaySynchronizer</code> - * to compare a local resource to a resource variant. - * @param synchronizer - */ - public ThreeWayResourceComparator(ThreeWaySynchronizer synchronizer) { - this.synchronizer = synchronizer; - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantComparator#compare(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant) - */ - public boolean compare(IResource local, IResourceVariant remote) { - // First, ensure the resources are the same gender - if ((local.getType() == IResource.FILE) == remote.isContainer()) { - return false; - } - try { - // If the file is locally modified, it cannot be in sync - if (local.getType() == IResource.FILE && getSynchronizer().isLocallyModified(local)) { - return false; - } - // If there is no base, the local cannopt match the remote - if (getSynchronizer().getBaseBytes(local) == null) return false; - // Otherwise, assume they are the same if the remote equals the base - return equals(getSynchronizer().getBaseBytes(local), getBytes(remote)); - } catch (TeamException e) { - TeamPlugin.log(e); - return false; - } - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantComparator#compare(org.eclipse.team.core.variants.IResourceVariant, org.eclipse.team.core.variants.IResourceVariant) - */ - public boolean compare(IResourceVariant base, IResourceVariant remote) { - byte[] bytes1 = getBytes(base); - byte[] bytes2 = getBytes(remote); - return equals(bytes1, bytes2); - } - - /* (non-Javadoc) - * @see org.eclipse.team.core.variants.IResourceVariantComparator#isThreeWay() - */ - public boolean isThreeWay() { - return true; - } - - private ThreeWaySynchronizer getSynchronizer() { - return synchronizer; - } - - private byte[] getBytes(IResourceVariant remote) { - return remote.asBytes(); - } - - private boolean equals(byte[] syncBytes, byte[] oldBytes) { - if (syncBytes.length != oldBytes.length) return false; - for (int i = 0; i < oldBytes.length; i++) { - if (oldBytes[i] != syncBytes[i]) return false; - } - return true; - } -} |