Author: sergiykarpenko
Date: 2010-06-09 08:37:03 -0400 (Wed, 09 Jun 2010)
New Revision: 2523
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-766: QPathEntry - equals() method added
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java 2010-06-09
12:26:44 UTC (rev 2522)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java 2010-06-09
12:37:03 UTC (rev 2523)
@@ -37,7 +37,6 @@
public class QPath implements Comparable<QPath>
{
-
/**
* Logger.
*/
@@ -176,7 +175,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 +238,7 @@
}
/**
- * @return last name of this path
+ * @return last QPathEntry of this path
*/
public InternalQName getName()
{
@@ -247,7 +246,7 @@
}
/**
- * @return index
+ * @return index of last QPathEntry of this paths
*/
public int getIndex()
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java 2010-06-09
12:26:44 UTC (rev 2522)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java 2010-06-09
12:37:03 UTC (rev 2523)
@@ -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/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-06-09
12:26:44 UTC (rev 2522)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-06-09
12:37:03 UTC (rev 2523)
@@ -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 =
Show replies by date