directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r477192 - in /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap: codec/TwixTransformer.java message/DerefAliasesEnum.java schema/ObjectClassTypeEnum.java schema/UsageEnum.java
Date Mon, 20 Nov 2006 14:31:47 GMT
Author: elecharny
Date: Mon Nov 20 06:31:46 2006
New Revision: 477192

URL: http://svn.apache.org/viewvc?view=rev&rev=477192
Log:
Changed the DerefAliasTypeEnum to become an enum instead of an subclass
of ValuedEnum (Java 5 migration)
Fixed the velocity templates to fix some bug related to enum switch

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/DerefAliasesEnum.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=477192&r1=477191&r2=477192
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
Mon Nov 20 06:31:46 2006
@@ -604,19 +604,19 @@
         switch ( searchRequest.getDerefAliases() )
         {
             case LdapConstants.DEREF_ALWAYS:
-                snickersMessage.setDerefAliases( DerefAliasesEnum.DEREFALWAYS );
+                snickersMessage.setDerefAliases( DerefAliasesEnum.DEREF_ALWAYS );
                 break;
 
             case LdapConstants.DEREF_FINDING_BASE_OBJ:
-                snickersMessage.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+                snickersMessage.setDerefAliases( DerefAliasesEnum.DEREF_FINDING_BASE_OBJ
);
                 break;
 
             case LdapConstants.DEREF_IN_SEARCHING:
-                snickersMessage.setDerefAliases( DerefAliasesEnum.DEREFINSEARCHING );
+                snickersMessage.setDerefAliases( DerefAliasesEnum.DEREF_IN_SEARCHING );
                 break;
 
             case LdapConstants.NEVER_DEREF_ALIASES:
-                snickersMessage.setDerefAliases( DerefAliasesEnum.NEVERDEREFALIASES );
+                snickersMessage.setDerefAliases( DerefAliasesEnum.NEVER_DEREF_ALIASES );
                 break;
         }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/DerefAliasesEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/DerefAliasesEnum.java?view=diff&rev=477192&r1=477191&r2=477192
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/DerefAliasesEnum.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/DerefAliasesEnum.java
Mon Nov 20 06:31:46 2006
@@ -22,8 +22,6 @@
 
 import java.util.Map;
 
-import org.apache.directory.shared.ldap.util.ValuedEnum;
-
 
 /**
  * Type-safe derefAliases search parameter enumeration which determines the mode
@@ -33,108 +31,126 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Revision$
  */
-public class DerefAliasesEnum extends ValuedEnum
+public enum DerefAliasesEnum
 {
-    static final long serialVersionUID = 1501231261415745531L;
-
-    /** java.naming.ldap.derefAliases JNDI property */
-    public static final String JNDI_PROP = "java.naming.ldap.derefAliases";
-
-    /** Alias handling mode name that treats aliases like entries */
-    public static final String NEVERDEREFALIASES_NAME = "never";
-
-    /** Alias handling mode name that dereferences only when searching */
-    public static final String DEREFINSEARCHING_NAME = "searching";
-
-    /** Alias handling mode name that dereferences only in finding the base */
-    public static final String DEREFFINDINGBASEOBJ_NAME = "finding";
-
-    /** Alias handling mode name that dereferences always */
-    public static final String DEREFALWAYS_NAME = "always";
-
     /** Alias handling mode value that treats aliases like entries */
-    public static final int NEVERDEREFALIASES_VAL = 0;
+    NEVER_DEREF_ALIASES(0),
 
     /** Alias handling mode value that dereferences only when searching */
-    public static final int DEREFINSEARCHING_VAL = 1;
+    DEREF_IN_SEARCHING(1),
 
     /** Alias handling mode value that dereferences only in finding the base */
-    public static final int DEREFFINDINGBASEOBJ_VAL = 2;
+    DEREF_FINDING_BASE_OBJ(2),
 
     /** Alias handling mode value that dereferences always */
-    public static final int DEREFALWAYS_VAL = 3;
+    DEREF_ALWAYS(3);
 
-    /** Alias handling mode that treats aliases like entries */
-    public static final DerefAliasesEnum NEVERDEREFALIASES = new DerefAliasesEnum( NEVERDEREFALIASES_NAME,
-        NEVERDEREFALIASES_VAL );
 
-    /** Alias handling mode that dereferences only when searching */
-    public static final DerefAliasesEnum DEREFINSEARCHING = new DerefAliasesEnum( DEREFINSEARCHING_NAME,
-        DEREFINSEARCHING_VAL );
+    /** Stores the integer value of each element of the enumeration */
+    private int value;
+    
+    /**
+     * Private constructor so no other instances can be created other than the
+     * public static constants in this class.
+     * 
+     * @param value the integer value of the enumeration.
+     */
+    private DerefAliasesEnum( int value )
+    {
+       this.value = value;
+    }
 
-    /** Alias handling mode that dereferences only in finding the base */
-    public static final DerefAliasesEnum DEREFFINDINGBASEOBJ = new DerefAliasesEnum( DEREFFINDINGBASEOBJ_NAME,
-        DEREFFINDINGBASEOBJ_VAL );
+    
+    /**
+     * @return The value associated with the current element.
+     */
+    public int getValue()
+    {
+        return value;
+    }
+
+    /** java.naming.ldap.derefAliases JNDI property */
+    public static final String JNDI_DEREF_ALIAS_PROP = "java.naming.ldap.derefAliases";
+
+    /** Alias handling mode name that treats aliases like entries */
+    public static final String NEVER_DEREF_ALIASES_NAME = "never";
+
+    /** Alias handling mode name that dereferences only when searching */
+    public static final String DEREF_IN_SEARCHING_NAME = "searching";
 
-    /** Alias handling mode that dereferences always */
-    public static final DerefAliasesEnum DEREFALWAYS = new DerefAliasesEnum( DEREFALWAYS_NAME,
DEREFALWAYS_VAL );
+    /** Alias handling mode name that dereferences only in finding the base */
+    public static final String DEREF_FINDING_BASE_OBJ_NAME = "finding";
 
+    /** Alias handling mode name that dereferences always */
+    public static final String DEREF_ALWAYS_NAME = "always";
 
     /**
-     * Private construct so no other instances can be created other than the
-     * public static constants in this class.
+     * Gets the enumeration from by extracting the value for the JNDI LDAP
+     * specific environment property, java.naming.ldap.derefAliases, from the
+     * environment.
      * 
-     * @param a_name
-     *            a string name for the enumeration value.
-     * @param a_value
-     *            the integer value of the enumeration.
+     * @param env
+     *            the JNDI environment with a potential value for the
+     *            java.naming.ldap.derefAliases property
+     * @return the enumeration for the environment
      */
-    private DerefAliasesEnum(final String a_name, final int a_value)
+    public static DerefAliasesEnum getEnum( Map env )
     {
-        super( a_name, a_value );
+        String property = ( String ) env.get( JNDI_DEREF_ALIAS_PROP );
+        
+        if ( null == property )
+        {
+            return DEREF_ALWAYS;
+        }
+        
+        DerefAliasesEnum result = valueOf( property );
+        return ( result == null ? DEREF_ALWAYS : result );
     }
-
-
+    
     /**
      * Checks to see if we dereference while searching and finding the base.
      * 
-     * @return true if value is DEREFALWAYS_VAL, false otherwise
+     * @return true if value is DEREF_ALWAYS, false otherwise
      */
-    public boolean derefAlways()
+    public boolean isDerefAlways()
     {
-        return getValue() == DEREFALWAYS_VAL;
+        return this == DEREF_ALWAYS;
     }
 
 
     /**
      * Checks to see if we never dereference aliases.
      * 
-     * @return true if value is NEVERDEREFALIASES_VAL, false otherwise
+     * @return true if value is NEVER_DEREF_ALIASES, false otherwise
      */
-    public boolean neverDeref()
+    public boolean isNeverDeref()
     {
-        return getValue() == NEVERDEREFALIASES_VAL;
+        return this == NEVER_DEREF_ALIASES;
     }
 
 
     /**
      * Checks to see if we dereference while searching.
      * 
-     * @return true if value is DEREFALWAYS_VAL, or DEREFINSEARCHING_VAL, and
+     * @return true if value is DEREF_ALWAYS_VAL, or DEREF_IN_SEARCHING, and
      *         false otherwise.
      */
-    public boolean derefInSearching()
+    public boolean isDerefInSearching()
     {
-        switch ( getValue() )
+        switch ( this )
         {
-            case ( DEREFALWAYS_VAL ):
+            case DEREF_ALWAYS :
                 return true;
-            case ( DEREFFINDINGBASEOBJ_VAL ):
+            
+            case DEREF_FINDING_BASE_OBJ :
                 return false;
-            case ( DEREFINSEARCHING_VAL ):
+            
+            case DEREF_IN_SEARCHING :
                 return true;
-            case ( NEVERDEREFALIASES_VAL ):
+            
+            case NEVER_DEREF_ALIASES :
                 return false;
+            
             default:
                 throw new IllegalArgumentException( "Class has bug: check for valid enumeration
values" );
         }
@@ -144,71 +160,27 @@
     /**
      * Checks to see if we dereference while finding the base.
      * 
-     * @return true if value is DEREFALWAYS_VAL, or DEREFFINDINGBASEOBJ_VAL, and
+     * @return true if value is DEREF_ALWAYS, or DEREF_FINDING_BASE_OBJ, and
      *         false otherwise.
      */
-    public boolean derefFindingBase()
+    public boolean isDerefFindingBase()
     {
-        switch ( getValue() )
+        switch ( this )
         {
-            case ( DEREFALWAYS_VAL ):
+            case DEREF_ALWAYS :
                 return true;
-            case ( DEREFFINDINGBASEOBJ_VAL ):
+            
+            case DEREF_FINDING_BASE_OBJ :
                 return true;
-            case ( DEREFINSEARCHING_VAL ):
+            
+            case DEREF_IN_SEARCHING :
                 return false;
-            case ( NEVERDEREFALIASES_VAL ):
+            
+            case NEVER_DEREF_ALIASES :
                 return false;
+            
             default:
                 throw new IllegalArgumentException( "Class has bug: check for valid enumeration
values" );
         }
-    }
-
-
-    /**
-     * Gets the enumeration for a enumeration name which also happens to be the
-     * value of the java.naming.ldap.derefAliases LDAP proovider property.
-     * 
-     * @param a_name
-     *            the value for the java.naming.ldap.derefAliases or a name of
-     *            an enum value.
-     * @return the enumeration for a name
-     */
-    public static DerefAliasesEnum getEnum( String a_name )
-    {
-        if ( null == a_name || a_name.equalsIgnoreCase( DEREFALWAYS_NAME ) )
-        {
-            return DEREFALWAYS;
-        }
-        else if ( a_name.equalsIgnoreCase( DEREFFINDINGBASEOBJ_NAME ) )
-        {
-            return DEREFFINDINGBASEOBJ;
-        }
-        else if ( a_name.equalsIgnoreCase( DEREFINSEARCHING_NAME ) )
-        {
-            return DEREFINSEARCHING;
-        }
-        else if ( a_name.equalsIgnoreCase( NEVERDEREFALIASES_NAME ) )
-        {
-            return NEVERDEREFALIASES;
-        }
-
-        throw new IllegalArgumentException( "Unrecognized JNDI environment property " + JNDI_PROP
+ " value: " + a_name );
-    }
-
-
-    /**
-     * Gets the enumeration from by extracting the value for the JNDI LDAP
-     * specific environment property, java.naming.ldap.derefAliases, from the
-     * environment.
-     * 
-     * @param env
-     *            the JNDI environment with a potential value for the
-     *            java.naming.ldap.derefAliases property
-     * @return the enumeration for the environment
-     */
-    public static DerefAliasesEnum getEnum( Map env )
-    {
-        return getEnum( ( String ) env.get( JNDI_PROP ) );
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java?view=diff&rev=477192&r1=477191&r2=477192
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
Mon Nov 20 06:31:46 2006
@@ -42,6 +42,15 @@
     /** The enumeration constant value for the structural objectClasses */
     STRUCTURAL( 2 );
 
+    /** The int constant value for the abstract objectClasses */
+    public static final int ABSTRACT_VAL = 0;
+
+    /** The int constant value for the auxillary objectClasses */
+    public static final int AUXILIARY_VAL = 1;
+
+    /** The int constant value for the structural objectClasses */
+    public static final int STRUCTURAL_VAL=2;
+    
     /** Stores the integer value of each element of the enumeration */
     private int value;
     

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java?view=diff&rev=477192&r1=477191&r2=477192
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
Mon Nov 20 06:31:46 2006
@@ -78,6 +78,13 @@
      */
     public static UsageEnum getUsage( String usage )
     {
+        UsageEnum result = valueOf( usage );
+        
+        if ( result != null )
+        {
+            return result;
+        }
+        
     	if ( "directoryOperation".equals( usage ) )
     	{
     		return DIRECTORY_OPERATION;



Mime
View raw message