directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r329683 - /directory/shared/ldap/branches/shared-ldap-utf8/common/src/java/org/apache/ldap/common/schema/SchemaUtils.java
Date Mon, 31 Oct 2005 00:50:42 GMT
Author: elecharny
Date: Sun Oct 30 16:50:38 2005
New Revision: 329683

URL: http://svn.apache.org/viewcvs?rev=329683&view=rev
Log:
Moved the binaries HashSet initialization to this class, avoiding this 
initialization to be found all over the code (actually, only twice, but this is one
more than necessary)

Modified:
    directory/shared/ldap/branches/shared-ldap-utf8/common/src/java/org/apache/ldap/common/schema/SchemaUtils.java

Modified: directory/shared/ldap/branches/shared-ldap-utf8/common/src/java/org/apache/ldap/common/schema/SchemaUtils.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/common/src/java/org/apache/ldap/common/schema/SchemaUtils.java?rev=329683&r1=329682&r2=329683&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/common/src/java/org/apache/ldap/common/schema/SchemaUtils.java
(original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/common/src/java/org/apache/ldap/common/schema/SchemaUtils.java
Sun Oct 30 16:50:38 2005
@@ -17,8 +17,14 @@
 package org.apache.ldap.common.schema;
 
 
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
 import javax.naming.NamingException;
 
+import org.apache.asn1new.util.StringUtils;
+
 
 /**
  * Various utility methods for schema functions and objects.
@@ -28,6 +34,28 @@
  */
 public class SchemaUtils
 {
+
+    public static Set initBinaries( Hashtable env, String key ) 
+    {
+        // construct the set for fast lookups while filtering
+        String binaryIds = (String)env.get( key );
+
+        Set binaries = new HashSet();
+
+        if ( StringUtils.isEmpty( binaryIds ) == false )
+        {
+            String[] binaryArray = binaryIds.split( "/" );
+            
+            for ( int i = 0; i < binaryArray.length; i++ )
+            {
+                binaries.add( StringUtils.lowerCase( StringUtils.trim( binaryArray[i] ) )
);
+            }
+        }
+        
+        return binaries;
+    }
+
+    
     // ------------------------------------------------------------------------
     // qdescrs rendering operations
     // ------------------------------------------------------------------------



Mime
View raw message