You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Julian Reschke <ju...@gmx.de> on 2007/03/12 14:48:33 UTC
need clarification on Path.equals
Hi,
with a recent change in JCR2SPI, my own SPI implementation is failing
because of Path.equals(). The issue seems to be caused that for
single-sibling nodes, some ways to create a path object use index 0
(undefined), while others use 1.
However, Path.equals() (or actually, PathElement.equals) claims that
both are different, see:
/**
* Computes a hash code for this path element.
*
* @return hash code
*/
public int hashCode() {
// @todo treat index==0 as index==1?
int h = 17;
h = 37 * h + index;
h = 37 * h + name.hashCode();
return h;
}
/**
* Check for path element equality. Returns true if the given
* object is a PathElement and contains the same name and index
* as this one.
*
* @param obj the object to compare with
* @return <code>true</code> if the path elements are equal
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PathElement) {
PathElement other = (PathElement) obj;
return name.equals(other.name)
// @todo treat index==0 as index==1?
&& index == other.index;
}
return false;
}
Should I supply a path for this one (making 0 and 1 equivalent for
PathElement.equals()), or do I need to investigate why both types occur
in my setup?
Feedback appreciated...
Best regards, Julian