[exo-jcr-commits] exo-jcr SVN: r2530 - in jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jun 10 04:58:22 EDT 2010


Author: sergiykarpenko
Date: 2010-06-10 04:58:20 -0400 (Thu, 10 Jun 2010)
New Revision: 2530

Modified:
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-766: QPathEntry - equals() method added

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java	2010-06-10 08:41:16 UTC (rev 2529)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java	2010-06-10 08:58:20 UTC (rev 2530)
@@ -176,7 +176,7 @@
 
       for (int i = 0; i < ancestorNames.length; i++)
       {
-         if (!ancestorNames[i].equals(names[i]))
+         if (!names[i].equals(ancestorNames[i]))
             return false;
       }
       return true;
@@ -239,7 +239,7 @@
    }
 
    /**
-    * @return last name of this path
+    * @return last QPathEntry of this path
     */
    public InternalQName getName()
    {
@@ -247,7 +247,7 @@
    }
 
    /**
-    * @return index
+    * @return index of last QPathEntry of this paths
     */
    public int getIndex()
    {

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java	2010-06-10 08:41:16 UTC (rev 2529)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java	2010-06-10 08:58:20 UTC (rev 2530)
@@ -158,4 +158,18 @@
       return getAsString(true);
    }
 
+   @Override
+   public boolean equals(Object o)
+   {
+      boolean result = super.equals(o);
+
+      if (result == true && (o instanceof QPathEntry))
+      {
+         return result && (index == ((QPathEntry)o).getIndex());
+      }
+      else
+      {
+         return result;
+      }
+   }
 }

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java	2010-06-10 08:41:16 UTC (rev 2529)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java	2010-06-10 08:58:20 UTC (rev 2530)
@@ -2393,18 +2393,14 @@
          NodeData nodeData = siblings.get(i);
          if (srcInd == -1)
          {
-            if (nodeData.getQPath().getName().equals(srcPath.getName())
-               && (nodeData.getQPath().getIndex() == srcPath.getIndex() || srcPath.getIndex() == 0
-                  && nodeData.getQPath().getIndex() == 1))
+            if (nodeData.getQPath().getName().equals(srcPath.getName()))
             {
                srcInd = i;
             }
          }
          if (destPath != null && destInd == -1)
          {
-            if (nodeData.getQPath().getName().equals(destPath.getName())
-               && (nodeData.getQPath().getIndex() == destPath.getIndex() || destPath.getIndex() == 0
-                  && nodeData.getQPath().getIndex() == 1))
+            if (nodeData.getQPath().getName().equals(destPath.getName()))
             {
                destInd = i;
                if (srcInd != -1)
@@ -2466,7 +2462,7 @@
          NodeData sdata = siblings.get(j);
 
          // calculating same name index
-         if (sdata.getQPath().getName().equals(srcPath.getName()))
+         if (sdata.getQPath().getName().getAsString().equals(srcPath.getName().getAsString()))
             ++sameNameIndex;
 
          // skeep unchanged
@@ -2475,7 +2471,8 @@
 
          NodeData newData = sdata;
          // change same name index
-         if (sdata.getQPath().getName().equals(srcPath.getName()) && sdata.getQPath().getIndex() != sameNameIndex)
+         if (sdata.getQPath().getName().getAsString().equals(srcPath.getName().getAsString())
+            && sdata.getQPath().getIndex() != sameNameIndex)
          {
             // update with new index
             QPath siblingPath =



More information about the exo-jcr-commits mailing list