directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 30808 - in incubator/directory/ldap/trunk/common: . src/java/org/apache/ldap/common/message
Date Wed, 28 Jul 2004 01:15:35 GMT
Author: akarasulu
Date: Tue Jul 27 18:15:34 2004
New Revision: 30808

Modified:
   incubator/directory/ldap/trunk/common/   (props changed)
   incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/ScopeEnum.java
Log:
Added getLdapValue() to compliment the enumeration's getValue().  This is
to differentiate between LDAP scope constants (ENUMERATION values) and JNDI
scope constants taken from the javax.naming.directory.DirContext class.


Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/ScopeEnum.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/ScopeEnum.java
(original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/message/ScopeEnum.java
Tue Jul 27 18:15:34 2004
@@ -14,74 +14,107 @@
  *   limitations under the License.
  *
  */
-package org.apache.ldap.common.message ;
-
-
-import javax.naming.directory.SearchControls ;
-
-
-/**
- * Type-safe scope parameter enumeration.
- * 
- * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
- * @author $Author: akarasulu $
- * @version $Revision: 1.4 $
- */
-public class ScopeEnum
-    extends org.apache.commons.lang.enum.ValuedEnum
-{
-    /** Search scope parameter value for base object search */
-    public static final int BASEOBJECT_VAL = SearchControls.OBJECT_SCOPE ;
-    /** Search scope parameter value for single level search */
-    public static final int SINGLELEVEL_VAL = SearchControls.ONELEVEL_SCOPE ;
-    /** Search scope parameter value for whole subtree level search */
-    public static final int WHOLESUBTREE_VAL = SearchControls.SUBTREE_SCOPE ;
-
-    /** Search scope parameter enum for base object search */
-    public static final ScopeEnum BASEOBJECT = 
-        new ScopeEnum( "BASEOBJECT", BASEOBJECT_VAL ) ;
-    /** Search scope parameter enum for single level search */
-    public static final ScopeEnum SINGLELEVEL =
-        new ScopeEnum( "SINGLELEVEL", SINGLELEVEL_VAL ) ;
-    /** Search scope parameter enum for whole subtree level search */
-    public static final ScopeEnum WHOLESUBTREE =
-        new ScopeEnum( "WHOLESUBTREE", WHOLESUBTREE_VAL ) ;
-
-
-    /**
-     * Private construct so no other instances can be created other than the
-     * public static constants in this class.
-     *
-     * @param a_name a string name for the enumeration value.
-     * @param a_value the integer value of the enumeration.
-     */
-    private ScopeEnum( final String a_name, final int a_value )
-    {
-        super( a_name, a_value ) ;
-    }
-    
-    
-    /**
-     * Gets the type safe enumeration constant corresponding to a SearchControls
-     * scope value.
-     * 
-     * @param a_controls the SearchControls whose scope value we convert to enum
-     * @return the SopeEnum for the scope int value
-     */
-    public static ScopeEnum getScope( SearchControls a_controls )
-    {
-        switch( a_controls.getSearchScope() )
-        {
-            case( SearchControls.OBJECT_SCOPE ):
-                return BASEOBJECT ; 
-            case( SearchControls.ONELEVEL_SCOPE ):
-                return SINGLELEVEL ; 
-            case( SearchControls.SUBTREE_SCOPE ):
-                return WHOLESUBTREE ; 
-            default:
-                throw new IllegalArgumentException( 
-                    "Unrecognized search scope in SearchControls: " 
-                    + a_controls.getSearchScope() ) ;
-        }
-    }
-}
+package org.apache.ldap.common.message ;
+
+
+import javax.naming.directory.SearchControls ;
+
+
+/**
+ * Type-safe scope parameter enumeration.
+ * 
+ * @author <a href="mailto:aok123@bellsouth.net">Alex Karasulu</a>
+ * @author $Author: akarasulu $
+ * @version $Revision: 1.4 $
+ */
+public class ScopeEnum
+    extends org.apache.commons.lang.enum.ValuedEnum
+{
+    /** Search scope parameter value for base object search */
+    public static final int BASEOBJECT_VAL = SearchControls.OBJECT_SCOPE ;
+    /** Search scope parameter value for single level search */
+    public static final int SINGLELEVEL_VAL = SearchControls.ONELEVEL_SCOPE ;
+    /** Search scope parameter value for whole subtree level search */
+    public static final int WHOLESUBTREE_VAL = SearchControls.SUBTREE_SCOPE ;
+
+
+    /** LDAP search scope parameter value for base object search */
+    public static final int BASEOBJECT_LDAPVAL = 0 ;
+    /** LDAP search scope parameter value for single level search */
+    public static final int SINGLELEVEL_LDAPVAL = 1 ;
+    /** LDAP search scope parameter value for whole subtree level search */
+    public static final int WHOLESUBTREE_LDAPVAL = 2 ;
+
+
+    /** Search scope parameter enum for base object search */
+    public static final ScopeEnum BASEOBJECT = 
+        new ScopeEnum( "BASEOBJECT", BASEOBJECT_VAL ) ;
+    /** Search scope parameter enum for single level search */
+    public static final ScopeEnum SINGLELEVEL =
+        new ScopeEnum( "SINGLELEVEL", SINGLELEVEL_VAL ) ;
+    /** Search scope parameter enum for whole subtree level search */
+    public static final ScopeEnum WHOLESUBTREE =
+        new ScopeEnum( "WHOLESUBTREE", WHOLESUBTREE_VAL ) ;
+
+
+    /**
+     * Private construct so no other instances can be created other than the
+     * public static constants in this class.
+     *
+     * @param a_name a string name for the enumeration value.
+     * @param a_value the integer value of the enumeration.
+     */
+    private ScopeEnum( final String a_name, final int a_value )
+    {
+        super( a_name, a_value ) ;
+    }
+    
+    
+    /**
+     * Gets the type safe enumeration constant corresponding to a SearchControls
+     * scope value.
+     * 
+     * @param a_controls the SearchControls whose scope value we convert to enum
+     * @return the SopeEnum for the scope int value
+     */
+    public static ScopeEnum getScope( SearchControls a_controls )
+    {
+        switch( a_controls.getSearchScope() )
+        {
+            case( SearchControls.OBJECT_SCOPE ):
+                return BASEOBJECT ; 
+            case( SearchControls.ONELEVEL_SCOPE ):
+                return SINGLELEVEL ; 
+            case( SearchControls.SUBTREE_SCOPE ):
+                return WHOLESUBTREE ; 
+            default:
+                throw new IllegalArgumentException( 
+                    "Unrecognized search scope in SearchControls: " 
+                    + a_controls.getSearchScope() ) ;
+        }
+    }
+
+
+    /**
+     * Gets the LdapValue for the scope enumeration as opposed to the JNDI value
+     * which is returned using getValue().
+     *
+     * @return the LDAP enumeration value for the scope parameter on a search
+     * request.
+     */ 
+    public int getLdapValue()
+    {
+        switch( getValue() )
+        {
+            case( BASEOBJECT_VAL ):
+                return BASEOBJECT_LDAPVAL;
+            case( SINGLELEVEL_VAL ):
+                return SINGLELEVEL_LDAPVAL;
+            case( WHOLESUBTREE_VAL ):
+                return WHOLESUBTREE_LDAPVAL;
+            default:
+                throw new IllegalArgumentException( "Unrecognized value: "
+                    + getValue() );
+        }
+    }
+}

Mime
View raw message