From: Daniel Sobrado Date: Thu, 5 Jun 2008 18:39:21 +0000 (+0000) Subject: Diff Key X-Git-Tag: argeo-slc-2.1.7~2822 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=ebb2c485490a5088773385c3e435ce3cce08d1f0;hp=fa4530c014ecc4f549f8aeef97fae19de03a2cfe;p=gpl%2Fargeo-slc.git Diff Key git-svn-id: https://svn.argeo.org/slc/trunk@1219 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffIssueKey.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffIssueKey.java new file mode 100644 index 000000000..cf00fd8eb --- /dev/null +++ b/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffIssueKey.java @@ -0,0 +1,31 @@ +package org.argeo.slc.diff; + +/** Intermediate class that can hold the key to be displayed. */ +public abstract class DiffIssueKey extends DiffIssue { + /** The position of this issue. */ + protected DiffKey key; + + /** Constructor without key*/ + public DiffIssueKey(DiffPosition position) { + super(position); + } + + /** Constructor with key*/ + public DiffIssueKey(DiffPosition position, DiffKey key) { + super(position); + this.key = key; + } + + public Object getKey() { + return key; + } + + @Override + public String toString() { + if (key != null) { + return key.toString(); + } else { + return ""; + } + } +} diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissing.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissing.java index da4476660..fe2ab106f 100644 --- a/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissing.java +++ b/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissing.java @@ -6,24 +6,19 @@ package org.argeo.slc.diff; * the reached it means that it is missing from the reached. If the value is * null it means that the entire line is missing. */ -public class DiffMissing extends DiffIssue { - private final DiffKey key; +public class DiffMissing extends DiffIssueKey { public DiffMissing(DiffPosition position, DiffKey key) { super(position); - this.key = key; - } - - public Object getKey() { - return key; + super.key = key; } @Override public String toString() { if (position.relatedFile == RelatedFile.EXPECTED) { - return position + ": left over " + key; + return position + ": left over " + super.toString(); } else if (position.relatedFile == RelatedFile.REACHED) { - return position + ": missing " + key; + return position + ": missing " + super.toString(); } return super.toString(); } diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffNotMatched.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffNotMatched.java index 04f7acff1..a482548f5 100644 --- a/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffNotMatched.java +++ b/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffNotMatched.java @@ -1,7 +1,7 @@ package org.argeo.slc.diff; /** Diff issue where reached and expected values are different. */ -public class DiffNotMatched extends DiffIssue { +public class DiffNotMatched extends DiffIssueKey { private final Object expected; private final Object reached; @@ -11,6 +11,12 @@ public class DiffNotMatched extends DiffIssue { this.reached = reached; } + public DiffNotMatched(DiffPosition position, Object expected, Object reached, DiffKey key) { + super(position, key); + this.expected = expected; + this.reached = reached; + } + public Object getExpected() { return expected; } @@ -21,7 +27,12 @@ public class DiffNotMatched extends DiffIssue { @Override public String toString() { - return position + ": not matched " + expected + " <> " + reached; + String result = position + ": not matched " + expected + " <> " + reached; + if (super.key != null) { + result = result + " - Key: " + super.toString(); + } + + return result; } }