Introduce DiffMissingXml
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 15 Dec 2007 10:03:48 +0000 (10:03 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 15 Dec 2007 10:03:48 +0000 (10:03 +0000)
NEW - bug 55: The DiffMissing object is not adapted to the XML Diff
https://www.argeo.org/bugzilla/show_bug.cgi?id=55

git-svn-id: https://svn.argeo.org/slc/trunk@861 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissingXml.java [new file with mode: 0644]
org.argeo.slc.core/src/main/java/org/argeo/slc/diff/XPathDiffPosition.java

diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissingXml.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/diff/DiffMissingXml.java
new file mode 100644 (file)
index 0000000..ca3fd21
--- /dev/null
@@ -0,0 +1,43 @@
+package org.argeo.slc.diff;\r
+\r
+/**\r
+ * <code>DiffMissing</code> using the XPath of the position as\r
+ * <code>DiffKey</code>\r
+ */\r
+public class DiffMissingXml extends DiffMissing {\r
+\r
+       public DiffMissingXml(XPathDiffPosition position) {\r
+               super(position, new DiffKeyXml(position.getXPath()));\r
+       }\r
+\r
+       /** Implementation of <code>DiffKey</code> based on an XPath string. */\r
+       protected static class DiffKeyXml implements DiffKey {\r
+               private final String xPath;\r
+\r
+               public DiffKeyXml(String xPath) {\r
+                       this.xPath = xPath;\r
+               }\r
+\r
+               public String getXPath() {\r
+                       return xPath;\r
+               }\r
+\r
+               @Override\r
+               public String toString() {\r
+                       return xPath;\r
+               }\r
+\r
+               @Override\r
+               public boolean equals(Object obj) {\r
+                       if (!(obj instanceof DiffKeyXml))\r
+                               return false;\r
+                       return xPath.equals(((DiffKeyXml) obj).xPath);\r
+               }\r
+\r
+               @Override\r
+               public int hashCode() {\r
+                       return xPath.hashCode();\r
+               }\r
+\r
+       }\r
+}\r
index 5c4b900407b1759a0631b6e2c6ae98fd5db0921c..0d22342406767875e15f1d78b76ec69b885f6644 100644 (file)
@@ -24,8 +24,12 @@ public class XPathDiffPosition extends DiffPosition {
                }\r
        }\r
 \r
+       public String getXPath() {\r
+               return xPath;\r
+       }\r
+\r
        @Override\r
-       public String toString(){\r
+       public String toString() {\r
                return xPath;\r
        }\r
 }\r