directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r370290 - /directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/schema/RegexNormalizer.java
Date Wed, 18 Jan 2006 22:43:00 GMT
Author: elecharny
Date: Wed Jan 18 14:42:56 2006
New Revision: 370290

URL: http://svn.apache.org/viewcvs?rev=370290&view=rev
Log:
- Get rid of a.o.regexp and oro, replaced them by jdk 1.4 regexp

Modified:
    directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/schema/RegexNormalizer.java

Modified: directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/schema/RegexNormalizer.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/schema/RegexNormalizer.java?rev=370290&r1=370289&r2=370290&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/schema/RegexNormalizer.java
(original)
+++ directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/schema/RegexNormalizer.java
Wed Jan 18 14:42:56 2006
@@ -17,7 +17,8 @@
 package org.apache.ldap.common.schema;
 
 
-import org.apache.oro.text.perl.Perl5Util ;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 
 /**
@@ -30,10 +31,10 @@
 public class RegexNormalizer implements Normalizer
 {
     /** the perl 5 regex engine */
-    private final Perl5Util perl = new Perl5Util() ;
+    private final Pattern[] regexes;
     
     /** the set of regular expressions used to transform values*/
-    private String [] regexes ;
+    private final Matcher[] matchers;
 
 
     /**
@@ -41,9 +42,15 @@
      *
      * @param regexes the set of regular expressions used to transform values
      */
-    public RegexNormalizer( String [] regexes )
+    public RegexNormalizer( Pattern[] regexes )
     {
-        this.regexes = regexes ;
+    	this.regexes = regexes;
+    	matchers = new Matcher[ regexes.length ];
+    	
+    	for ( int i = 0; i < regexes.length; i++ )
+    	{
+    		matchers[i] = regexes[i].matcher( "" ); 
+    	}
     }
 
 
@@ -61,9 +68,10 @@
         {
             String str = ( String ) value ;
     
-            for ( int ii = 0; ii < regexes.length; ii++ )
+            for ( int i = 0; i < matchers.length; i++ )
             {
-                str = perl.substitute( regexes[ii], str ) ;
+            	
+                str = matchers[i].replaceAll( str ) ;
             }
     
             return str ;
@@ -81,11 +89,11 @@
         StringBuffer buf = new StringBuffer() ;
         buf.append( "RegexNormalizer( " ) ;
 
-        for ( int ii = 0; ii < regexes.length; ii++ )
+        for ( int i = 0; i < regexes.length; i++ )
         {
-            buf.append( regexes[ii] );
+            buf.append( regexes[i] );
 
-            if ( ii < regexes.length - 1 )
+            if ( i < regexes.length - 1 )
             {
                 buf.append( ", " );
             }



Mime
View raw message