directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1694541 - in /directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model: AclAttribute.java AclAttributeWrapper.java
Date Thu, 06 Aug 2015 17:30:44 GMT
Author: elecharny
Date: Thu Aug  6 17:30:44 2015
New Revision: 1694541

URL: http://svn.apache.org/r1694541
Log:
Added the wrapper for the AclAttribute, and added a toString() method

Added:
    directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeWrapper.java
Modified:
    directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java

Modified: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java?rev=1694541&r1=1694540&r2=1694541&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java
(original)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java
Thu Aug  6 17:30:44 2015
@@ -91,8 +91,9 @@ public class AclAttribute
                 else
                 {
                     isAttributeType = true;
-                    this.name = name;
                 }
+
+                this.name = name;
             }
         }
         
@@ -194,4 +195,30 @@ public class AclAttribute
     {
         return isObjectClassNotAllowed;
     }
+
+
+    /**
+     * @See Object#toString()
+     */
+    public String toString()
+    {
+        if ( isEntry || isChildren || isAttributeType )
+        {
+            return name;
+        }
+
+        StringBuilder buffer = new StringBuilder();
+        
+        if ( isObjectClass )
+        {
+            buffer.append( '@' );
+        }
+        else
+        {
+            buffer.append( '!' );
+        }
+        
+        buffer.append( name );
+        return buffer.toString();
+    }
 }

Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeWrapper.java?rev=1694541&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeWrapper.java
(added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeWrapper.java
Thu Aug  6 17:30:44 2015
@@ -0,0 +1,117 @@
+package org.apache.directory.studio.openldap.config.acl.model;
+
+import org.apache.directory.api.util.Strings;
+
+public class AclAttributeWrapper implements Cloneable, Comparable<AclAttributeWrapper>
+{
+    /** The AclAttribute */
+    private AclAttribute aclAttribute;
+    
+    /**
+     * Creates a new instance of AclAttributeWrapper.
+     *
+     * @param aclAttribute the aclAttribute
+     */
+    public AclAttributeWrapper( AclAttribute aclAttribute )
+    {
+        this.aclAttribute = aclAttribute;
+    }
+
+
+    /**
+     * @return the value
+     */
+    public AclAttribute getAclAttribute()
+    {
+        return aclAttribute;
+    }
+
+    
+    /**
+     * @param aclAttribute the aclAttribute to set
+     */
+    public void setAclAttribute( AclAttribute aclAttribute )
+    {
+        this.aclAttribute = aclAttribute;
+    }
+
+
+    /**
+     * Clone the current object
+     */
+    public AclAttributeWrapper clone()
+    {
+        try
+        {
+            return (AclAttributeWrapper)super.clone();
+        }
+        catch ( CloneNotSupportedException e )
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object that )
+    {
+        // Quick test
+        if ( this == that )
+        {
+            return true;
+        }
+
+        if ( that instanceof AclAttributeWrapper )
+        {
+            AclAttributeWrapper thatInstance = (AclAttributeWrapper)that;
+
+            return aclAttribute.getName().equalsIgnoreCase( thatInstance.aclAttribute.getName()
);
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int h = 37;
+
+        if ( aclAttribute != null )
+        {
+            h += h*17 + aclAttribute.getName().hashCode();
+        }
+
+        return h;
+    }
+
+
+    /**
+     * @see Comparable#compareTo()
+     */
+    public int compareTo( AclAttributeWrapper that )
+    {
+        if ( that == null )
+        {
+            return 1;
+        }
+
+        // Check the AclAttribute
+        return aclAttribute.getName().compareToIgnoreCase( that.getAclAttribute().getName()
);
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return aclAttribute.toString();
+    }
+}



Mime
View raw message