Diff Key
authorDaniel Sobrado <daniel.sobrado@capco.com>
Thu, 5 Jun 2008 18:39:21 +0000 (18:39 +0000)
committerDaniel Sobrado <daniel.sobrado@capco.com>
Thu, 5 Jun 2008 18:39:21 +0000 (18:39 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1219 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffIssueKey.java [new file with mode: 0644]
org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissing.java
org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffNotMatched.java

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 (file)
index 0000000..cf00fd8
--- /dev/null
@@ -0,0 +1,31 @@
+package org.argeo.slc.diff;\r
+\r
+/** Intermediate class that can hold the key to be displayed. */\r
+public abstract class DiffIssueKey extends DiffIssue {\r
+       /** The position of this issue. */\r
+       protected DiffKey key;\r
+\r
+       /** Constructor without key*/\r
+       public DiffIssueKey(DiffPosition position) {\r
+               super(position);\r
+       }\r
+       \r
+       /** Constructor with key*/\r
+       public DiffIssueKey(DiffPosition position, DiffKey key) {\r
+               super(position);\r
+               this.key = key;\r
+       }\r
+\r
+       public Object getKey() {\r
+               return key;\r
+       }\r
+       \r
+       @Override\r
+       public String toString() {\r
+               if (key != null) {\r
+                       return key.toString();\r
+               } else {\r
+                       return "";\r
+               }\r
+       }\r
+}\r
index da4476660f02b4ef41d38c802941528e04b4be8f..fe2ab106f9a49caed4609e9c9c7085b267ff0638 100644 (file)
@@ -6,24 +6,19 @@ package org.argeo.slc.diff;
  * the reached it means that it is missing from the reached. If the value is\r
  * null it means that the entire line is missing.\r
  */\r
-public class DiffMissing extends DiffIssue {\r
-       private final DiffKey key;\r
+public class DiffMissing extends DiffIssueKey {\r
 \r
        public DiffMissing(DiffPosition position, DiffKey key) {\r
                super(position);\r
-               this.key = key;\r
-       }\r
-\r
-       public Object getKey() {\r
-               return key;\r
+               super.key = key;\r
        }\r
 \r
        @Override\r
        public String toString() {\r
                if (position.relatedFile == RelatedFile.EXPECTED) {\r
-                       return position + ": left over " + key;\r
+                       return position + ": left over " + super.toString();\r
                } else if (position.relatedFile == RelatedFile.REACHED) {\r
-                       return position + ": missing " + key;\r
+                       return position + ": missing " + super.toString();\r
                }\r
                return super.toString();\r
        }\r
index 04f7acff12311a093f54bbc45147d04dd4f42d4b..a482548f521032f9c4089d78e3e3c5495e5f9398 100644 (file)
@@ -1,7 +1,7 @@
 package org.argeo.slc.diff;\r
 \r
 /** Diff issue where reached and expected values are different. */\r
-public class DiffNotMatched extends DiffIssue {\r
+public class DiffNotMatched extends DiffIssueKey {\r
        private final Object expected;\r
        private final Object reached;\r
 \r
@@ -11,6 +11,12 @@ public class DiffNotMatched extends DiffIssue {
                this.reached = reached;\r
        }\r
 \r
+       public DiffNotMatched(DiffPosition position, Object expected, Object reached, DiffKey key) {\r
+               super(position, key);\r
+               this.expected = expected;\r
+               this.reached = reached;\r
+       }\r
+\r
        public Object getExpected() {\r
                return expected;\r
        }\r
@@ -21,7 +27,12 @@ public class DiffNotMatched extends DiffIssue {
 \r
        @Override\r
        public String toString() {\r
-               return position + ": not matched " + expected + " <> " + reached;\r
+               String result = position + ": not matched " + expected + " <> " + reached;\r
+               if (super.key != null) {\r
+                        result = result + " - Key: " + super.toString();\r
+               }\r
+               \r
+               return result;\r
        }\r
 \r
 }\r