directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r345872 - /directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/DeepTrimNormalizer.java
Date Mon, 21 Nov 2005 09:11:28 GMT
Author: elecharny
Date: Mon Nov 21 01:11:18 2005
New Revision: 345872

URL: http://svn.apache.org/viewcvs?rev=345872&view=rev
Log:
- Protect the code from NPE
- added a case to deal with byte[] values

Modified:
    directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/DeepTrimNormalizer.java

Modified: directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/DeepTrimNormalizer.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/DeepTrimNormalizer.java?rev=345872&r1=345871&r2=345872&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/DeepTrimNormalizer.java
(original)
+++ directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/schema/DeepTrimNormalizer.java
Mon Nov 21 01:11:18 2005
@@ -19,6 +19,7 @@
 
 import javax.naming.NamingException;
 
+import org.apache.asn1.codec.util.StringUtils;
 import org.apache.ldap.common.util.StringTools;
 
 
@@ -34,6 +35,18 @@
 {
     public Object normalize( Object value ) throws NamingException
     {
-        return StringTools.deepTrim( value.toString() );
+        if ( value == null )
+        {
+            return null;
+        }
+        
+        if ( value instanceof byte[] )
+        {
+            return StringTools.deepTrim( StringUtils.toUtf8( (byte[])value ) );
+        }
+        else
+        {
+            return StringTools.deepTrim( (String)value );
+        }
     }
 }



Mime
View raw message