directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r928296 [2/3] - in /directory: apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/ apacheds/trunk/core-entry/...
Date Sat, 27 Mar 2010 22:50:34 GMT
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerAttribute.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerAttribute.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerAttribute.java Sat Mar 27 22:50:33 2010
@@ -28,7 +28,6 @@ import javax.naming.NamingException;
 
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.exception.LdapException;
@@ -100,11 +99,11 @@ public final class DefaultServerAttribut
                     else
                     {
                         // We have to convert the value to a binary value first
-                        serverValue = new ServerBinaryValue( attributeType, 
+                        serverValue = new BinaryValue( attributeType, 
                             clientValue.getBytes() );
                     }
                 }
-                else if ( clientValue instanceof ClientBinaryValue )
+                else if ( clientValue instanceof BinaryValue )
                 {
                     if ( isHR )
                     {
@@ -114,7 +113,7 @@ public final class DefaultServerAttribut
                     }
                     else
                     {
-                        serverValue = new ServerBinaryValue( attributeType, clientValue.getBytes() );
+                        serverValue = new BinaryValue( attributeType, clientValue.getBytes() );
                     }
                 }
 
@@ -301,7 +300,7 @@ public final class DefaultServerAttribut
             
             for ( byte[] val:vals )
             {
-                Value<?> value = new ServerBinaryValue( attributeType, val );
+                Value<?> value = new BinaryValue( attributeType, val );
                 
                 try
                 {
@@ -430,34 +429,35 @@ public final class DefaultServerAttribut
             {
                 if ( val == null )
                 {
-                    Value<byte[]> nullSV = new ServerBinaryValue( attributeType, (byte[])null );
+                    Value<byte[]> nullSV = new BinaryValue( attributeType, (byte[])null );
                     
                     if ( values.add( nullSV ) )
                     {
                         nbAdded++;
                     }
                 }
-                else if ( ( val instanceof ClientBinaryValue ) )
+                else
                 {
-                    Value<byte[]> serverBinaryValue = new ServerBinaryValue( attributeType, val.getBytes() ); 
-                    
-                    if ( values.add( serverBinaryValue ) )
+                    if ( val instanceof BinaryValue )
                     {
-                        nbAdded++;
+                        BinaryValue binaryValue = (BinaryValue)val;
+                        
+                        if ( binaryValue.getAttributeType() == null )
+                        {
+                            binaryValue = new BinaryValue( attributeType, val.getBytes() ); 
+                        }
+    
+                        if ( values.add( binaryValue ) )
+                        {
+                            nbAdded++;
+                        }
                     }
-                }
-                else if ( val instanceof ServerBinaryValue )
-                {
-                    if ( values.add( val ) )
+                    else
                     {
-                        nbAdded++;
+                        String message = I18n.err( I18n.ERR_04452 );
+                        LOG.error( message );
                     }
                 }
-                else
-                {
-                    String message = I18n.err( I18n.ERR_04452 );
-                    LOG.error( message );
-                }
             }
         }
         
@@ -496,7 +496,7 @@ public final class DefaultServerAttribut
             // don't find one in the values
             for ( byte[] val:vals )
             {
-                ServerBinaryValue value = new ServerBinaryValue( attributeType, val );
+                BinaryValue value = new BinaryValue( attributeType, val );
                 
                 try
                 {
@@ -608,7 +608,7 @@ public final class DefaultServerAttribut
         {
             for ( Value<?> val:vals )
             {
-                if ( val instanceof ClientBinaryValue )
+                if ( val instanceof BinaryValue )
                 {
                     if ( !values.contains( val ) )
                     {
@@ -682,7 +682,7 @@ public final class DefaultServerAttribut
         
         for ( byte[] val:vals )
         {
-            ServerBinaryValue value = new ServerBinaryValue( attributeType, val );
+            BinaryValue value = new BinaryValue( attributeType, val );
             removed &= values.remove( value );
         }
         
@@ -749,14 +749,16 @@ public final class DefaultServerAttribut
         {
             for ( Value<?> val:vals )
             {
-                if ( val instanceof ClientBinaryValue )
+                if ( val instanceof BinaryValue )
                 {
-                    ServerBinaryValue sbv = new ServerBinaryValue( attributeType, (byte[])val.get() );
-                    removed &= values.remove( sbv );
-                }
-                else if ( val instanceof ServerBinaryValue )
-                {
-                    removed &= values.remove( val );
+                    BinaryValue binaryValue = (BinaryValue)val;
+                    
+                    if ( binaryValue.getAttributeType() == null )
+                    {
+                        binaryValue = new BinaryValue( attributeType, (byte[])val.get() );
+                    }
+                    
+                    removed &= values.remove( binaryValue );
                 }
                 else
                 {
@@ -973,7 +975,7 @@ public final class DefaultServerAttribut
                 }
                 else
                 {
-                    ((ServerBinaryValue)value).serialize( out );
+                    ((BinaryValue)value).serialize( out );
                 }
             }
         }
@@ -1025,8 +1027,8 @@ public final class DefaultServerAttribut
                 }
                 else
                 {
-                    value  = new ServerBinaryValue( attributeType );
-                    ((ServerBinaryValue)value).deserialize( in );
+                    value  = new BinaryValue( attributeType );
+                    ((BinaryValue)value).deserialize( in );
                 }
                 
                 try

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerStringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerStringValue.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerStringValue.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerStringValue.java Sat Mar 27 22:50:33 2010
@@ -19,22 +19,13 @@
 package org.apache.directory.shared.ldap.entry;
 
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 
 
 /**
@@ -48,49 +39,6 @@ import org.slf4j.LoggerFactory;
  */
 public class ServerStringValue extends ClientStringValue
 {
-    /** Used for serialization */
-    private static final long serialVersionUID = 2L;
-    
-    /** logger for reporting errors that might not be handled properly upstream */
-    private static final Logger LOG = LoggerFactory.getLogger( ServerStringValue.class );
-
-    /** reference to the attributeType which is not serialized */
-    private transient AttributeType attributeType;
-
-
-    // -----------------------------------------------------------------------
-    // utility methods
-    // -----------------------------------------------------------------------
-    /**
-     * Utility method to get some logs if an assert fails
-     */
-    protected String logAssert( String message )
-    {
-        LOG.error(  message );
-        return message;
-    }
-
-    
-    /**
-     *  Check the attributeType member. It should not be null, 
-     *  and it should contains a syntax.
-     */
-    protected String checkAttributeType( AttributeType attributeType )
-    {
-        if ( attributeType == null )
-        {
-            return "The AttributeType parameter should not be null";
-        }
-        
-        if ( attributeType.getSyntax() == null )
-        {
-            return "There is no Syntax associated with this attributeType";
-        }
-
-        return null;
-    }
-
-    
     // -----------------------------------------------------------------------
     // Constructors
     // -----------------------------------------------------------------------
@@ -329,38 +277,6 @@ public class ServerStringValue extends C
     }
 
 
-    /**
-     * Get the associated AttributeType
-     * @return The AttributeType
-     */
-    public AttributeType getAttributeType()
-    {
-        return attributeType;
-    }
-
-
-    /**
-     * Check if the value is stored into an instance of the given 
-     * AttributeType, or one of its ascendant.
-     * 
-     * For instance, if the Value is associated with a CommonName,
-     * checking for Name will match.
-     * 
-     * @param attributeType The AttributeType we are looking at
-     * @return <code>true</code> if the value is associated with the given
-     * attributeType or one of its ascendant
-     */
-    public boolean instanceOf( AttributeType attributeType ) throws LdapException
-    {
-        if ( this.attributeType.equals( attributeType ) )
-        {
-            return true;
-        }
-
-        return this.attributeType.isDescendantOf( attributeType );
-    }
-
-
     // -----------------------------------------------------------------------
     // Object Methods
     // -----------------------------------------------------------------------
@@ -439,239 +355,4 @@ public class ServerStringValue extends C
             }
         }
     }
-
-
-    // -----------------------------------------------------------------------
-    // Private Helper Methods (might be put into abstract base class)
-    // -----------------------------------------------------------------------
-
-
-    /**
-     * Find a matchingRule to use for normalization and comparison.  If an equality
-     * matchingRule cannot be found it checks to see if other matchingRules are
-     * available: SUBSTR, and ORDERING.  If a matchingRule cannot be found null is
-     * returned.
-     *
-     * @return a matchingRule or null if one cannot be found for the attributeType
-     * @throws LdapException if resolution of schema entities fail
-     */
-    private MatchingRule getMatchingRule() throws LdapException
-    {
-        MatchingRule mr = attributeType.getEquality();
-
-        if ( mr == null )
-        {
-            mr = attributeType.getOrdering();
-        }
-
-        if ( mr == null )
-        {
-            mr = attributeType.getSubstring();
-        }
-
-        return mr;
-    }
-
-
-    /**
-     * Gets a normalizer using getMatchingRule() to resolve the matchingRule
-     * that the normalizer is extracted from.
-     *
-     * @return a normalizer associated with the attributeType or null if one cannot be found
-     * @throws LdapException if resolution of schema entities fail
-     */
-    private Normalizer getNormalizer() throws LdapException
-    {
-        MatchingRule mr = getMatchingRule();
-
-        if ( mr == null )
-        {
-            return null;
-        }
-
-        return mr.getNormalizer();
-    }
-
-
-    /**
-     * Implement the hashCode method.
-     * 
-     * @see Object#hashCode()
-     * @throws IllegalStateException on failures to extract the comparator, or the
-     * normalizers needed to perform the required comparisons based on the schema
-     * @return the instance's hash code 
-     */
-    public int hashCode()
-    {
-        // return the OID hashcode if the value is null. 
-        if ( isNull() )
-        {
-            return attributeType.getOid().hashCode();
-        }
-
-        // If the normalized value is null, will default to wrapped
-        // which cannot be null at this point.
-        int h = 17;
-        
-        String normalized = getNormalizedValue();
-        
-        if ( normalized != null )
-        {
-            h = h*37 + normalized.hashCode();
-        }
-        
-        // Add the OID hashcode
-        h = h*37 + attributeType.getOid().hashCode();
-        
-        return h;
-    }
-
-    
-    /**
-     * Gets a comparator using getMatchingRule() to resolve the matching
-     * that the comparator is extracted from.
-     *
-     * @return a comparator associated with the attributeType or null if one cannot be found
-     * @throws LdapException if resolution of schema entities fail
-     */
-    private LdapComparator<? super Object> getLdapComparator() throws LdapException
-    {
-        MatchingRule mr = getMatchingRule();
-
-        if ( mr == null )
-        {
-            return null;
-        }
-
-        return mr.getLdapComparator();
-    }
-    
-    
-    /**
-     * @see Externalizable#writeExternal(ObjectOutput)
-     * 
-     * We can't use this method for a ServerStringValue, as we have to feed the value
-     * with an AttributeType object
-     */ 
-    public void writeExternal( ObjectOutput out ) throws IOException
-    {
-        throw new IllegalStateException( I18n.err( I18n.ERR_04446 ) );
-    }
-    
-    
-    /**
-     * We will write the value and the normalized value, only
-     * if the normalized value is different.
-     * 
-     * If the value is empty, a flag is written at the beginning with 
-     * the value true, otherwise, a false is written.
-     * 
-     * The data will be stored following this structure :
-     *  [empty value flag]
-     *  [UP value]
-     *  [normalized] (will be false if the value can't be normalized)
-     *  [same] (a flag set to true if the normalized value equals the UP value)
-     *  [Norm value] (the normalized value if different from the UP value)
-     *  
-     *  @param out the buffer in which we will stored the serialized form of the value
-     *  @throws IOException if we can't write into the buffer
-     */
-    public void serialize( ObjectOutput out ) throws IOException
-    {
-        if ( wrapped != null )
-        {
-            // write a flag indicating that the value is not null
-            out.writeBoolean( true );
-            
-            // Write the data
-            out.writeUTF( wrapped );
-            
-            // Normalize the data
-            try
-            {
-                normalize();
-                out.writeBoolean( true );
-                
-                if ( wrapped.equals( normalizedValue ) )
-                {
-                    out.writeBoolean( true );
-                }
-                else
-                {
-                    out.writeBoolean( false );
-                    out.writeUTF( normalizedValue );
-                }
-            }
-            catch ( LdapException ne )
-            {
-                // The value can't be normalized, we don't write the 
-                // normalized value.
-                normalizedValue = null;
-                out.writeBoolean( false );
-            }
-        }
-        else
-        {
-            // Write a flag indicating that the value is null
-            out.writeBoolean( false );
-        }
-        
-        out.flush();
-    }
-
-    
-    /**
-     * @see Externalizable#readExternal(ObjectInput)
-     * 
-     * We can't use this method for a ServerStringValue, as we have to feed the value
-     * with an AttributeType object
-     */
-    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
-    {
-        throw new IllegalStateException( I18n.err( I18n.ERR_04446 ) );
-    }
-    
-
-    /**
-     * 
-     * Deserialize a ServerStringValue. 
-     *
-     * @param in the buffer containing the bytes with the serialized value
-     * @throws IOException 
-     * @throws ClassNotFoundException
-     */
-    public void deserialize( ObjectInput in ) throws IOException, ClassNotFoundException
-    {
-        // If the value is null, the flag will be set to false
-        if ( !in.readBoolean() )
-        {
-            set( null );
-            normalizedValue = null;
-            return;
-        }
-        
-        // Read the value
-        String wrapped = in.readUTF();
-        
-        set( wrapped );
-        
-        // Read the normalized flag
-        normalized = in.readBoolean();
-        
-        if ( normalized )
-        {
-            normalized = true;
-
-            // Read the 'same' flag
-            if ( in.readBoolean() )
-            {
-                normalizedValue = wrapped;
-            }
-            else
-            {
-                // The normalized value is different. Read it
-                normalizedValue = in.readUTF();
-            }
-        }
-    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java Sat Mar 27 22:50:33 2010
@@ -30,6 +30,9 @@ import org.apache.directory.shared.i18n.
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.entry.AbstractValue;
 import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -50,11 +53,13 @@ public class ClientStringValue extends A
     /** Used for serialization */
     private static final long serialVersionUID = 2L;
     
-    
     /** logger for reporting errors that might not be handled properly upstream */
-    private static final Logger LOG = LoggerFactory.getLogger( ClientStringValue.class );
+    protected static final Logger LOG = LoggerFactory.getLogger( ClientStringValue.class );
+
+    /** reference to the attributeType which is not serialized */
+    protected transient AttributeType attributeType;
+
 
-    
     // -----------------------------------------------------------------------
     // Constructors
     // -----------------------------------------------------------------------
@@ -246,12 +251,39 @@ public class ClientStringValue extends A
         // stored in an attribute - the binary version does the same 
         if ( isNull() )
         {
+            if ( attributeType != null )
+            {
+                // return the OID hashcode if the value is null. 
+                return attributeType.getOid().hashCode();
+            }
+            
             return 0;
         }
 
         // If the normalized value is null, will default to wrapped
         // which cannot be null at this point.
-        return getNormalizedValue().hashCode();
+        // If the normalized value is null, will default to wrapped
+        // which cannot be null at this point.
+        int h = 0;
+
+        String normalized = getNormalizedValue();
+        
+        if ( normalized != null )
+        {
+            h = normalized.hashCode();
+        }
+        else
+        {
+            h = 17;
+        }
+        
+        // Add the OID hashcode if we have an AttributeType
+        if ( attributeType != null )
+        {
+            h = h*37 + attributeType.getOid().hashCode();
+        }
+        
+        return h;
     }
 
 
@@ -390,8 +422,257 @@ public class ClientStringValue extends A
         // and flush the data
         out.flush();
     }
+
     
+    /**
+     * Get the associated AttributeType
+     * @return The AttributeType
+     */
+    public AttributeType getAttributeType()
+    {
+        return attributeType;
+    }
+
+    
+    /**
+     * Check if the value is stored into an instance of the given 
+     * AttributeType, or one of its ascendant.
+     * 
+     * For instance, if the Value is associated with a CommonName,
+     * checking for Name will match.
+     * 
+     * @param attributeType The AttributeType we are looking at
+     * @return <code>true</code> if the value is associated with the given
+     * attributeType or one of its ascendant
+     */
+    public boolean instanceOf( AttributeType attributeType ) throws LdapException
+    {
+        if ( attributeType != null )
+        {
+            if ( this.attributeType.equals( attributeType ) )
+            {
+                return true;
+            }
     
+            return this.attributeType.isDescendantOf( attributeType );
+        }
+        
+        return false;
+    }
+
+
+    /**
+     *  Check the attributeType member. It should not be null, 
+     *  and it should contains a syntax.
+     */
+    protected String checkAttributeType( AttributeType attributeType )
+    {
+        if ( attributeType == null )
+        {
+            return "The AttributeType parameter should not be null";
+        }
+        
+        if ( attributeType.getSyntax() == null )
+        {
+            return "There is no Syntax associated with this attributeType";
+        }
+
+        return null;
+    }
+
+    
+    /**
+     * Gets a comparator using getMatchingRule() to resolve the matching
+     * that the comparator is extracted from.
+     *
+     * @return a comparator associated with the attributeType or null if one cannot be found
+     * @throws LdapException if resolution of schema entities fail
+     */
+    protected LdapComparator<? super Object> getLdapComparator() throws LdapException
+    {
+        if ( attributeType != null )
+        {
+            MatchingRule mr = getMatchingRule();
+    
+            if ( mr == null )
+            {
+                return null;
+            }
+    
+            return mr.getLdapComparator();
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+    
+    /**
+     * Find a matchingRule to use for normalization and comparison.  If an equality
+     * matchingRule cannot be found it checks to see if other matchingRules are
+     * available: SUBSTR, and ORDERING.  If a matchingRule cannot be found null is
+     * returned.
+     *
+     * @return a matchingRule or null if one cannot be found for the attributeType
+     * @throws LdapException if resolution of schema entities fail
+     */
+    protected MatchingRule getMatchingRule() throws LdapException
+    {
+        if ( attributeType != null )
+        {
+            MatchingRule mr = attributeType.getEquality();
+    
+            if ( mr == null )
+            {
+                mr = attributeType.getOrdering();
+            }
+    
+            if ( mr == null )
+            {
+                mr = attributeType.getSubstring();
+            }
+    
+            return mr;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Gets a normalizer using getMatchingRule() to resolve the matchingRule
+     * that the normalizer is extracted from.
+     *
+     * @return a normalizer associated with the attributeType or null if one cannot be found
+     * @throws LdapException if resolution of schema entities fail
+     */
+    protected Normalizer getNormalizer() throws LdapException
+    {
+        if ( attributeType != null )
+        {
+            MatchingRule mr = getMatchingRule();
+    
+            if ( mr == null )
+            {
+                return null;
+            }
+    
+            return mr.getNormalizer();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    
+    /**
+     * We will write the value and the normalized value, only
+     * if the normalized value is different.
+     * 
+     * If the value is empty, a flag is written at the beginning with 
+     * the value true, otherwise, a false is written.
+     * 
+     * The data will be stored following this structure :
+     *  [empty value flag]
+     *  [UP value]
+     *  [normalized] (will be false if the value can't be normalized)
+     *  [same] (a flag set to true if the normalized value equals the UP value)
+     *  [Norm value] (the normalized value if different from the UP value)
+     *  
+     *  @param out the buffer in which we will stored the serialized form of the value
+     *  @throws IOException if we can't write into the buffer
+     */
+    public void serialize( ObjectOutput out ) throws IOException
+    {
+        if ( wrapped != null )
+        {
+            // write a flag indicating that the value is not null
+            out.writeBoolean( true );
+            
+            // Write the data
+            out.writeUTF( wrapped );
+            
+            // Normalize the data
+            try
+            {
+                normalize();
+                out.writeBoolean( true );
+                
+                if ( wrapped.equals( normalizedValue ) )
+                {
+                    out.writeBoolean( true );
+                }
+                else
+                {
+                    out.writeBoolean( false );
+                    out.writeUTF( normalizedValue );
+                }
+            }
+            catch ( LdapException ne )
+            {
+                // The value can't be normalized, we don't write the 
+                // normalized value.
+                normalizedValue = null;
+                out.writeBoolean( false );
+            }
+        }
+        else
+        {
+            // Write a flag indicating that the value is null
+            out.writeBoolean( false );
+        }
+        
+        out.flush();
+    }
+
+    
+    /**
+     * Deserialize a ServerStringValue. 
+     *
+     * @param in the buffer containing the bytes with the serialized value
+     * @throws IOException 
+     * @throws ClassNotFoundException
+     */
+    public void deserialize( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        // If the value is null, the flag will be set to false
+        if ( !in.readBoolean() )
+        {
+            set( null );
+            normalizedValue = null;
+            return;
+        }
+        
+        // Read the value
+        String wrapped = in.readUTF();
+        
+        set( wrapped );
+        
+        // Read the normalized flag
+        normalized = in.readBoolean();
+        
+        if ( normalized )
+        {
+            normalized = true;
+
+            // Read the 'same' flag
+            if ( in.readBoolean() )
+            {
+                normalizedValue = wrapped;
+            }
+            else
+            {
+                // The normalized value is different. Read it
+                normalizedValue = in.readUTF();
+            }
+        }
+    }
+
+
     /**
      * @see Object#toString()
      */

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientAttribute.java Sat Mar 27 22:50:33 2010
@@ -32,6 +32,7 @@ import org.apache.directory.shared.ldap.
 
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.ServerStringValue;
 import org.apache.directory.shared.ldap.entry.Value;
@@ -493,7 +494,7 @@ public class DefaultClientAttribute impl
     public int add( Value<?>... vals )
     {
         int nbAdded = 0;
-        ClientBinaryValue nullBinaryValue = null;
+        BinaryValue nullBinaryValue = null;
         ClientStringValue nullStringValue = null;
         boolean nullValueAdded = false;
         
@@ -510,7 +511,7 @@ public class DefaultClientAttribute impl
                     // know later if we add some new value.
                     // We have to do that because we are using a Set,
                     // and we can't remove the first element of the Set.
-                    nullBinaryValue = new ClientBinaryValue( null );
+                    nullBinaryValue = new BinaryValue( (byte[])null );
                     nullStringValue = new ClientStringValue( null );
                     
                     values.add( nullBinaryValue );
@@ -521,7 +522,7 @@ public class DefaultClientAttribute impl
                 else if ( !isHR )
                 {
                     // The attribute type is binary.
-                    nullBinaryValue = new ClientBinaryValue( null );
+                    nullBinaryValue = new BinaryValue( (byte[])null );
                     
                     // Don't add a value if it already exists. 
                     if ( !values.contains( nullBinaryValue ) )
@@ -560,7 +561,7 @@ public class DefaultClientAttribute impl
                     {
                         // The attributeType is binary, convert the
                         // value to a BinaryValue
-                        ClientBinaryValue cbv = new ClientBinaryValue();
+                        BinaryValue cbv = new BinaryValue();
                         cbv.set( val.getBytes() );
                         
                         if ( !contains( cbv ) )
@@ -678,7 +679,7 @@ public class DefaultClientAttribute impl
                 }
                 
                 // Now call the add(Value) method
-                if ( add( new ClientBinaryValue( valBytes ) ) == 1 )
+                if ( add( new BinaryValue( valBytes ) ) == 1 )
                 {
                     nbAdded++;
                 }
@@ -755,7 +756,7 @@ public class DefaultClientAttribute impl
         {
             for ( byte[] val:vals )
             {
-                if ( add( new ClientBinaryValue( val ) ) == 1 )
+                if ( add( new BinaryValue( val ) ) == 1 )
                 {
                     nbAdded++;
                 }
@@ -840,7 +841,7 @@ public class DefaultClientAttribute impl
                     String stringVal = val.getString();
                     
                     // We have to convert the binary value to a String
-                    if ( ! values.contains( new ClientBinaryValue( StringTools.getBytesUtf8( stringVal ) ) ) )
+                    if ( ! values.contains( new BinaryValue( StringTools.getBytesUtf8( stringVal ) ) ) )
                     {
                         return false;
                     }
@@ -893,7 +894,7 @@ public class DefaultClientAttribute impl
             {
                 byte[] binaryVal = StringTools.getBytesUtf8( val );
 
-                if ( !contains( new ClientBinaryValue( binaryVal ) ) )
+                if ( !contains( new BinaryValue( binaryVal ) ) )
                 {
                     return false;
                 }
@@ -929,7 +930,7 @@ public class DefaultClientAttribute impl
             // don't find one in the values
             for ( byte[] val:vals )
             {
-                if ( !contains( new ClientBinaryValue( val ) ) )
+                if ( !contains( new BinaryValue( val ) ) )
                 {
                     return false;
                 }
@@ -1193,7 +1194,7 @@ public class DefaultClientAttribute impl
             // The attribute type is not HR, we can directly process the values
             for ( byte[] val:vals )
             {
-                ClientBinaryValue value = new ClientBinaryValue( val );
+                BinaryValue value = new BinaryValue( val );
                 removed &= values.remove( value );
             }
         }
@@ -1250,7 +1251,7 @@ public class DefaultClientAttribute impl
             // to byte[] before removing them
             for ( String val:vals )
             {
-                ClientBinaryValue value = new ClientBinaryValue( StringTools.getBytesUtf8( val ) );
+                BinaryValue value = new BinaryValue( StringTools.getBytesUtf8( val ) );
                 removed &= values.remove( value );
             }
         }
@@ -1454,7 +1455,7 @@ public class DefaultClientAttribute impl
             }
             else
             {
-                clientValue = new ClientBinaryValue( value.getBytes() );
+                clientValue = new BinaryValue( value.getBytes() );
             }
             
             clientAttribute.add( clientValue );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AbstractExprNode.java Sat Mar 27 22:50:33 2010
@@ -24,8 +24,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 
 
@@ -156,9 +156,9 @@ public abstract class AbstractExprNode i
 
         if ( value.isBinary() )
         {
-            sb = new StringBuilder( ((ClientBinaryValue)value).getReference().length * 3 );
+            sb = new StringBuilder( ((BinaryValue)value).getReference().length * 3 );
             
-            for ( byte b:((ClientBinaryValue)value).getReference() )
+            for ( byte b:((BinaryValue)value).getReference() )
             {
                 if ( ( b < 0x7F ) && ( b >= 0 ) )
                 {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java Sat Mar 27 22:50:33 2010
@@ -23,8 +23,8 @@ package org.apache.directory.shared.ldap
 import java.text.ParseException;
 
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.Position;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -266,11 +266,11 @@ public class FilterParser
             byte[] result = new byte[ current ];
             System.arraycopy( value, 0, result, 0, current );
             
-            return new ClientBinaryValue( result );
+            return new BinaryValue( result );
         }
         else
         {
-            return new ClientBinaryValue();
+            return new BinaryValue();
         }
     }
 
@@ -396,7 +396,7 @@ public class FilterParser
         else if ( StringTools.isCharASCII( filter, pos.start, ')' ) )
         {
             // An empty equality Node
-            return new EqualityNode( attr, new ClientBinaryValue() );
+            return new EqualityNode( attr, new BinaryValue() );
         }
         else
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java Sat Mar 27 22:50:33 2010
@@ -21,8 +21,8 @@ package org.apache.directory.shared.ldap
 
 
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.message.internal.InternalCompareRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalCompareResponse;
@@ -132,7 +132,7 @@ public class CompareRequestImpl extends 
     {
         if ( attrVal != null )
         {
-            this.attrVal = new ClientBinaryValue( attrVal );
+            this.attrVal = new BinaryValue( attrVal );
         }
         else
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVA.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVA.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVA.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVA.java Sat Mar 27 22:50:33 2010
@@ -27,8 +27,8 @@ import java.io.ObjectOutput;
 import java.util.Arrays;
 
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -146,7 +146,7 @@ public class AVA implements Cloneable, C
      */
     public AVA( String upType, String normType, byte[] upValue, byte[] normValue ) throws LdapInvalidDnException
     {
-        this( upType, normType, new ClientBinaryValue( upValue ), new ClientBinaryValue( normValue ) );
+        this( upType, normType, new BinaryValue( upValue ), new BinaryValue( normValue ) );
     }
 
 
@@ -908,12 +908,12 @@ public class AVA implements Cloneable, C
             int upValueLength = in.readInt();
             byte[] upValueBytes = new byte[upValueLength];
             in.readFully( upValueBytes );
-            upValue = new ClientBinaryValue( upValueBytes );
+            upValue = new BinaryValue( upValueBytes );
 
             int valueLength = in.readInt();
             byte[] normValueBytes = new byte[valueLength];
             in.readFully( normValueBytes );
-            normValue = new ClientBinaryValue( normValueBytes );
+            normValue = new BinaryValue( normValueBytes );
         }
     }
     

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVASerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVASerializer.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVASerializer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AVASerializer.java Sat Mar 27 22:50:33 2010
@@ -23,8 +23,8 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -184,8 +184,8 @@ public class AVASerializer
     
                 AVA atav = 
                     new AVA( upType, normType, 
-                        new ClientBinaryValue( upValue) , 
-                        new ClientBinaryValue( normValue ), upName );
+                        new BinaryValue( upValue) , 
+                        new BinaryValue( normValue ), upName );
                 
                 return atav;
             }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java Sat Mar 27 22:50:33 2010
@@ -22,7 +22,7 @@ package org.apache.directory.shared.ldap
 
 
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.schema.Normalizer;
@@ -63,7 +63,7 @@ public class SimpleNameComponentNormaliz
 
     public Object normalizeByName( String name, byte[] val ) throws LdapException
     {
-        return normalizer.normalize( new ClientBinaryValue( val ) );
+        return normalizer.normalize( new BinaryValue( val ) );
     }
 
 
@@ -75,7 +75,7 @@ public class SimpleNameComponentNormaliz
 
     public Object normalizeByOid( String oid, byte[] val ) throws LdapException
     {
-        return normalizer.normalize( new ClientBinaryValue( val ) );
+        return normalizer.normalize( new BinaryValue( val ) );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ConcreteNameComponentNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ConcreteNameComponentNormalizer.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ConcreteNameComponentNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ConcreteNameComponentNormalizer.java Sat Mar 27 22:50:33 2010
@@ -23,7 +23,7 @@ package org.apache.directory.shared.ldap
 import java.io.UnsupportedEncodingException;
 
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -123,7 +123,7 @@ public class ConcreteNameComponentNormal
                 String unescaped = unescape( value );
                 byte[] valBytes = unescaped.getBytes( "UTF-8" );
                 
-                return lookup( name ).normalize( new ClientBinaryValue( valBytes ) ); 
+                return lookup( name ).normalize( new BinaryValue( valBytes ) ); 
             }
             catch ( UnsupportedEncodingException uee )
             {
@@ -145,7 +145,7 @@ public class ConcreteNameComponentNormal
         
         if ( !attributeType.getSyntax().isHumanReadable() )
         {
-            return lookup( name ).normalize( new ClientBinaryValue( value ) );
+            return lookup( name ).normalize( new BinaryValue( value ) );
         }
         else
         {
@@ -178,7 +178,7 @@ public class ConcreteNameComponentNormal
      */
     public Object normalizeByOid( String oid, byte[] value ) throws LdapException
     {
-        return lookup( oid ).normalize( new ClientBinaryValue( value ) );
+        return lookup( oid ).normalize( new BinaryValue( value ) );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=928296&r1=928295&r2=928296&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Sat Mar 27 22:50:33 2010
@@ -38,7 +38,7 @@ import javax.naming.InvalidNameException
 
 import org.apache.directory.shared.asn1.codec.binary.Hex;
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.syntaxCheckers.UuidSyntaxChecker;
 
@@ -1058,9 +1058,9 @@ public class StringTools
             {
                 return ( ( ClientStringValue ) object ).get();
             }
-            else if ( object instanceof ClientBinaryValue )
+            else if ( object instanceof BinaryValue )
             {
-                return dumpBytes( ( ( ClientBinaryValue ) object ).get() );
+                return dumpBytes( ( ( BinaryValue ) object ).get() );
             }
             else
             {

Copied: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/BinaryValueAttributeTypeTest.java (from r928092, directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/BinaryValueAttributeTypeTest.java?p2=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/BinaryValueAttributeTypeTest.java&p1=directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java&r1=928092&r2=928296&rev=928296&view=diff
==============================================================================
--- directory/apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/BinaryValueAttributeTypeTest.java Sat Mar 27 22:50:33 2010
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.server.core.entry;
+package org.apache.directory.shared.ldap.entry;
 
 
 import static org.junit.Assert.assertEquals;
@@ -34,10 +34,9 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Arrays;
 
-import org.apache.directory.shared.ldap.entry.ServerBinaryValue;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
 import org.apache.directory.shared.ldap.entry.ServerStringValue;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
@@ -51,7 +50,7 @@ import org.junit.Test;
 
 
 /**
- * Tests that the ServerBinaryValue class works properly as expected.
+ * Tests that the BinaryValue class works properly as expected.
  *
  * Some notes while conducting tests:
  *
@@ -63,7 +62,7 @@ import org.junit.Test;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ServerBinaryValueTest
+public class BinaryValueAttributeTypeTest
 {
     private LdapSyntax s;
     private AttributeType at;
@@ -78,9 +77,9 @@ public class ServerBinaryValueTest
      */
     @Before public void initAT()
     {
-        s = TestServerEntryUtils.syntaxFactory( "1.1.1.1", false );
+        s = EntryUtils.syntaxFactory( "1.1.1.1", false );
         s.setSyntaxChecker( new OctetStringSyntaxChecker() );
-        mr = TestServerEntryUtils.matchingRuleFactory( "1.1.2.1" );
+        mr = EntryUtils.matchingRuleFactory( "1.1.2.1" );
         mr.setSyntax( s );
         
         mr.setLdapComparator( new ByteArrayComparator( "1.1.1" ) );
@@ -102,7 +101,7 @@ public class ServerBinaryValueTest
                         newVal[i++] = (byte)(b & 0x007F); 
                     }
                     
-                    return new ClientBinaryValue( StringTools.trim( newVal ) );
+                    return new BinaryValue( StringTools.trim( newVal ) );
                 }
 
                 throw new IllegalStateException( "expected byte[] to normalize" );
@@ -124,9 +123,9 @@ public class ServerBinaryValueTest
     
     
     /**
-     * Serialize a ServerBinaryValue
+     * Serialize a BinaryValue
      */
-    private ByteArrayOutputStream serializeValue( ServerBinaryValue value ) throws IOException
+    private ByteArrayOutputStream serializeValue( BinaryValue value ) throws IOException
     {
         ObjectOutputStream oOut = null;
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -161,9 +160,9 @@ public class ServerBinaryValueTest
     
     
     /**
-     * Deserialize a ServerBinaryValue
+     * Deserialize a BinaryValue
      */
-    private ServerBinaryValue deserializeValue( ByteArrayOutputStream out, AttributeType at ) throws IOException, ClassNotFoundException
+    private BinaryValue deserializeValue( ByteArrayOutputStream out, AttributeType at ) throws IOException, ClassNotFoundException
     {
         ObjectInputStream oIn = null;
         ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
@@ -172,7 +171,7 @@ public class ServerBinaryValueTest
         {
             oIn = new ObjectInputStream( in );
 
-            ServerBinaryValue value = new ServerBinaryValue( at );
+            BinaryValue value = new BinaryValue( at );
             value.deserialize( oIn );
 
             return value;
@@ -205,7 +204,7 @@ public class ServerBinaryValueTest
     {
         try
         {
-            new ServerBinaryValue( null );
+            new BinaryValue( null, (byte[])null );
             fail();
         }
         catch ( IllegalArgumentException iae )
@@ -218,7 +217,7 @@ public class ServerBinaryValueTest
         
         try
         {
-            new ServerBinaryValue( attribute );
+            new BinaryValue( attribute );
             fail();
         }
         catch ( IllegalArgumentException ae )
@@ -233,9 +232,9 @@ public class ServerBinaryValueTest
      */
     @Test public void testServerBinaryValueNullValue()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( attribute, null );
+        BinaryValue value = new BinaryValue( attribute, null );
         
         assertNull( value.getReference() );
         assertTrue( value.isNull() );
@@ -247,9 +246,9 @@ public class ServerBinaryValueTest
      */
     @Test public void testServerBinaryValueEmptyValue()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( attribute, StringTools.EMPTY_BYTES );
+        BinaryValue value = new BinaryValue( attribute, StringTools.EMPTY_BYTES );
         
         assertEquals( StringTools.EMPTY_BYTES, value.getReference() );
         assertFalse( value.isNull() );
@@ -261,9 +260,9 @@ public class ServerBinaryValueTest
      */
     @Test public void testServerBinaryValueNoValue()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         byte[] val = new byte[]{0x01};
-        ServerBinaryValue value = new ServerBinaryValue( attribute );
+        BinaryValue value = new BinaryValue( attribute );
         
         value.set( val );
         assertTrue( Arrays.equals( val, value.getReference() ) );
@@ -277,9 +276,9 @@ public class ServerBinaryValueTest
      */
     @Test public void testServerBinaryValue()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         byte[] val = new byte[]{0x01};
-        ServerBinaryValue value = new ServerBinaryValue( attribute, val );
+        BinaryValue value = new BinaryValue( attribute, val );
         
         assertTrue( Arrays.equals( val, value.getReference() ) );
         assertFalse( value.isNull() );
@@ -293,10 +292,10 @@ public class ServerBinaryValueTest
     @Test
     public void testClone() throws LdapException
     {
-        AttributeType at1 = TestServerEntryUtils.getBytesAttributeType();
-        ServerBinaryValue sbv = new ServerBinaryValue( at1, null );
+        AttributeType at1 = EntryUtils.getBytesAttributeType();
+        BinaryValue sbv = new BinaryValue( at1, null );
         
-        ClientBinaryValue sbv1 = sbv.clone();
+        BinaryValue sbv1 = sbv.clone();
         
         assertEquals( sbv, sbv1 );
         
@@ -323,15 +322,15 @@ public class ServerBinaryValueTest
      */
     @Test public void testEquals()
     {
-        AttributeType at1 = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType at1 = EntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value1 = new ServerBinaryValue( at1, new byte[]{0x01, (byte)0x02} );
-        ServerBinaryValue value2 = new ServerBinaryValue( at1, new byte[]{0x01, (byte)0x02} );
-        ServerBinaryValue value3 = new ServerBinaryValue( at1, new byte[]{0x01, (byte)0x82} );
-        ServerBinaryValue value4 = new ServerBinaryValue( at1, new byte[]{0x01} );
-        ServerBinaryValue value5 = new ServerBinaryValue( at1, null );
-        ServerBinaryValue value6 = new ServerBinaryValue( at, new byte[]{0x01, 0x02} );
-        ServerStringValue value7 = new ServerStringValue( TestServerEntryUtils.getIA5StringAttributeType(), 
+        BinaryValue value1 = new BinaryValue( at1, new byte[]{0x01, (byte)0x02} );
+        BinaryValue value2 = new BinaryValue( at1, new byte[]{0x01, (byte)0x02} );
+        BinaryValue value3 = new BinaryValue( at1, new byte[]{0x01, (byte)0x82} );
+        BinaryValue value4 = new BinaryValue( at1, new byte[]{0x01} );
+        BinaryValue value5 = new BinaryValue( at1, null );
+        BinaryValue value6 = new BinaryValue( at, new byte[]{0x01, 0x02} );
+        ServerStringValue value7 = new ServerStringValue( EntryUtils.getIA5StringAttributeType(), 
             "test" );
         
         assertTrue( value1.equals( value1 ) );
@@ -352,15 +351,15 @@ public class ServerBinaryValueTest
      */
     @Test public void testGetNormalizedValue()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( attribute, null );
+        BinaryValue value = new BinaryValue( attribute, null );
         assertNull( value.getNormalizedValue() );
 
-        value = new ServerBinaryValue( attribute, StringTools.EMPTY_BYTES );
+        value = new BinaryValue( attribute, StringTools.EMPTY_BYTES );
         assertTrue( Arrays.equals(  StringTools.EMPTY_BYTES, value.getNormalizedValue() ) );
 
-        value = new ServerBinaryValue( attribute, BYTES2 );
+        value = new BinaryValue( attribute, BYTES2 );
         assertTrue( Arrays.equals( BYTES1, value.getNormalizedValue() ) );
     }
     
@@ -370,15 +369,15 @@ public class ServerBinaryValueTest
      */
     @Test public void testGetNormalizedValueCopy()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( attribute, null );
+        BinaryValue value = new BinaryValue( attribute, null );
         assertNull( value.getNormalizedValueCopy() );
 
-        value = new ServerBinaryValue( attribute, StringTools.EMPTY_BYTES );
+        value = new BinaryValue( attribute, StringTools.EMPTY_BYTES );
         assertTrue( Arrays.equals(  StringTools.EMPTY_BYTES, value.getNormalizedValueCopy() ) );
 
-        value = new ServerBinaryValue( attribute, BYTES2 );
+        value = new BinaryValue( attribute, BYTES2 );
         assertTrue( Arrays.equals( BYTES1, value.getNormalizedValueCopy() ) );
     }
     
@@ -388,15 +387,15 @@ public class ServerBinaryValueTest
      */
     @Test public void testGetNormalizedValueReference()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( attribute, null );
+        BinaryValue value = new BinaryValue( attribute, null );
         assertNull( value.getNormalizedValueReference() );
 
-        value = new ServerBinaryValue( attribute, StringTools.EMPTY_BYTES );
+        value = new BinaryValue( attribute, StringTools.EMPTY_BYTES );
         assertTrue( Arrays.equals(  StringTools.EMPTY_BYTES, value.getNormalizedValueReference() ) );
 
-        value = new ServerBinaryValue( attribute, BYTES2 );
+        value = new BinaryValue( attribute, BYTES2 );
         assertTrue( Arrays.equals( BYTES1, value.getNormalizedValueReference() ) );
     }
     
@@ -407,8 +406,8 @@ public class ServerBinaryValueTest
     @Test
     public void testgetAttributeType()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
-        ServerBinaryValue sbv = new ServerBinaryValue( attribute );
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
+        BinaryValue sbv = new BinaryValue( attribute );
         
         assertEquals( attribute, sbv.getAttributeType() );
     }    
@@ -421,18 +420,18 @@ public class ServerBinaryValueTest
      */
     @Test public void testIsValid()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
         
-        ServerBinaryValue value = new ServerBinaryValue( attribute, null );
+        BinaryValue value = new BinaryValue( attribute, null );
         assertTrue( value.isValid() );
         
-        value = new ServerBinaryValue( attribute, StringTools.EMPTY_BYTES );
+        value = new BinaryValue( attribute, StringTools.EMPTY_BYTES );
         assertTrue( value.isValid() );
 
-        value = new ServerBinaryValue( attribute, new byte[]{0x01, 0x02} );
+        value = new BinaryValue( attribute, new byte[]{0x01, 0x02} );
         assertTrue( value.isValid() );
 
-        value = new ServerBinaryValue( attribute, new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06} );
+        value = new BinaryValue( attribute, new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06} );
         assertFalse( value.isValid() );
     }
     
@@ -443,10 +442,10 @@ public class ServerBinaryValueTest
      */
     @Test public void testHashCode()
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
-        ServerBinaryValue v0 = new ServerBinaryValue( attribute, new byte[]{0x01, 0x02} );
-        ServerBinaryValue v1 = new ServerBinaryValue( attribute, new byte[]{(byte)0x81, (byte)0x82} );
-        ServerBinaryValue v2 = new ServerBinaryValue( attribute, new byte[]{0x01, 0x02} );
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
+        BinaryValue v0 = new BinaryValue( attribute, new byte[]{0x01, 0x02} );
+        BinaryValue v1 = new BinaryValue( attribute, new byte[]{(byte)0x81, (byte)0x82} );
+        BinaryValue v2 = new BinaryValue( attribute, new byte[]{0x01, 0x02} );
         assertEquals( v0.hashCode(), v1.hashCode() );
         assertEquals( v1.hashCode(), v2.hashCode() );
         assertEquals( v0.hashCode(), v2.hashCode() );
@@ -457,7 +456,7 @@ public class ServerBinaryValueTest
         assertTrue( v1.isValid() );
         assertTrue( v2.isValid() );
 
-        ServerBinaryValue v3 = new ServerBinaryValue( attribute, new byte[]{0x01, 0x03} );
+        BinaryValue v3 = new BinaryValue( attribute, new byte[]{0x01, 0x03} );
         assertFalse( v3.equals( v0 ) );
         assertFalse( v3.equals( v1 ) );
         assertFalse( v3.equals( v2 ) );
@@ -471,8 +470,8 @@ public class ServerBinaryValueTest
     @Test
     public void testSame() throws LdapException
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
-        ServerBinaryValue sbv = new ServerBinaryValue( attribute );
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
+        BinaryValue sbv = new BinaryValue( attribute );
 
         sbv.normalize();
         assertTrue( sbv.isSame() );
@@ -497,12 +496,12 @@ public class ServerBinaryValueTest
     @Test
     public void testInstanceOf() throws LdapException
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
-        ServerBinaryValue sbv = new ServerBinaryValue( attribute );
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
+        BinaryValue sbv = new BinaryValue( attribute );
         
         assertTrue( sbv.instanceOf( attribute ) );
         
-        attribute = TestServerEntryUtils.getIA5StringAttributeType();
+        attribute = EntryUtils.getIA5StringAttributeType();
         
         assertFalse( sbv.instanceOf( attribute ) );
     }    
@@ -514,8 +513,8 @@ public class ServerBinaryValueTest
     @Test
     public void testNormalize() throws LdapException
     {
-        AttributeType attribute = TestServerEntryUtils.getBytesAttributeType();
-        ServerBinaryValue sbv = new ServerBinaryValue( attribute );
+        AttributeType attribute = EntryUtils.getBytesAttributeType();
+        BinaryValue sbv = new BinaryValue( attribute );
 
         sbv.normalize();
         assertEquals( null, sbv.getNormalizedValue() );
@@ -536,14 +535,14 @@ public class ServerBinaryValueTest
     @Test
     public void testCompareTo()
     {
-        AttributeType at1 = TestServerEntryUtils.getBytesAttributeType();
-        ServerBinaryValue v0 = new ServerBinaryValue( at1, BYTES1 );
-        ServerBinaryValue v1 = new ServerBinaryValue( at1, BYTES2 );
+        AttributeType at1 = EntryUtils.getBytesAttributeType();
+        BinaryValue v0 = new BinaryValue( at1, BYTES1 );
+        BinaryValue v1 = new BinaryValue( at1, BYTES2 );
         
         assertEquals( 0, v0.compareTo( v1 ) );
         assertEquals( 0, v1.compareTo( v0 ) );
 
-        ServerBinaryValue v2 = new ServerBinaryValue( at1, null );
+        BinaryValue v2 = new BinaryValue( at1, null );
         
         assertEquals( 1, v0.compareTo( v2 ) );
         assertEquals( -1, v2.compareTo( v0 ) );
@@ -559,7 +558,7 @@ public class ServerBinaryValueTest
         byte[] v1Norm = StringTools.getBytesUtf8( "Test   Test" );
         
         // First check with a value which will be normalized
-        ServerBinaryValue sbv = new ServerBinaryValue( at, v1 );
+        BinaryValue sbv = new BinaryValue( at, v1 );
         
         sbv.normalize();
         byte[] normalized = sbv.getNormalizedValueReference();
@@ -567,7 +566,7 @@ public class ServerBinaryValueTest
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sbv.getReference() ) );
         
-        ServerBinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
+        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
         
         assertEquals( sbv, sbvSer );
     }
@@ -582,9 +581,9 @@ public class ServerBinaryValueTest
         byte[] v1 = StringTools.getBytesUtf8( "Test   Test" );
         
         // First check with a value which will be normalized
-        ServerBinaryValue sbv = new ServerBinaryValue( at, v1 );
+        BinaryValue sbv = new BinaryValue( at, v1 );
         
-        ServerBinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
+        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
         
         assertEquals( sbv, sbvSer );
     }
@@ -599,7 +598,7 @@ public class ServerBinaryValueTest
         byte[] v1Norm = StringTools.getBytesUtf8( "test" );
 
         // First check with a value which will be normalized
-        ServerBinaryValue sbv = new ServerBinaryValue( at, v1 );
+        BinaryValue sbv = new BinaryValue( at, v1 );
         
         sbv.normalize();
         byte[] normalized = sbv.getNormalizedValueReference();
@@ -607,7 +606,7 @@ public class ServerBinaryValueTest
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sbv.getBytes() ) );
         
-        ServerBinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
+        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
         
         assertEquals( sbv, sbvSer );
    }
@@ -619,7 +618,7 @@ public class ServerBinaryValueTest
     @Test public void testNullBinaryValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
-        ServerBinaryValue sbv = new ServerBinaryValue( at );
+        BinaryValue sbv = new BinaryValue( at );
         
         sbv.normalize();
         byte[] normalized = sbv.getNormalizedValueReference();
@@ -627,7 +626,7 @@ public class ServerBinaryValueTest
         assertEquals( null, normalized );
         assertEquals( null, sbv.get() );
         
-        ServerBinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
+        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
         
         assertEquals( sbv, sbvSer );
    }
@@ -639,7 +638,7 @@ public class ServerBinaryValueTest
     @Test public void testEmptyBinaryValueSerialization() throws LdapException, IOException, ClassNotFoundException
     {
         // First check with a value which will be normalized
-        ServerBinaryValue sbv = new ServerBinaryValue( at, StringTools.EMPTY_BYTES );
+        BinaryValue sbv = new BinaryValue( at, StringTools.EMPTY_BYTES );
         
         sbv.normalize();
         byte[] normalized = sbv.getNormalizedValueReference();
@@ -647,7 +646,7 @@ public class ServerBinaryValueTest
         assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, normalized ) );
         assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, sbv.getBytes() ) );
         
-        ServerBinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
+        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
         
         assertEquals( sbv, sbvSer );
    }
@@ -662,7 +661,7 @@ public class ServerBinaryValueTest
         byte[] v1Norm = StringTools.getBytesUtf8( "test" );
 
         // First check with a value which will be normalized
-        ServerBinaryValue sbv = new ServerBinaryValue( at, v1 );
+        BinaryValue sbv = new BinaryValue( at, v1 );
         
         sbv.normalize();
         byte[] normalized = sbv.getNormalizedValueReference();
@@ -670,7 +669,7 @@ public class ServerBinaryValueTest
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sbv.getBytes() ) );
         
-        ServerBinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
+        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );
         
         assertEquals( sbv, sbvSer );
    }



Mime
View raw message