Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java')
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java
new file mode 100644
index 000000000..2a7ca6643
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/rangedifferencer/IRangeComparator.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+package org.eclipse.compare.rangedifferencer;
+
+/**
+ * For breaking an object to compare into a sequence of comparable entities.
+ * <p>
+ * It is used by <code>RangeDifferencer</code> to find longest sequences of
+ * matching and non-matching ranges.
+ * <p>
+ * For example, to compare two text documents and find longest common sequences
+ * of matching and non-matching lines, the implementation must break the document
+ * into lines. <code>getRangeCount</code> would return the number of lines in the
+ * document, and <code>rangesEqual</code> would compare a specified line given
+ * with one in another <code>IRangeComparator</code>.
+ * </p>
+ * <p>
+ * Clients should implement this interface; there is no standard implementation.
+ * </p>
+ */
+public interface IRangeComparator {
+
+ /**
+ * Returns the number of comparable entities.
+ *
+ * @return the number of comparable entities
+ */
+ int getRangeCount();
+
+ /**
+ * Returns whether the comparable entity given by the first index
+ * matches an entity specified by the other <code>IRangeComparator</code> and index.
+ *
+ * @param thisIndex the index of the comparable entity within this <code>IRangeComparator</code>
+ * @param other the IRangeComparator to compare this with
+ * @param otherIndex the index of the comparable entity within the other <code>IRangeComparator</code>
+ * @return <code>true</code> if the comparable entities are equal
+ */
+ boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex);
+
+ /**
+ * Returns whether a comparison should be skipped because it would be too costly (or lengthy).
+ *
+ * @param length a number on which to base the decision whether to return
+ * <code>true</code> or <code>false</code>
+ * @param maxLength another number on which to base the decision whether to return
+ * <code>true</code> or <code>false</code>
+ * @param other the other <code>IRangeComparator</code> to compare with
+ * @return <code>true</code> to avoid a too lengthy range comparison
+ */
+ boolean skipRangeComparison(int length, int maxLength, IRangeComparator other);
+}

Back to the top