directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1028660 - in /directory: apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ shared/trunk/ldap/src/main/java/org/a...
Date Fri, 29 Oct 2010 09:42:04 GMT
Author: felixk
Date: Fri Oct 29 09:42:04 2010
New Revision: 1028660

URL: http://svn.apache.org/viewvc?rev=1028660&view=rev
Log:
Found some more "TODO: should this be an enum?"

Modified:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/LdapOperation.java

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java?rev=1028660&r1=1028659&r2=1028660&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
Fri Oct 29 09:42:04 2010
@@ -332,7 +332,7 @@ public class PersistentSearchIT extends 
     {
         PersistentSearchControl control = new PersistentSearchControl();
         control.setReturnECs( true );
-        control.setChangeTypes( ChangeType.ADD_VALUE );
+        control.setChangeTypes( ChangeType.ADD.getValue() );
         control.enableNotification( ChangeType.MODIFY );
         setUpListener( true, control, false );
         ctx.createSubcontext( "cn=Jack Black", getPersonAttributes( "Black", "Jack Black"
) );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java?rev=1028660&r1=1028659&r2=1028660&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/ChangeType.java
Fri Oct 29 09:42:04 2010
@@ -37,52 +37,42 @@ import org.apache.directory.shared.i18n.
  *   }
  * </pre>
  * 
- * TODO: should this be an enum?
- * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class ChangeType
+public enum ChangeType
 {
-    public static final int ADD_VALUE = 1;
-
-    public static final int DELETE_VALUE = 2;
-
-    public static final int MODIFY_VALUE = 4;
-
-    public static final int MODDN_VALUE = 8;
+    ADD(1),
 
-    public static final ChangeType ADD = new ChangeType( "ADD", ADD_VALUE );
+    DELETE(2),
 
-    public static final ChangeType DELETE = new ChangeType( "DELETE", DELETE_VALUE );
+    MODIFY(4),
 
-    public static final ChangeType MODIFY = new ChangeType( "MODIFY", MODIFY_VALUE );
+    MODDN(8);
 
-    public static final ChangeType MODDN = new ChangeType( "MODDN", MODDN_VALUE );
-    
-    private final String label;
+    private int value;
 
-    private final int value;
 
-
-    private ChangeType(String label, int value)
+    /**
+     * 
+     * Creates a new instance of ChangeType.
+     *
+     * @param value
+     */
+    private ChangeType(int value)
     {
-        this.label = label;
         this.value = value;
     }
 
 
+    /**
+     * @return The int value of the ChangeType
+     */
     public int getValue()
     {
         return value;
     }
 
 
-    public String toString()
-    {
-        return label;
-    }
-
-
     /**
      * Gets the changeType enumeration type for an integer value.
      * 
@@ -94,13 +84,13 @@ public final class ChangeType
     {
         switch ( value )
         {
-            case ( ADD_VALUE ):
+            case ( 1 ):
                 return ADD;
-            case ( DELETE_VALUE ):
+            case ( 2 ):
                 return DELETE;
-            case ( MODIFY_VALUE ):
+            case ( 4 ):
                 return MODIFY;
-            case ( MODDN_VALUE ):
+            case ( 8 ):
                 return MODDN;
             default:
                 throw new IllegalArgumentException( I18n.err( I18n.ERR_04055, value ) );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java?rev=1028660&r1=1028659&r2=1028660&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/entryChange/EntryChangeControlGrammar.java
Fri Oct 29 09:42:04 2010
@@ -103,13 +103,13 @@ public final class EntryChangeControlGra
                 try
                 {
                     int change = IntegerDecoder.parse( value, 1, 8 );
-
-                    switch ( change )
+                    
+                    switch ( ChangeType.getChangeType( change ) )
                     {
-                        case ChangeType.ADD_VALUE:
-                        case ChangeType.DELETE_VALUE:
-                        case ChangeType.MODDN_VALUE:
-                        case ChangeType.MODIFY_VALUE:
+                        case ADD:
+                        case DELETE:
+                        case MODDN:
+                        case MODIFY:
                             ChangeType changeType = ChangeType.getChangeType( change );
 
                             if ( IS_DEBUG )
@@ -135,6 +135,10 @@ public final class EntryChangeControlGra
                     LOG.error( msg, e );
                     throw new DecoderException( msg );
                 }
+                catch ( IllegalArgumentException e )
+                {
+                    throw new DecoderException( e.getLocalizedMessage() );
+                }
             }
         } );
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/LdapOperation.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/LdapOperation.java?rev=1028660&r1=1028659&r2=1028660&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/LdapOperation.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/LdapOperation.java
Fri Oct 29 09:42:04 2010
@@ -24,38 +24,42 @@ package org.apache.directory.shared.ldap
 /**
  * An enumeration that represents change inducing LDAP operations.
  * 
- * TODO: should this be an enum?
- * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class LdapOperation
+public enum LdapOperation
 {
-    public static final LdapOperation MODIFY = new LdapOperation( "Modify" );
+    MODIFY( "Modify" ),
 
-    public static final LdapOperation ADD = new LdapOperation( "Add" );
+    ADD( "Add" ),
 
-    public static final LdapOperation DELETE = new LdapOperation( "Delete" );
+    DELETE( "Delete" ),
 
-    public static final LdapOperation MODIFYDN = new LdapOperation( "ModifyDN" );
+    MODIFYDN( "ModifyDN" ),
     
-    public static final LdapOperation MODIFYDN_RENAME = new LdapOperation( "ModifyDN.Rename"
);
+    MODIFYDN_RENAME( "ModifyDN.Rename" ),
     
-    public static final LdapOperation MODIFYDN_EXPORT = new LdapOperation( "ModifyDN.Export"
);
+    MODIFYDN_EXPORT( "ModifyDN.Export" ),
     
-    public static final LdapOperation MODIFYDN_IMPORT = new LdapOperation( "ModifyDN.Import"
);
+    MODIFYDN_IMPORT( "ModifyDN.Import" );
 
     
     private final String name;
 
 
-    private LdapOperation( String name )
+    /**
+     * 
+     * Creates a new instance of LdapOperation.
+     *
+     * @param name
+     */
+    LdapOperation( String name )
     {
         this.name = name;
     }
 
 
     /**
-     * Returns the name of this LDAP operation.
+     * @return the name of this LDAP operation
      */
     public String getName()
     {
@@ -67,53 +71,4 @@ public final class LdapOperation
     {
         return name;
     }
-
-
-    /**
-     * @see java.lang.Object#hashCode()
-     * @return the instance's hash code 
-     */
-    public int hashCode()
-    {
-        int h = 37;
-
-        h = h*17 + ( ( name == null ) ? 0 : name.hashCode() );
-        
-        return h;
-    }
-
-
-    /**
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-        {
-            return true;
-        }
-        
-        if ( ! ( obj  instanceof LdapOperation ) )
-        {
-            return false;
-        }
-
-        final LdapOperation other = ( LdapOperation ) obj;
-
-        if ( name == null )
-        {
-            if ( other.name != null )
-            {
-                return false;
-            }
-            else
-            { 
-                return true;
-            }
-        }
-        else 
-        {
-            return name.equals( other.name );
-        }
-    }
 }



Mime
View raw message