directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r760830 - /directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/
Date Wed, 01 Apr 2009 09:50:52 GMT
Author: elecharny
Date: Wed Apr  1 09:50:48 2009
New Revision: 760830

URL: http://svn.apache.org/viewvc?rev=760830&view=rev
Log:
o Using varargs for Controls
o Returning the object for setters, to allow chaining

Modified:
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java

Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.java?rev=760830&r1=760829&r2=760830&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequest.java
Wed Apr  1 09:50:48 2009
@@ -38,6 +38,7 @@
      * Set the abandoned message ID
      * 
      * @param abandonedMessageId The abandoned messageID to set.
+     * @return The object itself, to allow chaining
      */
-    void setAbandonedMessageId( int abandonedMessageId );
+    AbandonRequest setAbandonedMessageId( int abandonedMessageId );
 }

Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java?rev=760830&r1=760829&r2=760830&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbandonRequestImpl.java
Wed Apr  1 09:50:48 2009
@@ -53,8 +53,10 @@
      * 
      * @param abandonedMessageId The abandoned messageID to set.
      */
-    public void setAbandonedMessageId( int abandonedMessageId )
+    public AbandonRequest setAbandonedMessageId( int abandonedMessageId )
     {
         this.abandonedMessageId = abandonedMessageId;
+        
+        return this;
     }
 }

Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.java?rev=760830&r1=760829&r2=760830&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/AbstractRequest.java
Wed Apr  1 09:50:48 2009
@@ -44,31 +44,22 @@
     /**
      * {@inheritDoc}
      */
-    public void add( Control control ) throws MessageException
+    public Message add( Control... controls ) throws MessageException
     {
-        if ( controls == null )
-        {
-            controls = new HashMap<String, Control>();
-        }
-        
-        controls.put( control.getID(), control );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void addAll( Control[] controls ) throws MessageException
-    {
-        if ( controls == null )
+        if ( this.controls == null )
         {
             this.controls = new HashMap<String, Control>();
         }
         
-        for ( Control control:controls )
+        if ( controls != null )
         {
-            this.controls.put( control.getID(), control );
+            for ( Control control:controls )
+            {
+                this.controls.put( control.getID(), control );
+            }
         }
+        
+        return this;
     }
 
 
@@ -102,20 +93,33 @@
     /**
      * {@inheritDoc}
      */
-    public void remove( Control control ) throws MessageException
+    public Message remove( Control... controls ) throws MessageException
     {
+        if ( this.controls == null )
+        {
+            // We don't have any controls, so we can just exit
+            return this;
+        }
+        
         if ( controls != null )
         {
-            controls.remove( control.getID() );
+            for ( Control ctrl:controls )
+            {
+                this.controls.remove( ctrl.getID() );
+            }
         }
+        
+        return this;
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void setTimeout( long timeout )
+    public Message setTimeout( long timeout )
     {
         this.timeout = timeout;
+        
+        return this;
     }
 }

Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java?rev=760830&r1=760829&r2=760830&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
Wed Apr  1 09:50:48 2009
@@ -38,8 +38,9 @@
 
     /**
      * Sets the authentication mechanism to SASL
+     * @return The object itself, to allow chaining
      */
-    void setSasl();
+    BindRequest setSasl();
 
 
     /**
@@ -55,10 +56,10 @@
      * Sets the simple credentials associated with a simple authentication
      * attempt ignored if this request uses SASL authentication mechanisms.
      * 
-     * @param credentials
-     *            the credentials if authentication is simple, null otherwise
+     * @param credentials the credentials if authentication is simple, null otherwise
+     * @return The object itself, to allow chaining
      */
-    void setCredentials( byte[] credentials );
+    BindRequest setCredentials( byte[] credentials );
 
 
     /**
@@ -82,8 +83,9 @@
      * 
      * @param name the DN of the authenticating user - leave null for annonymous
      * user.
+     * @return The object itself, to allow chaining
      */
-    void setName( String name );
+    BindRequest setName( String name );
 
 
     /**
@@ -124,8 +126,9 @@
      * then we shall convert the return type to a type safe enumeration.
      * 
      * @param version The version. Should be 3 or 2
+     * @return The object itself, to allow chaining
      */
-    void setVersion( int version );
+    BindRequest setVersion( int version );
 
 
     /**
@@ -141,8 +144,8 @@
      * Sets the SASL mechanism String associated with this BindRequest if the
      * bind operation is using SASL.
      * 
-     * @param saslMechanism
-     *            the SASL mechanism
+     * @param saslMechanism the SASL mechanism
+     * @return The object itself, to allow chaining
      */
-    void setSaslMechanism( String saslMechanism );
+    BindRequest setSaslMechanism( String saslMechanism );
 }

Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java?rev=760830&r1=760829&r2=760830&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java
Wed Apr  1 09:50:48 2009
@@ -67,89 +67,99 @@
     /**
      * {@inheritDoc}
      */
-    public String getName()
+    public BindRequest setCredentials( byte[] credentials )
     {
-        return name;
+        this.credentials = credentials;
+        
+        return this;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public String getSaslMechanism()
+    public String getName()
     {
-        return saslMechanism;
+        return name;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public int getVersion()
+    public BindRequest setName( String name )
     {
-        return version;
+        this.name = name;
+        
+        return this;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public boolean isSimple()
+    public String getSaslMechanism()
     {
-        return isSimple;
+        return saslMechanism;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public boolean isVersion3()
+    public BindRequest setSaslMechanism( String saslMechanism )
     {
-        return version == 3;
+        this.saslMechanism = saslMechanism;
+        
+        return this;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public void setCredentials( byte[] credentials )
+    public int getVersion()
     {
-        this.credentials = credentials;
+        return version;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public void setName( String name )
+    public BindRequest setVersion( int version )
     {
-        this.name = name;
+        this.version = version;
+        
+        return this;
     }
-    
 
+    
     /**
      * {@inheritDoc}
      */
-    public void setSasl()
+    public boolean isSimple()
     {
-        isSimple = false;
+        return isSimple;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public void setSaslMechanism( String saslMechanism )
+    public boolean isVersion3()
     {
-        this.saslMechanism = saslMechanism;
+        return version == 3;
     }
-
     
+
     /**
      * {@inheritDoc}
      */
-    public void setVersion( int version )
+    public BindRequest setSasl()
     {
-        this.version = version;
+        isSimple = false;
+        
+        return this;
     }
 }

Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java?rev=760830&r1=760829&r2=760830&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/Message.java
Wed Apr  1 09:50:48 2009
@@ -49,7 +49,7 @@
      *
      * @param timeout The new timeout, expressed in milliseconds
      */
-    void setTimeout( long timeout );
+    Message setTimeout( long timeout );
     
     
     /**
@@ -79,16 +79,7 @@
      *             if controls cannot be added to this Message or the control is
      *             not known etc.
      */
-    void add( Control control ) throws MessageException;
-
-
-    /**
-     * Adds an array of controls to this Message.
-     * 
-     * @param controls the controls to add.
-     * @throws MessageException if controls cannot be added to this Message or they are not
known etc.
-     */
-    void addAll( Control[] controls ) throws MessageException;
+    Message add( Control... control ) throws MessageException;
 
 
     /**
@@ -99,5 +90,5 @@
      *             if controls cannot be added to this Message or the control is
      *             not known etc.
      */
-    void remove( Control control ) throws MessageException;
+    Message remove( Control... control ) throws MessageException;
 }



Mime
View raw message