directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r491034 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizer.java
Date Fri, 29 Dec 2006 15:49:58 GMT
Author: elecharny
Date: Fri Dec 29 07:49:58 2006
New Revision: 491034

URL: http://svn.apache.org/viewvc?view=rev&rev=491034
Log:
The normalizer is now called with the String type

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

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizer.java?view=diff&rev=491034&r1=491033&r2=491034
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizer.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DeepTrimNormalizer.java
Fri Dec 29 07:49:58 2006
@@ -6,20 +6,22 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.ldap.schema;
 
 
+import java.io.IOException;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -29,26 +31,32 @@
  * Normalizer which trims down whitespace replacing multiple whitespace
  * characters on the edges and within the string with a single space character
  * thereby preserving tokenization order.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
 public class DeepTrimNormalizer implements Normalizer
 {
-    public Object normalize( Object value ) throws NamingException
-    {
-        if ( value == null )
-        {
-            return null;
-        }
-
-        if ( value instanceof byte[] )
-        {
-            return StringTools.deepTrim( StringTools.utf8ToString( ( byte[] ) value ) );
-        }
-        else
-        {
-            return StringTools.deepTrim( ( String ) value );
-        }
-    }
-}
+   static final long serialVersionUID = 1L;
+
+   public Object normalize( Object 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 );
+           }
+       }
+       catch ( IOException ioe )
+       {
+           throw new NamingException( "Invalid value : " + value );
+       }
+   }
+}
\ No newline at end of file



Mime
View raw message