directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r329612 - /directory/shared/ldap/branches/shared-ldap-utf8/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
Date Sun, 30 Oct 2005 19:55:33 GMT
Author: elecharny
Date: Sun Oct 30 11:55:28 2005
New Revision: 329612

URL: http://svn.apache.org/viewcvs?rev=329612&view=rev
Log:
Added an initialization of the binary attributes HashSet.

Modified:
    directory/shared/ldap/branches/shared-ldap-utf8/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java

Modified: directory/shared/ldap/branches/shared-ldap-utf8/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-utf8/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java?rev=329612&r1=329611&r2=329612&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-utf8/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
(original)
+++ directory/shared/ldap/branches/shared-ldap-utf8/apache-provider/src/java/org/apache/ldap/common/berlib/asn1/SnickersDecoder.java
Sun Oct 30 11:55:28 2005
@@ -22,6 +22,7 @@
 import org.apache.asn1.codec.stateful.DecoderCallback;
 import org.apache.asn1.codec.stateful.DecoderMonitor;
 import org.apache.asn1.codec.stateful.StatefulDecoder;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.ldap.common.berlib.asn1.decoder.LdapDigesterFactory;
 import org.apache.ldap.common.message.Message;
 import org.apache.ldap.common.message.spi.Provider;
@@ -30,6 +31,8 @@
 
 import java.io.InputStream;
 import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.Hashtable;
 
 
 /**
@@ -41,7 +44,26 @@
 {
     private final Provider provider;
     private final BERDigester digester;
+    private HashSet binaries;
+    private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
 
+    private void initBinaries( Hashtable env ) 
+    {
+        // construct the set for fast lookups while filtering
+        String binaryIds = (String)env.get( BINARY_KEY );
+
+        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] ) )
);
+            }
+        }
+    }
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -53,11 +75,12 @@
      *
      * @param provider the owning provider.
      */
-    public SnickersDecoder( Provider provider )
+    public SnickersDecoder( Provider provider, Hashtable env )
     {
         this.provider = provider;
         LdapDigesterFactory factory = LdapDigesterFactory.getSingleton();
-        digester = factory.create();
+        initBinaries( env );
+        digester = factory.create( binaries );
     }
 
 
@@ -125,7 +148,7 @@
         LdapDigesterFactory factory = LdapDigesterFactory.getSingleton();
 
         // @todo we should probably pool digesters for performance
-        BERDigester digesterTmp = factory.create();
+        BERDigester digesterTmp = factory.create( binaries );
         DigesterCallback dcb = new DigesterCallback();
         digesterTmp.setCallback( dcb );
 



Mime
View raw message