directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r604361 [4/4] - in /directory/sandbox/akarasulu/bigbang: apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ apacheds/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/core-integ/...
Date Sat, 15 Dec 2007 00:58:49 GMT
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
Fri Dec 14 16:58:40 2007
@@ -24,6 +24,7 @@
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import java.util.Arrays;
+import java.util.Comparator;
 
 
 /**
@@ -34,6 +35,10 @@
  */
 public class BinaryValue implements Value<byte[]>
 {
+    /** A byte array comparator instance */
+	@SuppressWarnings ( { "unchecked" } )
+    private static final Comparator<byte[]> BYTE_ARRAY_COMPARATOR = new ByteArrayComparator();
+    
     /** the wrapped binary value */
     private byte[] wrapped;
 
@@ -58,23 +63,19 @@
 
 
     /**
-     * Creates a new instance of BinaryValue copying an existing BinaryValue
+     * Dumps binary in hex with label.
      *
-     * @param value the binary value to copy
+     * @see Object#toString()
      */
-    public BinaryValue( BinaryValue value )
+    public String toString()
     {
-        if ( value != null )
-        {
-            wrapped = value.getCopy();
-        }
+        return "BinaryValue : " + StringTools.dumpBytes( wrapped );
     }
 
 
     /**
      * @see Object#hashCode()
      */
-    @Override
     public int hashCode()
     {
         return Arrays.hashCode( wrapped );
@@ -149,7 +150,11 @@
     {
         BinaryValue cloned = (BinaryValue)super.clone();
         
-        cloned.wrapped = getCopy();
+        if ( wrapped != null )
+        {
+            cloned.wrapped = new byte[ wrapped.length ];
+            System.arraycopy( wrapped, 0, cloned.wrapped, 0, wrapped.length );
+        }
         
         return cloned;
     }
@@ -158,7 +163,6 @@
     /**
      * @see Object#equals(Object)
      */
-    @Override
     public boolean equals( Object obj )
     {
         if ( this == obj )
@@ -166,28 +170,30 @@
             return true;
         }
 
-        if ( ! ( obj instanceof BinaryValue ) )
+        if ( obj == null )
+        {
+            return false;
+        }
+
+        if ( obj.getClass() != this.getClass() )
         {
             return false;
         }
 
         BinaryValue binaryValue = ( BinaryValue ) obj;
         
-        if ( isNull() ) 
+        if ( ( wrapped == null ) && ( binaryValue.wrapped == null ) )
         {
-            return binaryValue.isNull();
+            return true;
         }
-        else
+
+        //noinspection SimplifiableIfStatement
+        if ( isNull() != binaryValue.isNull() )
         {
-            if ( binaryValue.isNull() )
-            {
-                return false;
-            }
-            else
-            {
-                return Arrays.equals( wrapped, binaryValue.wrapped );
-            }
+            return false;
         }
+
+        return Arrays.equals( wrapped, binaryValue.wrapped );
     }
 
 
@@ -196,6 +202,7 @@
      *
      * @see Comparable#compareTo(Object) 
      */
+    @SuppressWarnings ( { "JavaDoc" } )
     public int compareTo( BinaryValue value )
     {
         if ( value == null )
@@ -215,18 +222,6 @@
             return -1;
         }
 
-        return ByteArrayComparator.INSTANCE.compare( wrapped, value.getReference() );
-    }
-
-    
-    /**
-     * Dumps binary in hex with label.
-     *
-     * @see Object#toString()
-     */
-    @Override
-    public String toString()
-    {
-        return "BinaryValue : " + StringTools.dumpBytes( wrapped );
+        return BYTE_ARRAY_COMPARATOR.compare( wrapped, value.getReference() );
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
Fri Dec 14 16:58:40 2007
@@ -23,7 +23,6 @@
 
 import javax.naming.NamingException;
 import java.util.Iterator;
-import java.util.List;
 
 
 /**
@@ -73,20 +72,6 @@
 
 
     /**
-     * Places non-null attributes in the attribute collection. If there is
-     * already an attribute with the same OID as any of the new attributes, 
-     * the old ones are removed from the collection and are returned by this 
-     * method. If there was no attribute with the same OID the return value 
-     * is <code>null</code>.
-     *
-     * @param attributes the attributes to be put
-     * @return the old attributes with the same OID, if exist; otherwise
-     *         <code>null</code>
-     */
-    List<T> put( T... attributes ) throws NamingException;
-
-
-    /**
      * Places a non-null attribute in the attribute collection. If there is
      * already an attribute with the same OID as the new attribute, the old one
      * is removed from the collection and is returned by this method. If there
@@ -100,27 +85,16 @@
 
 
     /**
-      * Removes the specified attributes. The removed attributes are
+      * Removes the specified attribute. The removed attribute is
       * returned by this method. If there were no attribute the return value
       * is <code>null</code>.
       *
-      * @param attributes the attributes to be removed
+      * @param attribute the attribute to be removed
       * @return the removed attribute, if exists; otherwise <code>null</code>
       */
-    List<T> remove( T... attributes ) throws NamingException;
+    T remove( T attribute ) throws NamingException;
 
 
-    /**
-     * Removes the specified attribute. The removed attribute is
-     * returned by this method. If there were no attribute the return value
-     * is <code>null</code>.
-     *
-     * @param attribute the attribute to be removed
-     * @return the removed attribute, if exists; otherwise <code>null</code>
-     */
-    T remove( T attribute ) throws NamingException;
-    
-    
     /**
       * Returns the number of attributes.
       *

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
Fri Dec 14 16:58:40 2007
@@ -18,17 +18,17 @@
  */
 package org.apache.directory.shared.ldap.entry;
 
+
 import java.util.Iterator;
 
 
 /**
- * A generic interface mocking the Attribute JNDI interface. This interface
- * will be the base interface for the ServerAttribute and ClientAttribute.
+ * Document me!
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface EntryAttribute<T extends Value<?>>
+public interface EntryAttribute<E extends Value<?>>
 {
     /**
      * Adds a value to this attribute. If the new value is already present in
@@ -43,6 +43,22 @@
      * @param val a new value to be added which may be null
      * @return true if a value was added, otherwise false
      */
+    boolean add( E val );
+
+
+    /**
+     * Adds a value to this attribute. If the new value is already present in
+     * the attribute values, the method has no effect.
+     * <p>
+     * The new value is added at the end of list of values.
+     * </p>
+     * <p>
+     * This method returns true or false to indicate whether a value was added.
+     * </p>
+     *
+     * @param val a new value to be added which may be null
+     * @return true if a value was added, otherwise false
+     */
     boolean add( String val );
 
 
@@ -74,7 +90,7 @@
      * @param val the value which may be null
      * @return true if this attribute contains the value, otherwise false
      */
-    boolean contains( String val );
+    boolean contains( E val );
 
 
     /**
@@ -83,45 +99,19 @@
      * @param val the value which may be null
      * @return true if this attribute contains the value, otherwise false
      */
-    boolean contains( byte[] val );
-
-
-   /**
-      * Retrieves the number of values in this attribute.
-      *
-      * @return the number of values in this attribute, including any values
-      * wrapping a null value if there is one
-      */
-    int size();
+    boolean contains( String val );
 
 
     /**
-     * Removes a value that is equal to the given value.
-     * <p>
-     * Returns true if a value is removed. If there is no value equal to <code>
-     * val</code> this method simply returns false.
-     * </p>
+     * Indicates whether the specified value is one of the attribute's values.
      *
-     * @param val the value to be removed
-     * @return true if the value is removed, otherwise false
+     * @param val the value which may be null
+     * @return true if this attribute contains the value, otherwise false
      */
-    boolean remove( byte[] val );
+    boolean contains( byte[] val );
 
 
     /**
-     * Removes a value that is equal to the given value.
-     * <p>
-     * Returns true if a value is removed. If there is no value equal to <code>
-     * val</code> this method simply returns false.
-     * </p>
-     *
-     * @param val the value to be removed
-     * @return true if the value is removed, otherwise false
-     */
-    boolean remove( String val );
-    
-    
-    /**
      * Gets the first value of this attribute. <code>null</code> is a valid value.
      *
      * <p>
@@ -131,7 +121,7 @@
      *
      * @return a value of this attribute
      */
-    T get();
+    E get();
 
 
     /**
@@ -146,7 +136,16 @@
      *
      * @return an enumeration of all values of the attribute
      */
-    Iterator<T> getAll();
+    Iterator<? extends E> getAll();
+
+
+   /**
+      * Retrieves the number of values in this attribute.
+      *
+      * @return the number of values in this attribute, including any values
+      * wrapping a null value if there is one
+      */
+    int size();
 
 
     /**
@@ -159,30 +158,31 @@
      * @param val the value to be removed
      * @return true if the value is removed, otherwise false
      */
-    boolean remove( T val );
+    boolean remove( E val );
 
 
     /**
-     * Indicates whether the specified value is one of the attribute's values.
+     * Removes a value that is equal to the given value.
+     * <p>
+     * Returns true if a value is removed. If there is no value equal to <code>
+     * val</code> this method simply returns false.
+     * </p>
      *
-     * @param val the value which may be null
-     * @return true if this attribute contains the value, otherwise false
+     * @param val the value to be removed
+     * @return true if the value is removed, otherwise false
      */
-    boolean contains( T val );
+    boolean remove( byte[] val );
 
 
     /**
-     * Adds a value to this attribute. If the new value is already present in
-     * the attribute values, the method has no effect.
-     * <p>
-     * The new value is added at the end of list of values.
-     * </p>
+     * Removes a value that is equal to the given value.
      * <p>
-     * This method returns true or false to indicate whether a value was added.
+     * Returns true if a value is removed. If there is no value equal to <code>
+     * val</code> this method simply returns false.
      * </p>
      *
-     * @param val a new value to be added which may be null
-     * @return true if a value was added, otherwise false
+     * @param val the value to be removed
+     * @return true if the value is removed, otherwise false
      */
-    boolean add( T val );
+    boolean remove( String val );
 }

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
Fri Dec 14 16:58:40 2007
@@ -27,7 +27,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface Modification<T extends EntryAttribute<?>>
+public interface Modification
 {
     /**
      *  @return the operation
@@ -54,7 +54,7 @@
     /**
      * @return the attribute containing the modifications
      */
-    T getAttribute();
+    EntryAttribute<? extends Value<?>> getAttribute();
     
     
     /**
@@ -62,5 +62,5 @@
      *
      * @param attribute The modified attribute 
      */
-    void setAttribute( T attribute );
+    void setAttribute( EntryAttribute<? extends Value<?>> attribute );
 }

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
Fri Dec 14 16:58:40 2007
@@ -29,6 +29,14 @@
  */
 public interface Value<T>
 {
+//    /**
+//     * Get the wrapped value.
+//     *
+//     * @return the wrapped value, as its original type (String,byte[],URI)
+//     */
+//    T get();
+
+
     /**
      * Sets the wrapped value.
      *
@@ -42,4 +50,5 @@
      * @return <code>true</code> if the inner value is null.
      */
     boolean isNull();
+    
 }

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ByteArrayComparator.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ByteArrayComparator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ByteArrayComparator.java
Fri Dec 14 16:58:40 2007
@@ -29,14 +29,14 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ByteArrayComparator implements Comparator<byte[]>
+public class ByteArrayComparator implements Comparator
 {
-    public static final Comparator<byte[]> INSTANCE = new ByteArrayComparator();
+    public static final ByteArrayComparator INSTANCE = new ByteArrayComparator();
 
     /* (non-Javadoc)
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
-    public int compare( byte[] o1, byte[] o2 )
+    public int compare( Object o1, Object o2 )
     {
         byte[] b1 = ( byte[] ) o1;
         byte[] b2 = ( byte[] ) o2;
@@ -73,7 +73,6 @@
         }
         
         int minLength = Math.min( b1.length, b2.length );
-        
         for ( int ii = 0; ii < minLength; ii++ )
         {
             if ( b1[ii] > b2[ii] )

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
Fri Dec 14 16:58:40 2007
@@ -95,7 +95,7 @@
      * @throws NamingException
      *             if there is a failure resolving the object
      */
-    Comparator<?> getComparator() throws NamingException;
+    Comparator getComparator() throws NamingException;
 
 
     /**

Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Fri Dec 14 16:58:40 2007
@@ -2636,20 +2636,6 @@
        assertEquals( "cn=\\ Kylie Minogue\\ ,dc=example,dc=com", dn.toString() );
    }
 
-   
-   /**
-    * Test for DIRSTUDIO-250
-    * @throws NamingException
-    */
-   public void testDoubleQuoteWithSpecialCharsInNameDIRSERVER_250() throws NamingException
-   {
-       LdapDN dn = new LdapDN( "a=\"b,c\"" );
-
-       assertEquals( "a=\"b,c\"", dn.getUpName() );
-       assertEquals( "a=b\\,c", dn.toString() );
-   }
-
-
    /**
     * Test for DIRSERVER-184
     * @throws NamingException



Mime
View raw message