directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1067695 - /directory/studio/branches/m1/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java
Date Sun, 06 Feb 2011 16:22:20 GMT
Author: akarasulu
Date: Sun Feb  6 16:22:20 2011
New Revision: 1067695

URL: http://svn.apache.org/viewvc?rev=1067695&view=rev
Log:
using more efficient switch statement instead of if else blocks

Modified:
    directory/studio/branches/m1/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java

Modified: directory/studio/branches/m1/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/m1/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java?rev=1067695&r1=1067694&r2=1067695&view=diff
==============================================================================
--- directory/studio/branches/m1/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java
(original)
+++ directory/studio/branches/m1/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ImportDsmlRunnable.java
Sun Feb  6 16:22:20 2011
@@ -39,6 +39,7 @@ import javax.naming.ldap.Control;
 import org.apache.commons.codec.digest.DigestUtils;
 
 import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.dsmlv2.DsmlDecorator;
 import org.apache.directory.shared.dsmlv2.Dsmlv2Parser;
 import org.apache.directory.shared.dsmlv2.reponse.AddResponseDsml;
 import org.apache.directory.shared.dsmlv2.reponse.BatchResponseDsml;
@@ -197,9 +198,6 @@ public class ImportDsmlRunnable implemen
             parser.parseAllRequests();
 
             // Getting the batch request
-            
-            // @TODO - fix next Alex
-            
             BatchRequestDsml batchRequest = parser.getBatchRequest();
 
             // Creating a DSML batch response (only if needed)
@@ -217,8 +215,8 @@ public class ImportDsmlRunnable implemen
             StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
 
             // Processing each request
-            List<?> requests = batchRequest.getRequests();
-            for ( Object request : requests )
+            List<DsmlDecorator<? extends Request>> requests = batchRequest.getRequests();
+            for ( DsmlDecorator<? extends Request> request : requests )
             {
                 // Processing the request
                 processRequest( request, batchResponseDsml, dummyMonitor );
@@ -279,40 +277,39 @@ public class ImportDsmlRunnable implemen
      * @throws org.apache.directory.shared.ldap.model.exception.LdapURLEncodingException
      * @throws LdapException
      */
-    private void processRequest( Object request, BatchResponseDsml batchResponseDsml, StudioProgressMonitor
monitor )
+    private void processRequest( DsmlDecorator<? extends Request> request, BatchResponseDsml
batchResponseDsml, StudioProgressMonitor monitor )
         throws NamingException, LdapURLEncodingException, LdapException
     {
-        if ( request instanceof BindRequest)
+        switch( request.getDecorated().getType() )
         {
-            processBindRequest( ( BindRequest ) request, batchResponseDsml, monitor );
-        }
-        else if ( request instanceof AddRequest )
-        {
-            processAddRequest( (AddRequest) request, batchResponseDsml, monitor );
-        }
-        else if ( request instanceof CompareRequest )
-        {
-            processCompareRequest( ( CompareRequest ) request, batchResponseDsml, monitor
);
-        }
-        else if ( request instanceof DeleteRequest )
-        {
-            processDelRequest( ( DeleteRequest ) request, batchResponseDsml, monitor );
-        }
-        else if ( request instanceof ExtendedRequest )
-        {
-            processExtendedRequest( ( ExtendedRequest ) request, batchResponseDsml, monitor
);
-        }
-        else if ( request instanceof ModifyRequest )
-        {
-            processModifyRequest( ( ModifyRequest ) request, batchResponseDsml, monitor );
-        }
-        else if ( request instanceof ModifyDnRequest )
-        {
-            processModifyDNRequest( ( ModifyDnRequest ) request, batchResponseDsml, monitor
);
-        }
-        else if ( request instanceof SearchRequest )
-        {
-            processSearchRequest( ( SearchRequest ) request, batchResponseDsml, monitor );
+            case BIND_REQUEST:
+                processBindRequest( ( BindRequest ) request, batchResponseDsml, monitor );
+                break;
+            case ADD_REQUEST:
+                processAddRequest( (AddRequest) request, batchResponseDsml, monitor );
+                break;
+            case COMPARE_REQUEST:
+                processCompareRequest( ( CompareRequest ) request, batchResponseDsml, monitor
);
+                break;
+            case DEL_REQUEST:
+                processDelRequest( ( DeleteRequest ) request, batchResponseDsml, monitor
);
+                break;
+            case EXTENDED_REQUEST:
+                processExtendedRequest( ( ExtendedRequest ) request, batchResponseDsml, monitor
);
+                break;
+            case MODIFY_REQUEST:
+                processModifyRequest( ( ModifyRequest ) request, batchResponseDsml, monitor
);
+                break;
+            case MODIFYDN_REQUEST:
+                processModifyDNRequest( ( ModifyDnRequest ) request, batchResponseDsml, monitor
);
+                break;
+            case SEARCH_REQUEST:
+                processSearchRequest( ( SearchRequest ) request, batchResponseDsml, monitor
);
+                break;
+            default:
+                throw new IllegalArgumentException( 
+                    "Should not be encountering a request type of: " 
+                    + request.getDecorated().getType() );
         }
     }
 



Mime
View raw message