You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by un...@apache.org on 2004/07/22 23:07:18 UTC

cvs commit: jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib Ace.java

unico       2004/07/22 14:07:18

  Modified:    webdavclient/clientlib/src/java/org/apache/webdav/lib
                        Ace.java
  Log:
  implement equals and hashCode
  
  Revision  Changes    Path
  1.3       +37 -4     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/Ace.java
  
  Index: Ace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/Ace.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Ace.java	11 Feb 2004 11:30:51 -0000	1.2
  +++ Ace.java	22 Jul 2004 21:07:17 -0000	1.3
  @@ -238,6 +238,39 @@
           privileges.clear();
       }
   
  +    public int hashCode() {
  +        return toString().hashCode() 
  +            + (getPrincipal().equals("property") 
  +                    ? getProperty().hashCode() 
  +                    : 0);
  +    }
  +
  +    public boolean equals(Object o) {
  +        if (o != null && o instanceof Ace) {
  +            Ace otherAce = (Ace) o;
  +            boolean equals = true;
  +            equals &= isNegative() == otherAce.isNegative();
  +            equals &= isProtected() == otherAce.isProtected();
  +            equals &= isInherited() == otherAce.isInherited();
  +            if (equals && isInherited()) {
  +                equals &= getInheritedFrom().equals(otherAce.getInheritedFrom());
  +            }
  +            equals &= getPrincipal().equals(otherAce.getPrincipal());
  +            if (equals && getPrincipal().equals("property")) {
  +                getProperty().equals(otherAce.getProperty());
  +            }
  +            if (equals) {
  +                Enumeration privileges = enumeratePrivileges();
  +                Enumeration otherPrivileges = enumeratePrivileges();
  +                while (equals && privileges.hasMoreElements()) {
  +                    equals &= otherPrivileges.hasMoreElements();
  +                    equals &= privileges.nextElement().equals(otherPrivileges.nextElement());
  +                }
  +            }
  +            return equals;
  +        }
  +        return false;
  +    }
   
       public String toString() {
           return ((!isNegative()?"granted":"denied") +
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org