jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Reschke <julian.resc...@gmx.de>
Subject need clarification on Path.equals
Date Mon, 12 Mar 2007 13:48:33 GMT
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



Mime
View raw message