directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r798550 [4/5] - in /directory: apacheds/trunk/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/trunk/core-entry/src/test/java/org/apache/directory/server/core/entry/ apacheds/trunk/core-jndi/src/main/java/org/apache...
Date Tue, 28 Jul 2009 14:54:05 GMT
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java Tue Jul 28 14:54:01 2009
@@ -28,6 +28,9 @@
 
 import javax.naming.InvalidNameException;
 
+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.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -70,10 +73,10 @@
     private String upType;
 
     /** The name value. It can be a String or a byte array */
-    private Object normValue;
+    private Value<?> normValue;
 
     /** The name user provided value. It can be a String or a byte array */
-    private Object upValue;
+    private Value<?> upValue;
 
     /** The user provided atav */
     private String upName;
@@ -105,7 +108,28 @@
         length = 0;
     }
 
+    
+    /**
+     * Construct an AttributeTypeAndValue. The type and value are normalized :
+     * <li> the type is trimmed and lowercased </li>
+     * <li> the value is trimmed </li>
+     * <p>
+     * Note that the upValue should <b>not</b> be null or empty, or resolved
+     * to an empty string after having trimmed it. 
+     *
+     * @param upType The Usrr Provided type
+     * @param normType The normalized type
+     * @param upValue The User Provided value
+     * @param normValue The normalized value
+     */
+    public AttributeTypeAndValue( String upType, String normType, String upValue, String normValue ) throws InvalidNameException
+    {
+        this( upType, normType, new ClientStringValue( upValue ), new ClientStringValue( normValue ) );
+    }
 
+
+
+    
     /**
      * Construct an AttributeTypeAndValue. The type and value are normalized :
      * <li> the type is trimmed and lowercased </li>
@@ -119,7 +143,26 @@
      * @param upValue The User Provided value
      * @param normValue The normalized value
      */
-    public AttributeTypeAndValue( String upType, String normType, Object upValue, Object normValue ) throws InvalidNameException
+    public AttributeTypeAndValue( String upType, String normType, byte[] upValue, byte[] normValue ) throws InvalidNameException
+    {
+        this( upType, normType, new ClientBinaryValue( upValue ), new ClientBinaryValue( normValue ) );
+    }
+
+
+    /**
+     * Construct an AttributeTypeAndValue. The type and value are normalized :
+     * <li> the type is trimmed and lowercased </li>
+     * <li> the value is trimmed </li>
+     * <p>
+     * Note that the upValue should <b>not</b> be null or empty, or resolved
+     * to an empty string after having trimmed it. 
+     *
+     * @param upType The Usrr Provided type
+     * @param normType The normalized type
+     * @param upValue The User Provided value
+     * @param normValue The normalized value
+     */
+    public AttributeTypeAndValue( String upType, String normType, Value<?> upValue, Value<?> normValue ) throws InvalidNameException
     {
         String upTypeTrimmed = StringTools.trim( upType );
         String normTypeTrimmed = StringTools.trim( normType );
@@ -152,43 +195,10 @@
             
         }
             
-
-        if ( ( normValue == null ) || ( upValue == null ) )
-        {
-            if ( normValue instanceof String )
-            {
-                this.normValue = StringTools.isEmpty( ( String ) normValue ) ? "" : normValue;
-            }
-            else
-            {
-                this.normValue = normValue;
-            }
-
-            if ( upValue instanceof String )
-            {
-                this.upValue = StringTools.isEmpty( ( String ) upValue ) ? "" : upValue;
-            }
-            else
-            {
-                this.upValue = upValue;
-            }
-        }
-        else
-        {
-    
-            this.upValue = upValue;
-    
-            if ( normValue instanceof String )
-            {
-                this.normValue = StringTools.isEmpty( ( String ) normValue ) ? "" : normValue;
-            }
-            else
-            {
-                this.normValue = normValue;
-            }
-        }
-
-        upName = this.upType + '=' + ( this.upValue == null ? "" : this.upValue );
+        this.normValue = normValue;
+        this.upValue = upValue;
+        
+        upName = this.upType + '=' + ( this.upValue == null ? "" : this.upValue.getString() );
         start = 0;
         length = upName.length();
     }
@@ -213,8 +223,8 @@
     /**No protection*/ AttributeTypeAndValue( 
                             String upType, 
                             String normType, 
-                            Object upValue, 
-                            Object normValue,
+                            Value<?> upValue, 
+                            Value<?> normValue,
                             int start, 
                             int length, 
                             String upName )
@@ -319,7 +329,7 @@
      *
      * @return The value
      */
-    public Object getNormValue()
+    public Value<?> getNormValue()
     {
         return normValue;
     }
@@ -329,7 +339,7 @@
      *
      * @return The value
      */
-    public Object getUpValue()
+    public Value<?> getUpValue()
     {
         return upValue;
     }
@@ -351,17 +361,9 @@
      * @param value The user provided value of the AttributeTypeAndValue
      * @param normValue The normalized value
      */
-    public void setValue( Object upValue, Object normValue )
+    public void setValue( Value<?> upValue, Value<?> normValue )
     {
-        if ( normValue instanceof String )
-        {
-            this.normValue = StringTools.isEmpty( ( String ) normValue ) ? "" : ( String ) normValue;
-        }
-        else
-        {
-            this.normValue = normValue;
-        }
-
+        this.normValue = normValue;
         this.upValue = upValue;
         upName = upName.substring( 0, upName.indexOf( '=' ) + 1 ) + upValue;
         start = -1;
@@ -414,11 +416,11 @@
 
         if ( StringTools.isEmpty( newValue ) )
         {
-            this.normValue = "";
+            this.normValue = new ClientStringValue( "" );
         }
         else
         {
-            this.normValue = newValue;
+            this.normValue = new ClientStringValue( newValue );
         }
 
         upName = upName.substring( 0, upName.indexOf( '=' ) + 1 ) + value;
@@ -548,14 +550,15 @@
      * @return -1 if the first value is inferior to the second one, +1 if
      * its superior, 0 if both values are equal
      */
-    private int compareValue( Object val1, Object val2, boolean sensitivity )
+    private int compareValue( Value<?> val1, Value<?> val2, boolean sensitivity )
     {
-        if ( val1 instanceof String )
+        if ( !val1.isBinary() )
         {
-            if ( val2 instanceof String )
+            if ( !val2.isBinary() )
             {
-                int val = ( sensitivity == CASE_SENSITIVE ) ? ( ( String ) val1 ).compareTo( ( String ) val2 )
-                    : ( ( String ) val1 ).compareToIgnoreCase( ( String ) val2 );
+                int val = ( sensitivity == CASE_SENSITIVE ) ? 
+                    ( val1.getString() ).compareTo( val2.getString() )
+                    : ( val1.getString() ).compareToIgnoreCase( val2.getString() );
 
                 return ( val < 0 ? -1 : ( val > 0 ? 1 : val ) );
             }
@@ -564,21 +567,24 @@
                 return 1;
             }
         }
-        else if ( val1 instanceof byte[] )
+        else
         {
-            if ( Arrays.equals( ( byte[] ) val1, ( byte[] ) val2 ) )
+            if ( val2.isBinary() )
             {
-                return 0;
+                if ( Arrays.equals( val1.getBytes(), val2.getBytes() ) )
+                {
+                    return 0;
+                }
+                else
+                {
+                    return 1;
+                }
             }
             else
             {
                 return 1;
             }
         }
-        else
-        {
-            return 1;
-        }
     }
 
     private static final boolean[] DN_ESCAPED_CHARS = new boolean[]
@@ -610,7 +616,7 @@
      */
     public String normalize()
     {
-        if ( normValue instanceof String )
+        if ( !normValue.isBinary() )
         {
             // The result will be gathered in a stringBuilder
             StringBuilder sb = new StringBuilder();
@@ -618,7 +624,7 @@
             // First, store the type and the '=' char
             sb.append( normType ).append( '=' );
             
-            String normalizedValue =  ( String ) normValue;
+            String normalizedValue =  normValue.getString();
             int valueLength = normalizedValue.length();
             boolean escaped = false;
             
@@ -701,7 +707,7 @@
         else
         {
             return normType + "=#"
-                + StringTools.dumpHexPairs( ( byte[] ) normValue );
+                + StringTools.dumpHexPairs( normValue .getBytes() );
         }
     }
 
@@ -756,35 +762,13 @@
         }
             
         // Compare the values
-        if ( normValue == null )
-        {
-            return instance.normValue == null;
-        }
-        else if ( normValue instanceof String )
-        {
-            if ( instance.normValue instanceof String )
-            {
-                return normValue.equals( instance.normValue );
-            }
-            else
-            {
-                return false;
-            }
-        }
-        else if ( normValue instanceof byte[] )
+        if ( normValue.isNull() )
         {
-            if ( instance.normValue instanceof byte[] )
-            {
-                return Arrays.equals( (byte[])normValue, (byte[])instance.normValue );
-            }
-            else
-            {
-                return false;
-            }
+            return instance.normValue.isNull();
         }
         else
         {
-            return false;
+            return normValue.equals( instance.normValue );
         }
     }
 
@@ -819,8 +803,8 @@
              StringTools.isEmpty( normType ) ||
              ( start < 0 ) ||
              ( length < 2 ) ||             // At least a type and '='
-             ( upValue == null ) ||
-             ( normValue == null ) )
+             ( upValue.isNull() ) ||
+             ( normValue.isNull() ) )
         {
             String message = "Cannot serialize an wrong ATAV, ";
             
@@ -844,11 +828,11 @@
             {
                 message += "the length should not be < 2";
             }
-            else if ( upValue == null )
+            else if ( upValue.isNull() )
             {
                 message += "the upValue should not be null";
             }
-            else if ( normValue == null )
+            else if ( normValue.isNull() )
             {
                 message += "the value should not be null";
             }
@@ -863,21 +847,21 @@
         out.writeUTF( upType );
         out.writeUTF( normType );
         
-        boolean isHR = ( normValue instanceof String );
+        boolean isHR = !normValue.isBinary();
         
         out.writeBoolean( isHR );
         
         if ( isHR )
         {
-            out.writeUTF( (String)upValue );
-            out.writeUTF( (String)normValue );
+            out.writeUTF( upValue.getString() );
+            out.writeUTF( normValue.getString() );
         }
         else
         {
-            out.writeInt( ((byte[])upValue).length );
-            out.write( (byte[])upValue );
-            out.writeInt( ((byte[])normValue).length );
-            out.write( (byte[])normValue );
+            out.writeInt( upValue.length() );
+            out.write( upValue.getBytes() );
+            out.writeInt( normValue.length() );
+            out.write( normValue.getBytes() );
         }
     }
     
@@ -901,18 +885,20 @@
         
         if ( isHR )
         {
-            upValue = in.readUTF();
-            normValue = in.readUTF();
+            upValue = new ClientStringValue( in.readUTF() );
+            normValue = new ClientStringValue( in.readUTF() );
         }
         else
         {
             int upValueLength = in.readInt();
-            upValue = new byte[upValueLength];
-            in.readFully( (byte[])upValue );
+            byte[] upValueBytes = new byte[upValueLength];
+            in.readFully( upValueBytes );
+            upValue = new ClientBinaryValue( upValueBytes );
 
             int valueLength = in.readInt();
-            normValue = new byte[valueLength];
-            in.readFully( (byte[])normValue );
+            byte[] normValueBytes = new byte[valueLength];
+            in.readFully( normValueBytes );
+            normValue = new ClientBinaryValue( normValueBytes );
         }
     }
     
@@ -935,7 +921,7 @@
 
         if ( normValue != null )
         {
-            sb.append( normValue );
+            sb.append( normValue.getString() );
         }
 
         return sb.toString();

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DefaultStringNormalizer.java Tue Jul 28 14:54:01 2009
@@ -21,6 +21,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
 
@@ -36,30 +38,59 @@
  */
 public class DefaultStringNormalizer implements Normalizer
 {
+    // The serial UID
     private static final long serialVersionUID = 1L;
     
+    /** A default String normalizer */
     private static final DefaultStringNormalizer NORMALIZER = new DefaultStringNormalizer();
     
-    public Object normalize( Object value ) throws NamingException
+    /**
+     * {@inheritDoc}
+     */
+    public Value<?> normalize( Value<?> value ) throws NamingException
     {
-        String str = ( String ) value;
+        String str = value.getString();
         
-        if ( str == null || str.length() == 0 )
+        if ( StringTools.isEmpty( str ) )
         {
-            return str;
+            return new ClientStringValue( str );
         }
         
         if ( str.charAt( 0 ) == '#' )
         {
-            return StringTools.decodeHexString( str );
+            return new ClientStringValue( StringTools.decodeHexString( str ) );
         }
         
         if ( str.indexOf( '\\' ) != -1 )
         {
-            return StringTools.decodeEscapedHex( str );
+            return new ClientStringValue( StringTools.decodeEscapedHex( str ) );
+        }
+        
+        return new ClientStringValue( str );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value ) throws NamingException
+    {
+        if ( StringTools.isEmpty( value ) )
+        {
+            return value;
+        }
+        
+        if ( value.charAt( 0 ) == '#' )
+        {
+            return StringTools.decodeHexString( value );
+        }
+        
+        if ( value.indexOf( '\\' ) != -1 )
+        {
+            return StringTools.decodeEscapedHex( value );
         }
         
-        return str;
+        return value;
     }
 
     
@@ -70,7 +101,7 @@
      * @return The normalized object
      * @throws NamingException If the normalization throws an error
      */
-    public static Object normalizeString( String string ) throws NamingException
+    public static String normalizeString( String string ) throws NamingException
     {
         return NORMALIZER.normalize( string );
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java Tue Jul 28 14:54:01 2009
@@ -27,6 +27,7 @@
 import javax.naming.NameParser;
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.util.Position;
 import org.apache.directory.shared.ldap.util.StringTools;
 
@@ -174,7 +175,9 @@
         // SPACE*
         matchSpaces( name, pos );
 
-        rdn.addAttributeTypeAndValue( type, type, upValue, value );
+        rdn.addAttributeTypeAndValue( type, type, 
+            new ClientStringValue( upValue ), 
+            new ClientStringValue( value ) );
 
         rdn.setUpName( name.substring( rdnStart, pos.start ) );
         rdn.normalize();

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java Tue Jul 28 14:54:01 2009
@@ -36,6 +36,8 @@
 import javax.naming.Name;
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -1376,13 +1378,15 @@
      */
     private static void oidNormalize( Rdn rdn, OidNormalizer oidNormalizer ) throws NamingException
     {
-        Object upValue = rdn.getUpValue();
+        String upValue = rdn.getUpValue();
         String upType = rdn.getUpType();
         rdn.clear();
-        Object normStringValue = DefaultStringNormalizer.normalizeString( ( String ) upValue );
-        Object normValue = oidNormalizer.getNormalizer().normalize( normStringValue );
+        String normStringValue = DefaultStringNormalizer.normalizeString( ( String ) upValue );
+        String normValue = oidNormalizer.getNormalizer().normalize( normStringValue );
 
-        rdn.addAttributeTypeAndValue( upType, oidNormalizer.getAttributeTypeOid(), upValue, normValue );
+        rdn.addAttributeTypeAndValue( upType, oidNormalizer.getAttributeTypeOid(), 
+            new ClientStringValue( upValue ), 
+            new ClientStringValue( normValue ) );
     }
 
     /**

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java Tue Jul 28 14:54:01 2009
@@ -33,6 +33,8 @@
 import javax.naming.InvalidNameException;
 
 import org.apache.commons.collections.map.MultiValueMap;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -235,7 +237,9 @@
     */
    public Rdn( String upType, String normType, String upValue, String normValue ) throws InvalidNameException
    {
-       addAttributeTypeAndValue( upType, normType, upValue, normValue );
+       addAttributeTypeAndValue( upType, normType, 
+           new ClientStringValue( upValue), 
+           new ClientStringValue( normValue ) );
 
        upName = upType + '=' + upValue;
        start = 0;
@@ -323,13 +327,13 @@
            case 1:
                // We have a single AttributeTypeAndValue
                // We will trim and lowercase type and value.
-               if ( atav.getNormValue() instanceof String )
+               if ( !atav.getNormValue().isBinary() )
                {
                    normName = atav.getNormalizedValue();
                }
                else
                {
-                   normName = atav.getNormType() + "=#" + StringTools.dumpHexPairs( (byte[])atav.getNormValue() );
+                   normName = atav.getNormType() + "=#" + StringTools.dumpHexPairs( atav.getNormValue().getBytes() );
                }
 
                break;
@@ -374,12 +378,12 @@
    // We need this method to be visible from the DnParser class, but not
    // from outside this package.
    @SuppressWarnings({"unchecked"})
-   /* Unspecified protection */void addAttributeTypeAndValue( String upType, String type, Object upValue, Object value ) 
+   /* Unspecified protection */void addAttributeTypeAndValue( String upType, String type, Value<?> upValue, Value<?> value ) 
        throws InvalidNameException
    {
        // First, let's normalize the type
        String normalizedType = StringTools.lowerCaseAscii(type);
-       Object normalizedValue = value;
+       Value<?> normalizedValue = value;
 
        switch ( nbAtavs )
        {
@@ -508,7 +512,7 @@
            case 1:
                if ( StringTools.equals( atav.getNormType(), normalizedType ) )
                {
-                   return atav.getNormValue();
+                   return atav.getNormValue().get();
                }
 
                return "";
@@ -903,10 +907,10 @@
                return null;
 
            case 1:
-               return atav.getNormValue();
+               return atav.getNormValue().get();
 
            default:
-               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getNormValue();
+               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getNormValue().get();
        }
    }
 
@@ -916,7 +920,7 @@
     * 
     * @return The first User provided value of this RDN
     */
-   public Object getUpValue()
+   public String getUpValue()
    {
        switch ( nbAtavs )
        {
@@ -924,10 +928,10 @@
                return null;
 
            case 1:
-               return atav.getUpValue();
+               return atav.getUpValue().getString();
 
            default:
-               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getUpValue();
+               return ((TreeSet<AttributeTypeAndValue>)atavs).first().getUpValue().getString();
        }
    }
 
@@ -945,7 +949,7 @@
                 return null;
                 
             case 1:
-                return (String)atav.getNormValue();
+                return atav.getNormValue().getString();
                 
             default:
                 return ((TreeSet<AttributeTypeAndValue>)atavs).first().getNormalizedValue();

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java Tue Jul 28 14:54:01 2009
@@ -22,6 +22,8 @@
 
 import javax.naming.InvalidNameException;
 
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.util.DNUtils;
 import org.apache.directory.shared.ldap.util.Position;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -824,7 +826,18 @@
             {
                 if ( rdn != null )
                 {
-                    rdn.addAttributeTypeAndValue( type, type, value, value );
+                    if ( value instanceof String )
+                    {
+                        rdn.addAttributeTypeAndValue( type, type, 
+                            new ClientStringValue( (String)value ), 
+                            new ClientStringValue( (String)value ) );
+                    }
+                    else
+                    {
+                        rdn.addAttributeTypeAndValue( type, type, 
+                            new ClientBinaryValue( (byte[])value ), 
+                            new ClientBinaryValue( (byte[])value ) );
+                    }
                 }
             }
 
@@ -979,7 +992,19 @@
         }
 
         String upValue = StringTools.utf8ToString( dn, start2, pos.length );
-        rdn.addAttributeTypeAndValue( type, type, upValue, value );
+        
+        if ( value instanceof String )
+        {
+            rdn.addAttributeTypeAndValue( type, type, 
+                new ClientStringValue( upValue ), 
+                new ClientStringValue( (String)value ) );
+        }
+        else
+        {
+            rdn.addAttributeTypeAndValue( type, type, 
+                new ClientStringValue( upValue ), 
+                new ClientBinaryValue( (byte[])value ) );
+        }
         
         rdn.normalize();
 

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=798550&r1=798549&r2=798550&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 Tue Jul 28 14:54:01 2009
@@ -23,6 +23,7 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 
 
@@ -61,7 +62,7 @@
 
     public Object normalizeByName( String name, byte[] val ) throws NamingException
     {
-        return normalizer.normalize( val );
+        return normalizer.normalize( new ClientBinaryValue( val ) );
     }
 
 
@@ -73,7 +74,7 @@
 
     public Object normalizeByOid( String oid, byte[] val ) throws NamingException
     {
-        return normalizer.normalize( val );
+        return normalizer.normalize( new ClientBinaryValue( val ) );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java Tue Jul 28 14:54:01 2009
@@ -24,6 +24,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+
 
 /**
  * Converts attribute values to a canonical form.
@@ -36,11 +38,18 @@
     /**
      * Gets the normalized value.
      * 
-     * @param value
-     *            the value to normalize. It must *not* be null !
+     * @param value the value to normalize. It must *not* be null !
+     * @return the normalized form for a value
+     * @throws NamingException if an error results during normalization
+     */
+    Value<?> normalize( Value<?> value ) throws NamingException;
+
+    /**
+     * Gets the normalized value.
+     * 
+     * @param value the value to normalize. It must *not* be null !
      * @return the normalized form for a value
-     * @throws NamingException
-     *             if an error results during normalization
+     * @throws NamingException if an error results during normalization
      */
-    Object normalize( Object value ) throws NamingException;
+    String normalize( String value ) throws NamingException;
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NormalizingComparator.java Tue Jul 28 14:54:01 2009
@@ -23,6 +23,7 @@
 import java.util.Comparator;
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -72,7 +73,7 @@
 
         try
         {
-            n1 = normalizer.normalize( o1 );
+            n1 = normalizer.normalize( (String)o1 );
         }
         catch ( NamingException e )
         {
@@ -82,7 +83,7 @@
 
         try
         {
-            n2 = normalizer.normalize( o2 );
+            n2 = normalizer.normalize( (String)o2 );
         }
         catch ( NamingException e )
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/BooleanNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/BooleanNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/BooleanNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/BooleanNormalizer.java Tue Jul 28 14:54:01 2009
@@ -22,8 +22,9 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -35,28 +36,36 @@
  */
 public class BooleanNormalizer implements Normalizer
 {
+    // The serial UID
     private static final long serialVersionUID = 1L;
 
 
-    public Object normalize( Object value ) throws NamingException
+    /**
+     * {@inheritDoc}
+     */
+    public Value<?> normalize( Value<?> value ) throws NamingException
     {
         if ( value == null )
         {
             return null;
         }
 
-        String strValue;
+        String strValue = value.getString();
+        
+        return new ClientStringValue( strValue.trim().toUpperCase() );
+    }
 
-        if ( value instanceof byte[] )
-        {
-            strValue = StringTools.utf8ToString( ( byte[] ) value );
-        }
-        else
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value ) throws NamingException
+    {
+        if ( value == null )
         {
-            strValue = ( String ) value;
+            return null;
         }
 
-        return strValue.trim().toUpperCase();
+        return value.trim().toUpperCase();
     }
-
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java Tue Jul 28 14:54:01 2009
@@ -22,6 +22,7 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.util.SynchronizedLRUMap;
 
@@ -77,27 +78,46 @@
 
 
     /**
-     * @see org.apache.directory.shared.ldap.schema.Normalizer#normalize(java.lang.Object)
-     * 
-     * @param value the value to normalize. It must *not* be null !
-     * @return the normalized form for a value
-     * @throws NamingException if an error results during normalization
+     * {@inheritDoc}
      */
-    public Object normalize( Object value ) throws NamingException
+    public Value<?> normalize( Value<?> value ) throws NamingException
     {
         if ( value == null )
         {
             return null;
         }
 
-        Object result = cache.get( value );
+        Value<?> result =(Value<?>)cache.get( value );
 
         if ( result != null )
         {
             return result;
         }
 
-        Object normalized = normalizer.normalize( value );
+        Value<?> normalized = normalizer.normalize( value );
+        cache.put( value, normalized );
+        return normalized;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value ) throws NamingException
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+
+        String normalized =(String)cache.get( value );
+
+        if ( normalized != null )
+        {
+            return normalized;
+        }
+
+        normalized = normalizer.normalize( value );
         cache.put( value, normalized );
         return normalized;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimNormalizer.java Tue Jul 28 14:54:01 2009
@@ -24,6 +24,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.PrepareString;
 import org.apache.directory.shared.ldap.schema.PrepareString.StringType;
@@ -40,22 +42,39 @@
  */
 public class DeepTrimNormalizer implements Normalizer
 {
+    // The serial UID
    private static final long serialVersionUID = 1L;
 
-   public Object normalize( Object value ) throws NamingException
+   /**
+    * {@inheritDoc}
+    */
+   public Value<?> normalize( Value<?> value ) throws NamingException
    {
        try
        {
-           if ( value instanceof byte[] )
-           {
-               return PrepareString.normalize( StringTools.utf8ToString( ( byte[] ) value ), 
-                   PrepareString.StringType.DIRECTORY_STRING );
-           }
-           else
-           {
-               return PrepareString.normalize( ( String ) value,
-                   PrepareString.StringType.DIRECTORY_STRING );
-           }
+           String normalized = PrepareString.normalize( value.getString(), 
+               PrepareString.StringType.DIRECTORY_STRING ); 
+           
+           return new ClientStringValue( normalized ); 
+       }
+       catch ( IOException ioe )
+       {
+           throw new NamingException( "Invalid value : " + value );
+       }
+   }
+
+
+   /**
+    * {@inheritDoc}
+    */
+   public String normalize( String value ) throws NamingException
+   {
+       try
+       {
+           String normalized = PrepareString.normalize( value, 
+               PrepareString.StringType.DIRECTORY_STRING ); 
+           
+           return normalized; 
        }
        catch ( IOException ioe )
        {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimToLowerNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimToLowerNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimToLowerNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/DeepTrimToLowerNormalizer.java Tue Jul 28 14:54:01 2009
@@ -24,10 +24,10 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.PrepareString;
-import org.apache.directory.shared.ldap.schema.PrepareString.StringType;
-import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -41,9 +41,13 @@
  */
 public class DeepTrimToLowerNormalizer implements Normalizer
 {
+    // The serial UID
     private static final long serialVersionUID = 1L;
 
-    public Object normalize( Object value ) throws NamingException
+    /**
+     * {@inheritDoc}
+     */
+    public Value<?> normalize( Value<?> value ) throws NamingException
     {
         if ( value == null )
         {
@@ -52,16 +56,34 @@
 
         try
         {
-            if ( value instanceof byte[] )
-            {
-                return PrepareString.normalize( StringTools.utf8ToString( ( byte[] ) value ), 
-                    PrepareString.StringType.CASE_IGNORE );
-            }
-            else
-            {
-                return PrepareString.normalize( ( String ) value,
-                    PrepareString.StringType.CASE_IGNORE );
-            }
+            String normalized = PrepareString.normalize( value.getString(),
+                PrepareString.StringType.CASE_IGNORE );
+            
+            return new ClientStringValue( normalized );
+        }
+        catch ( IOException ioe )
+        {
+            throw new NamingException( "Invalid value : " + value );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value ) throws NamingException
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+
+        try
+        {
+            String normalized = PrepareString.normalize( value,
+                PrepareString.StringType.CASE_IGNORE );
+            
+            return normalized;
         }
         catch ( IOException ioe )
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java Tue Jul 28 14:54:01 2009
@@ -24,6 +24,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.PrepareString;
 import org.apache.directory.shared.ldap.schema.PrepareString.StringType;
@@ -43,22 +45,39 @@
  */
 public class GeneralizedTimeNormalizer implements Normalizer
 {
+    // The serial UID
    static final long serialVersionUID = 1L;
 
-   public Object normalize( Object value ) throws NamingException
+   /**
+    * {@inheritDoc}
+    */
+   public Value<?> normalize( Value<?> value ) throws NamingException
    {
        try
        {
-           if ( value instanceof byte[] )
-           {
-               return PrepareString.normalize( StringTools.utf8ToString( ( byte[] ) value ), 
-                   PrepareString.StringType.DIRECTORY_STRING );
-           }
-           else
-           {
-               return PrepareString.normalize( ( String ) value,
-                   PrepareString.StringType.DIRECTORY_STRING );
-           }
+           String normalized = PrepareString.normalize( value.getString(), 
+               PrepareString.StringType.DIRECTORY_STRING );
+           
+           return new ClientStringValue( normalized );
+       }
+       catch ( IOException ioe )
+       {
+           throw new NamingException( "Invalid value : " + value );
+       }
+   }
+
+   
+   /**
+    * {@inheritDoc}
+    */
+   public String normalize( String value ) throws NamingException
+   {
+       try
+       {
+           String normalized = PrepareString.normalize( value, 
+               PrepareString.StringType.DIRECTORY_STRING );
+           
+           return normalized;
        }
        catch ( IOException ioe )
        {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NoOpNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NoOpNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NoOpNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NoOpNormalizer.java Tue Jul 28 14:54:01 2009
@@ -22,6 +22,7 @@
 
 import java.io.Serializable;
 
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 
 
@@ -33,27 +34,33 @@
  */
 public class NoOpNormalizer implements Normalizer, Serializable
 {
-    public static final NoOpNormalizer INSTANCE = new NoOpNormalizer();
+    // The serial UID
     static final long serialVersionUID = -7817763636668562489L;
     
+    /** A static instance of this normalizer */
+    public static final NoOpNormalizer INSTANCE = new NoOpNormalizer();
 
     /**
-     * Creates a do nothing normalizer.
+     * Returns the value argument as-is without alterations all the time.
+     * 
+     * @param value any value
+     * @return the value argument returned as-is
+     * @see org.apache.directory.shared.ldap.schema.Normalizer#normalize(java.lang.Object)
      */
-    public NoOpNormalizer()
+    public Value<?> normalize( Value<?> value )
     {
+        return value;
     }
-
-
+    
+    
     /**
      * Returns the value argument as-is without alterations all the time.
      * 
-     * @param value
-     *            any value
+     * @param value any value
      * @return the value argument returned as-is
      * @see org.apache.directory.shared.ldap.schema.Normalizer#normalize(java.lang.Object)
      */
-    public Object normalize( Object value )
+    public String normalize( String value )
     {
         return value;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NumericNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NumericNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NumericNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/NumericNormalizer.java Tue Jul 28 14:54:01 2009
@@ -24,10 +24,10 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.PrepareString;
-import org.apache.directory.shared.ldap.schema.PrepareString.StringType;
-import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -37,22 +37,38 @@
  */
 public class NumericNormalizer implements Normalizer
 {
+    // The serial UID
    static final long serialVersionUID = 1L;
 
-   public Object normalize( Object value ) throws NamingException
+   
+   /**
+    * {@inheritDoc}
+    */
+   public Value<?> normalize( Value<?> value ) throws NamingException
    {
        try
        {
-           if ( value instanceof byte[] )
-           {
-               return PrepareString.normalize( StringTools.utf8ToString( ( byte[] ) value ), 
-                   PrepareString.StringType.NUMERIC_STRING );
-           }
-           else
-           {
-               return PrepareString.normalize( ( String ) value,
-                   PrepareString.StringType.NUMERIC_STRING );
-           }
+           String normalized = PrepareString.normalize( value.getString(),
+               PrepareString.StringType.NUMERIC_STRING );
+           
+           return new ClientStringValue( normalized );
+       }
+       catch ( IOException ioe )
+       {
+           throw new NamingException( "Invalid value : " + value );
+       }
+   }
+
+
+   /**
+    * {@inheritDoc}
+    */
+   public String normalize( String value ) throws NamingException
+   {
+       try
+       {
+           return PrepareString.normalize( value,
+               PrepareString.StringType.NUMERIC_STRING );
        }
        catch ( IOException ioe )
        {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ObjectIdentifierNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ObjectIdentifierNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ObjectIdentifierNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/ObjectIdentifierNormalizer.java Tue Jul 28 14:54:01 2009
@@ -22,6 +22,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 
 
@@ -33,21 +35,48 @@
  */
 public class ObjectIdentifierNormalizer implements Normalizer
 {
+    // The serial UID
     private static final long serialVersionUID = 1L;
 
-    public Object normalize( Object value ) throws NamingException
+    /**
+     * {@inheritDoc}
+     */
+    public Value<?> normalize( Value<?> value ) throws NamingException
     {
         if ( value == null )
         {
             return null;
         }
 
-        if ( !( value instanceof String ) )
+        String str = value.getString().trim();
+
+        if ( str.length() == 0 )
+        {
+            return new ClientStringValue( "" );
+        }
+        else if ( Character.isDigit( str.charAt( 0 ) ) )
         {
-            return value;
+            // We do this test to avoid a lowerCasing which cost time
+            return new ClientStringValue( str );
+        }
+        else
+        {
+            return new ClientStringValue( str.toLowerCase() );
+        }
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value ) throws NamingException
+    {
+        if ( value == null )
+        {
+            return null;
         }
 
-        String str = ( ( String ) value ).trim();
+        String str = value.trim();
 
         if ( str.length() == 0 )
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/RegexNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/RegexNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/RegexNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/RegexNormalizer.java Tue Jul 28 14:54:01 2009
@@ -23,6 +23,8 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 
 
@@ -34,6 +36,7 @@
  */
 public class RegexNormalizer implements Normalizer
 {
+    // The serial UID
     private static final long serialVersionUID = 1L;
     
     /** the perl 5 regex engine */
@@ -72,18 +75,18 @@
 
 
     /**
-     * @see org.apache.directory.shared.ldap.schema.Normalizer#normalize(Object)
+     * {@inheritDoc}
      */
-    public Object normalize( final Object value )
+    public Value<?> normalize( final Value<?> value )
     {
         if ( value == null )
         {
             return null;
         }
 
-        if ( value instanceof String )
+        if ( !value.isBinary() )
         {
-            String str = ( String ) value;
+            String str = value.getString();
 
             for ( int i = 0; i < matchers.length; i++ )
             {
@@ -91,13 +94,37 @@
                 str = matchers[i].replaceAll( str );
             }
 
-            return str;
+            return new ClientStringValue( str );
         }
 
         return value;
     }
 
 
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value )
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+
+        String str = value;
+        
+        for ( int i = 0; i < matchers.length; i++ )
+        {
+
+            str = matchers[i].replaceAll( str );
+        }
+
+        return str;
+    }
+    
+    
     /**
      * @see java.lang.Object#toString()
      */

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/TelephoneNumberNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/TelephoneNumberNormalizer.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/TelephoneNumberNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/TelephoneNumberNormalizer.java Tue Jul 28 14:54:01 2009
@@ -24,10 +24,10 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.PrepareString;
-import org.apache.directory.shared.ldap.schema.PrepareString.StringType;
-import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -37,22 +37,37 @@
  */
 public class TelephoneNumberNormalizer implements Normalizer
 {
+    // The serial UID
    static final long serialVersionUID = 1L;
 
-   public Object normalize( Object value ) throws NamingException
+   /**
+    * {@inheritDoc}
+    */
+   public Value<?> normalize( Value<?> value ) throws NamingException
    {
        try
        {
-           if ( value instanceof byte[] )
-           {
-               return PrepareString.normalize( StringTools.utf8ToString( ( byte[] ) value ), 
-                   PrepareString.StringType.TELEPHONE_NUMBER );
-           }
-           else
-           {
-               return PrepareString.normalize( ( String ) value,
-                   PrepareString.StringType.TELEPHONE_NUMBER );
-           }
+           String normalized = PrepareString.normalize( value.getString(),
+               PrepareString.StringType.TELEPHONE_NUMBER );
+           
+           return new ClientStringValue( normalized );
+       }
+       catch ( IOException ioe )
+       {
+           throw new NamingException( "Invalid value : " + value );
+       }
+   }
+
+
+   /**
+    * {@inheritDoc}
+    */
+   public String normalize( String value ) throws NamingException
+   {
+       try
+       {
+           return PrepareString.normalize( value,
+               PrepareString.StringType.TELEPHONE_NUMBER );
        }
        catch ( IOException ioe )
        {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java Tue Jul 28 14:54:01 2009
@@ -244,7 +244,7 @@
      * @return <code>true</code> if the value exists in the attribute</code>
      * @throws NamingException If something went wrong while accessing the data
      */
-    public static boolean containsValue( Attribute attr, Object compared, AttributeType type ) throws NamingException
+    public static boolean containsValue( Attribute attr, Value<?> compared, AttributeType type ) throws NamingException
     {
         // quick bypass test
         if ( attr.contains( compared ) )
@@ -267,7 +267,7 @@
 
         if ( type.getSyntax().isHumanReadable() )
         {
-            String comparedStr = ( String ) normalizer.normalize( compared );
+            String comparedStr = normalizer.normalize( compared.getString() );
 
             for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); /**/)
             {
@@ -282,19 +282,19 @@
         {
             byte[] comparedBytes = null;
 
-            if ( compared instanceof String )
+            if ( !compared.isBinary() )
             {
-                if ( ( ( String ) compared ).length() < 3 )
+                if ( compared.getString().length() < 3 )
                 {
                     return false;
                 }
 
-                // Tansform the String to a byte array
+                // Transform the String to a byte array
                 int state = 1;
-                comparedBytes = new byte[( ( String ) compared ).length() / 3];
+                comparedBytes = new byte[compared.getString().length() / 3];
                 int pos = 0;
 
-                for ( char c : ( ( String ) compared ).toCharArray() )
+                for ( char c : compared.getString().toCharArray() )
                 {
                     switch ( state )
                     {
@@ -338,7 +338,7 @@
             }
             else
             {
-                comparedBytes = ( byte[] ) compared;
+                comparedBytes = compared.getBytes();
             }
 
             for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); /**/)
@@ -427,6 +427,7 @@
     }
 
 
+    /*
     public static boolean containsAnyValues( Attribute attr, Object[] compared, AttributeType type )
         throws NamingException
     {
@@ -476,6 +477,7 @@
 
         return false;
     }
+    */
 
 
     /**
@@ -1057,7 +1059,7 @@
      * @param type the attribute type
      * @return the value removed from the attribute, otherwise null
      * @throws NamingException if something went wrong while removing the value
-     */
+     *
     public static Object removeValue( Attribute attr, Object compared, AttributeType type ) throws NamingException
     {
         // quick bypass test
@@ -1082,7 +1084,7 @@
         {
             String comparedStr = ( String ) normalizer.normalize( compared );
 
-            for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); /**/)
+            for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); )
             {
                 String value = ( String ) values.nextElement();
                 if ( comparedStr.equals( normalizer.normalize( value ) ) )
@@ -1154,7 +1156,7 @@
                 comparedBytes = ( byte[] ) compared;
             }
 
-            for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); /**/)
+            for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); )
             {
                 Object value = values.nextElement();
 
@@ -1262,7 +1264,7 @@
             // Looping on values
             for ( Iterator<Value<?>> valueIterator = entryAttribute.iterator(); valueIterator.hasNext(); )
             {
-                Value<?> value = ( Value<?> ) valueIterator.next();
+                Value<?> value = valueIterator.next();
                 attribute.add( value.get() );
             }
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java Tue Jul 28 14:54:01 2009
@@ -623,7 +623,7 @@
 
         for ( Value<?> value:attribute )
         {
-            assertEquals( "", value.get() );
+            assertEquals( "", value.getString() );
         }
 
         // Check the length
@@ -712,7 +712,7 @@
  
         for ( Value<?> value:attribute )
         {
-            assertEquals( "", value.get() );
+            assertEquals( "", value.getString() );
         }
 
         // Check the length

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java Tue Jul 28 14:54:01 2009
@@ -561,7 +561,7 @@
         String attrValue = attributeValue.getString();
         assertEquals( "Paris", attrValue );
 
-        attrValue = (String)attributeValue.get( 1 ).get();
+        attrValue = attributeValue.get( 1 ).getString();
         assertEquals( "London", attrValue );
 
         modification = modifications.get( 1 );
@@ -1281,7 +1281,7 @@
         String attrValue = attributeValue.getString();
         assertEquals( "a", attrValue );
 
-        attrValue = ( String ) attributeValue.get( 1 ).get();
+        attrValue = attributeValue.get( 1 ).getString();
         assertEquals( "b", attrValue );
 
         // Check the length

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java Tue Jul 28 14:54:01 2009
@@ -675,7 +675,7 @@
 
         assertNull( extensibleMatchFilter.getMatchingRule() );
         assertNull( extensibleMatchFilter.getType() );
-        assertEquals( "test", StringTools.utf8ToString( (byte[])extensibleMatchFilter.getMatchValue().get() ) );
+        assertEquals( "test", extensibleMatchFilter.getMatchValue().getString() );
         assertFalse( extensibleMatchFilter.isDnAttributes() );
 
         List<EntryAttribute> attributes = sr.getAttributes();

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java Tue Jul 28 14:54:01 2009
@@ -198,7 +198,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "top", assertion.getAssertionValue().get() );
+        assertEquals( "top", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass=top) (ou=contacts) ) (...
         equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 1 );
@@ -208,7 +208,7 @@
         assertNotNull( assertion );
 
         assertEquals( "ou", assertion.getAttributeDesc() );
-        assertEquals( "contacts", assertion.getAssertionValue().get() );
+        assertEquals( "contacts", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass=top) (ou=contacts) ) (! ...
         NotFilter notFilter = ( NotFilter ) andFilters.get( 1 );
@@ -222,7 +222,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "ttt", assertion.getAssertionValue().get() );
+        assertEquals( "ttt", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
 
@@ -363,7 +363,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "top", assertion.getAssertionValue().get() );
+        assertEquals( "top", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass~=top) (ou<=contacts) ) (...
         AttributeValueAssertionFilter lessOrEqual = ( AttributeValueAssertionFilter ) orFilters.get( 1 );
@@ -373,7 +373,7 @@
         assertNotNull( assertion );
 
         assertEquals( "ou", assertion.getAttributeDesc() );
-        assertEquals( "contacts", assertion.getAssertionValue().get() );
+        assertEquals( "contacts", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass~=top) (ou<=contacts) ) (! ...
         NotFilter notFilter = ( NotFilter ) andFilters.get( 1 );
@@ -387,7 +387,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "ttt", assertion.getAssertionValue().get() );
+        assertEquals( "ttt", assertion.getAssertionValue().getString() );
 
         // The attributes
         List<EntryAttribute> attributes = sr.getAttributes();
@@ -555,7 +555,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "ttt", assertion.getAssertionValue().get() );
+        assertEquals( "ttt", assertion.getAssertionValue().getString() );
 
         // The attributes
         List<EntryAttribute> attributes = sr.getAttributes();
@@ -962,31 +962,31 @@
             .getAssertion();
 
         assertEquals( "uid", assertion.getAttributeDesc() );
-        assertEquals( "akarasulu", assertion.getAssertionValue().get() );
+        assertEquals( "akarasulu", assertion.getAssertionValue().getString() );
 
         // cn=aok
         assertion = ( ( AttributeValueAssertionFilter ) orFilter.getOrFilter().get( 1 ) ).getAssertion();
 
         assertEquals( "cn", assertion.getAttributeDesc() );
-        assertEquals( "aok", assertion.getAssertionValue().get() );
+        assertEquals( "aok", assertion.getAssertionValue().getString() );
 
         // ou = Human Resources
         assertion = ( ( AttributeValueAssertionFilter ) orFilter.getOrFilter().get( 2 ) ).getAssertion();
 
         assertEquals( "ou", assertion.getAttributeDesc() );
-        assertEquals( "Human Resources", assertion.getAssertionValue().get() );
+        assertEquals( "Human Resources", assertion.getAssertionValue().getString() );
 
         // l=Santa Clara
         assertion = ( ( AttributeValueAssertionFilter ) orFilter.getOrFilter().get( 3 ) ).getAssertion();
 
         assertEquals( "l", assertion.getAttributeDesc() );
-        assertEquals( "Santa Clara", assertion.getAssertionValue().get() );
+        assertEquals( "Santa Clara", assertion.getAssertionValue().getString() );
 
         // cn=abok
         assertion = ( ( AttributeValueAssertionFilter ) orFilter.getOrFilter().get( 4 ) ).getAssertion();
 
         assertEquals( "cn", assertion.getAttributeDesc() );
-        assertEquals( "abok", assertion.getAssertionValue().get() );
+        assertEquals( "abok", assertion.getAssertionValue().getString() );
 
         // The attributes
         List<EntryAttribute> attributes = sr.getAttributes();
@@ -1245,7 +1245,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "top", assertion.getAssertionValue().get() );
+        assertEquals( "top", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass=top) (ou=contacts) ) (...
         equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 1 );
@@ -1255,7 +1255,7 @@
         assertNotNull( assertion );
 
         assertEquals( "2.5.4.11", assertion.getAttributeDesc() );
-        assertEquals( "contacts", assertion.getAssertionValue().get() );
+        assertEquals( "contacts", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass=top) (ou=contacts) ) (! ...
         NotFilter notFilter = ( NotFilter ) andFilters.get( 1 );
@@ -1269,7 +1269,7 @@
         assertNotNull( assertion );
 
         assertEquals( "organizationalUnitName", assertion.getAttributeDesc() );
-        assertEquals( "ttt", assertion.getAssertionValue().get() );
+        assertEquals( "ttt", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
 
@@ -1556,7 +1556,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "top", assertion.getAssertionValue().get() );
+        assertEquals( "top", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass=top) (ou=contacts) ) (...
         equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 1 );
@@ -1566,7 +1566,7 @@
         assertNotNull( assertion );
 
         assertEquals( "ou", assertion.getAttributeDesc() );
-        assertEquals( "contacts", assertion.getAssertionValue().get() );
+        assertEquals( "contacts", assertion.getAssertionValue().getString() );
 
         // (& (| (objectclass=top) (ou=contacts) ) (! ...
         NotFilter notFilter = ( NotFilter ) andFilters.get( 1 );
@@ -1580,7 +1580,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectclass", assertion.getAttributeDesc() );
-        assertEquals( "ttt", assertion.getAssertionValue().get() );
+        assertEquals( "ttt", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
 
@@ -2550,7 +2550,7 @@
         AttributeValueAssertion assertion = greaterThanFilter.getAssertion();
 
         assertEquals( "test", assertion.getAttributeDesc() );
-        assertEquals( "", assertion.getAssertionValue().get() );
+        assertEquals( "", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
 
@@ -2633,7 +2633,7 @@
         AttributeValueAssertion assertion = greaterThanFilter.getAssertion();
 
         assertEquals( "test", assertion.getAttributeDesc() );
-        assertEquals( "", assertion.getAssertionValue().get() );
+        assertEquals( "", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
 
@@ -2728,7 +2728,7 @@
         AttributeValueAssertion assertion = greaterThanFilter.getAssertion();
 
         assertEquals( "test", assertion.getAttributeDesc() );
-        assertEquals( "", assertion.getAssertionValue().get() );
+        assertEquals( "", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
 
@@ -2993,7 +2993,7 @@
         assertNotNull( assertion );
 
         assertEquals( "pgpdisabled", assertion.getAttributeDesc() );
-        assertEquals( "0", assertion.getAssertionValue().get() );
+        assertEquals( "0", assertion.getAssertionValue().getString() );
 
         // Check the encoding
         // We won't check the whole PDU, as it may differs because
@@ -3091,7 +3091,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -3200,7 +3200,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -3314,7 +3314,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         // (&(a=b)(c=d))
         equalityMatch = ( AttributeValueAssertionFilter ) andFilters.get( 1 );
@@ -3324,7 +3324,7 @@
         assertNotNull( assertion );
 
         assertEquals( "c", assertion.getAttributeDesc() );
-        assertEquals( "d", assertion.getAssertionValue().get() );
+        assertEquals( "d", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -3439,7 +3439,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -3560,7 +3560,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         // (&(&(a=b)(c=d)
         equalityMatch = ( AttributeValueAssertionFilter ) andFilters2.get( 1 );
@@ -3570,7 +3570,7 @@
         assertNotNull( assertion );
 
         assertEquals( "c", assertion.getAttributeDesc() );
-        assertEquals( "d", assertion.getAssertionValue().get() );
+        assertEquals( "d", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -3690,7 +3690,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         // (&(&(a=b))(c=d))
         equalityMatch = ( AttributeValueAssertionFilter ) andFilters.get( 1 );
@@ -3700,7 +3700,7 @@
         assertNotNull( assertion );
 
         assertEquals( "c", assertion.getAttributeDesc() );
-        assertEquals( "d", assertion.getAssertionValue().get() );
+        assertEquals( "d", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -3825,7 +3825,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         // (&(&(a=b)(c=d)...
         equalityMatch = ( AttributeValueAssertionFilter ) andFilters2.get( 1 );
@@ -3835,7 +3835,7 @@
         assertNotNull( assertion );
 
         assertEquals( "c", assertion.getAttributeDesc() );
-        assertEquals( "d", assertion.getAssertionValue().get() );
+        assertEquals( "d", assertion.getAssertionValue().getString() );
         
         // (&(&(a=b)(c=d))(e=f))
         equalityMatch = ( AttributeValueAssertionFilter ) andFilters.get( 1 );
@@ -3845,7 +3845,7 @@
         assertNotNull( assertion );
 
         assertEquals( "e", assertion.getAttributeDesc() );
-        assertEquals( "f", assertion.getAssertionValue().get() );
+        assertEquals( "f", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -3965,7 +3965,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         // (&(a=b)(|(...
         OrFilter orFilter = ( OrFilter ) andFilters.get( 1 );
@@ -3982,7 +3982,7 @@
         assertNotNull( assertion );
 
         assertEquals( "c", assertion.getAttributeDesc() );
-        assertEquals( "d", assertion.getAssertionValue().get() );
+        assertEquals( "d", assertion.getAssertionValue().getString() );
 
         // (&(a=b)(|(c=d)(e=f)))
         equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 1 );
@@ -3992,7 +3992,7 @@
         assertNotNull( assertion );
 
         assertEquals( "e", assertion.getAttributeDesc() );
-        assertEquals( "f", assertion.getAssertionValue().get() );
+        assertEquals( "f", assertion.getAssertionValue().getString() );
         
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -4114,7 +4114,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         // (&(&(a=b))(&...
         andFilter2 = ( AndFilter ) andFilters.get( 1 );
@@ -4131,7 +4131,7 @@
         assertNotNull( assertion );
 
         assertEquals( "c", assertion.getAttributeDesc() );
-        assertEquals( "d", assertion.getAssertionValue().get() );
+        assertEquals( "d", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -4256,7 +4256,7 @@
         assertNotNull( assertion );
 
         assertEquals( "a", assertion.getAttributeDesc() );
-        assertEquals( "b", assertion.getAssertionValue().get() );
+        assertEquals( "b", assertion.getAssertionValue().getString() );
 
         // (&(&(a=b)(c=d))...
         equalityMatch = ( AttributeValueAssertionFilter ) andFilters2.get( 1 );
@@ -4266,7 +4266,7 @@
         assertNotNull( assertion );
 
         assertEquals( "c", assertion.getAttributeDesc() );
-        assertEquals( "d", assertion.getAssertionValue().get() );
+        assertEquals( "d", assertion.getAssertionValue().getString() );
         
         // (&(&(a=b)(c=d))(&...
         andFilter2 = ( AndFilter ) andFilters.get( 1 );
@@ -4283,7 +4283,7 @@
         assertNotNull( assertion );
 
         assertEquals( "e", assertion.getAttributeDesc() );
-        assertEquals( "f", assertion.getAssertionValue().get() );
+        assertEquals( "f", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -4421,7 +4421,7 @@
         assertNotNull( assertion );
 
         assertEquals( "e", assertion.getAttributeDesc() );
-        assertEquals( "f", assertion.getAssertionValue().get() );
+        assertEquals( "f", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -4585,7 +4585,7 @@
         assertNotNull( assertion );
 
         assertEquals( "uid", assertion.getAttributeDesc() );
-        assertEquals( "buster ", assertion.getAssertionValue().get() );
+        assertEquals( "buster ", assertion.getAssertionValue().getString() );
 
         // (&(uid=buster)(sbAttribute=Buy))
         equalityMatch = ( AttributeValueAssertionFilter ) andFilters.get( 1 );
@@ -4595,7 +4595,7 @@
         assertNotNull( assertion );
 
         assertEquals( "sbAttribute", assertion.getAttributeDesc() );
-        assertEquals( "Buy ", assertion.getAssertionValue().get() );
+        assertEquals( "Buy ", assertion.getAssertionValue().getString() );
 
         List<EntryAttribute> attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
@@ -4695,7 +4695,7 @@
         assertNotNull( assertion );
 
         assertEquals( "objectClass", assertion.getAttributeDesc() );
-        assertEquals( "person", assertion.getAssertionValue().get() );
+        assertEquals( "person", assertion.getAssertionValue().getString() );
 
         // (&(a=b)(|
         OrFilter orFilter = ( OrFilter ) andFilters.get( 1 );
@@ -4721,6 +4721,6 @@
         assertNotNull( assertion );
 
         assertEquals( "sn", assertion.getAttributeDesc() );
-        assertEquals( "Jagger", assertion.getAssertionValue().get() );
+        assertEquals( "Jagger", assertion.getAssertionValue().getString() );
     }
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java?rev=798550&r1=798549&r2=798550&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValueTest.java Tue Jul 28 14:54:01 2009
@@ -35,6 +35,7 @@
 import javax.naming.NamingException;
 import javax.naming.directory.InvalidAttributeValueException;
 
+import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.SyntaxChecker;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -58,11 +59,11 @@
     {
         private static final long serialVersionUID = 1L;
         
-        public Object normalize( Object value ) throws NamingException
+        public Value<?> normalize( Value<?> value ) throws NamingException
         {
-            if ( value instanceof byte[] )
+            if ( value.isBinary() )
             {
-                byte[] val = (byte[])value;
+                byte[] val = value.getBytes();
                 // each byte will be changed to be > 0, and spaces will be trimmed
                 byte[] newVal = new byte[ val.length ];
                 int i = 0;
@@ -72,12 +73,17 @@
                     newVal[i++] = (byte)(b & 0x007F); 
                 }
                 
-                return StringTools.trim( newVal );
+                return new ClientBinaryValue( StringTools.trim( newVal ) );
             }
 
             throw new IllegalStateException( "expected byte[] to normalize" );
         }
-    };
+
+        public String normalize( String value ) throws NamingException
+        {
+            throw new IllegalStateException( "expected byte[] to normalize" );
+        }
+};
 
     
     /**
@@ -87,15 +93,20 @@
     {
         private static final long serialVersionUID = 1L;
         
-        public Object normalize( Object value ) throws NamingException
+        public Value<?> normalize( Value<?> value ) throws NamingException
         {
-            if ( value instanceof byte[] )
+            if ( value.isBinary() )
             {
-                return StringTools.EMPTY_BYTES;
+                return new ClientBinaryValue( StringTools.EMPTY_BYTES );
             }
 
             throw new IllegalStateException( "expected byte[] to normalize" );
         }
+
+        public String normalize( String value ) throws NamingException
+        {
+            throw new IllegalStateException( "expected byte[] to normalize" );
+        }
     };
 
     
@@ -240,7 +251,7 @@
     {
         ClientBinaryValue cbv = new ClientBinaryValue( null );
         
-        assertEquals( null, cbv.get() );
+        assertNull( cbv.get() );
         assertFalse( cbv.isNormalized() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertTrue( cbv.isNull() );
@@ -253,7 +264,7 @@
     {
         ClientBinaryValue cbv = new ClientBinaryValue( StringTools.EMPTY_BYTES );
         
-        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.get() ) );
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.getBytes() ) );
         assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.getCopy() ) );
         assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.getReference() ) );
         assertFalse( cbv.isNormalized() );
@@ -270,7 +281,7 @@
     {
         ClientBinaryValue cbv = new ClientBinaryValue( BYTES1 );
         
-        assertTrue( Arrays.equals( BYTES1, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES1, cbv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.getCopy() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.getReference() ) );
         assertFalse( cbv.isNormalized() );
@@ -288,7 +299,7 @@
         
         cbv.set( BYTES1 );
         
-        assertTrue( Arrays.equals( BYTES1, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES1, cbv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.getCopy() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.getReference() ) );
         assertFalse( cbv.isNormalized() );
@@ -304,7 +315,7 @@
     {
         ClientBinaryValue cbv = new ClientBinaryValue( BYTES2 );
         
-        assertTrue( Arrays.equals( BYTES2, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES2, cbv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES2, cbv.getCopy() ) );
         assertTrue( Arrays.equals( BYTES2, cbv.getReference() ) );
         assertFalse( cbv.isNormalized() );
@@ -333,19 +344,19 @@
         cbv.set( StringTools.EMPTY_BYTES );
         cbv.normalize( BINARY_NORMALIZER );
         assertTrue( cbv.isNormalized() );
-        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.get() ) );
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.getBytes() ) );
         assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.getNormalizedValue() ) );
         
         cbv.set( BYTES1 );
         cbv.normalize( BINARY_NORMALIZER );
         assertTrue( cbv.isNormalized() );
-        assertTrue( Arrays.equals( BYTES1, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES1, cbv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.getNormalizedValue() ) );
 
         cbv.set( BYTES2 );
         cbv.normalize( BINARY_NORMALIZER );
         assertTrue( cbv.isNormalized() );
-        assertTrue( Arrays.equals( BYTES2, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES2, cbv.getBytes() ) );
         assertTrue( Arrays.equals( BYTES1, cbv.getNormalizedValue() ) );
     }
 
@@ -410,8 +421,8 @@
 
         cbv.getReference()[0] = 0x11;
         
-        assertTrue( Arrays.equals( BYTES_MOD, cbv.get() ) );
-        assertTrue( Arrays.equals( BYTES1, copy.get() ) );
+        assertTrue( Arrays.equals( BYTES_MOD, cbv.getBytes() ) );
+        assertTrue( Arrays.equals( BYTES1, copy.getBytes() ) );
     }
 
 
@@ -433,7 +444,7 @@
 
         cbv.getReference()[0] = 0x11;
         assertTrue( Arrays.equals( BYTES1, copy ) );
-        assertTrue( Arrays.equals( BYTES_MOD, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES_MOD, cbv.getBytes() ) );
     }
 
 
@@ -504,7 +515,7 @@
 
         cbv.getReference()[0] = 0x11;
         assertTrue( Arrays.equals( BYTES_MOD, reference ) );
-        assertTrue( Arrays.equals( BYTES_MOD, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES_MOD, cbv.getBytes() ) );
     }
 
 
@@ -517,16 +528,16 @@
         
         cbv.set( StringTools.EMPTY_BYTES );
         assertNotNull( cbv.get() );
-        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.get() ) );
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.getBytes() ) );
         
         cbv.set( BYTES1 );
-        byte[] get = cbv.get();
+        byte[] get = cbv.getBytes();
         
         assertTrue( Arrays.equals( BYTES1, get ) );
 
         cbv.getReference()[0] = 0x11;
         assertTrue( Arrays.equals( BYTES1, get ) );
-        assertTrue( Arrays.equals( BYTES_MOD, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES_MOD, cbv.getBytes() ) );
     }
 
 
@@ -668,14 +679,14 @@
 
         cbv.set( StringTools.EMPTY_BYTES );
         assertNotNull( cbv.get() );
-        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.get() ) );
+        assertTrue( Arrays.equals( StringTools.EMPTY_BYTES, cbv.getBytes() ) );
         assertFalse( cbv.isNormalized() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );
 
         cbv.set( BYTES1 );
         assertNotNull( cbv.get() );
-        assertTrue( Arrays.equals( BYTES1, cbv.get() ) );
+        assertTrue( Arrays.equals( BYTES1, cbv.getBytes() ) );
         assertFalse( cbv.isNormalized() );
         assertTrue( cbv.isValid( BINARY_CHECKER ) );
         assertFalse( cbv.isNull() );



Mime
View raw message