commits@directory.apache.org
[Top] [All Lists]

svn commit: r476881 - in /directory/trunks/shared/ldap/src/main/java/org

Subject: svn commit: r476881 - in /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema: MatchingRuleEnum.java UsageEnum.java
From:
Date: Sun, 19 Nov 2006 18:52:18 -0000
Author: elecharny
Date: Sun Nov 19 10:52:17 2006
New Revision: 476881

URL: http://svn.apache.org/viewvc?view=rev&rev=476881
Log:
Fixed some doco in UsageEnum
Moved MatchingRuleEnum to be an enum (java 5)
MatchingRuleEnum is never used anywhere ...

Modified:
    
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.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/schema/MatchingRuleEnum.java
URL: 
http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java?view=diff&rev=476881&r1=476880&r2=476881
==============================================================================
--- 
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java
 (original)
+++ 
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java
 Sun Nov 19 10:52:17 2006
@@ -19,14 +19,6 @@
  */
 package org.apache.directory.shared.ldap.schema;
 
-
-import java.util.Map;
-import java.util.List;
-
-import org.apache.directory.shared.ldap.util.EnumUtils;
-import org.apache.directory.shared.ldap.util.ValuedEnum;
-
-
 /**
  * Type safe enum for a matching rule's comparator and normalizer component
  * usage string. This can be take one of the following three values:
@@ -37,93 +29,50 @@
  * </ul>
  * 
  * @author <a href="mailto:dev@xxxxxxxxxxxxxxxxxxxx";>Apache Directory 
Project</a>
- * @version $Rev$
  */
-public class MatchingRuleEnum extends ValuedEnum
+public enum MatchingRuleEnum
 {
-    static final long serialVersionUID = 5500272648097676014L;
-
     /** value for ordering usage */
-    public static final int ORDERING_VAL = 0;
+    ORDERING( 0 ),
 
     /** value for equality usage */
-    public static final int EQUALITY_VAL = 1;
+    EQUALITY( 1 ),
 
     /** value for substring usage */
-    public static final int SUBSTRING_VAL = 2;
-
-    /** enum for ordering comparator usage */
-    public static final MatchingRuleEnum ORDERING = new MatchingRuleEnum( 
"ORDERING", ORDERING_VAL );
-
-    /** enum for equality comparator usage */
-    public static final MatchingRuleEnum EQUALITY = new MatchingRuleEnum( 
"EQUALITY", EQUALITY_VAL );
-
-    /** enum for substring comparator usage */
-    public static final MatchingRuleEnum SUBSTRING = new MatchingRuleEnum( 
"SUBSTRING", SUBSTRING_VAL );
-
+    SUBSTRING( 2 );
 
+    /** 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 name
-     *            a string name for the enumeration value.
      * @param value
      *            the integer value of the enumeration.
      */
-    private MatchingRuleEnum(final String name, final int value)
-    {
-        super( name, value );
-    }
-
-
-    /**
-     * Gets the enumeration type for the usage string regardless of case.
-     * 
-     * @param usage
-     *            the usage string
-     * @return the usage enumeration type
-     */
-    public static MatchingRuleEnum getUsage( String usage )
+    private MatchingRuleEnum( int value )
     {
-        if ( usage.equalsIgnoreCase( MatchingRuleEnum.EQUALITY.getName() ) )
-        {
-            return MatchingRuleEnum.EQUALITY;
-        }
-
-        if ( usage.equalsIgnoreCase( MatchingRuleEnum.ORDERING.getName() ) )
-        {
-            return MatchingRuleEnum.ORDERING;
-        }
-
-        if ( usage.equalsIgnoreCase( MatchingRuleEnum.SUBSTRING.getName() ) )
-        {
-            return MatchingRuleEnum.SUBSTRING;
-        }
-
-        throw new IllegalArgumentException( "Unknown matching rule usage 
string" + usage );
+       this.value = value;
     }
 
-
+    
     /**
-     * Gets a List of the enumerations for matching rule usage.
-     * 
-     * @return the List of enumerations possible for matching rule usage
+     * @return The value associated with the current element.
      */
-    public static List list()
+    public int getValue()
     {
-        return EnumUtils.getEnumList( MatchingRuleEnum.class );
+        return value;
     }
 
-
     /**
-     * Gets the Map of MatchingRuleEnum objects by name using the
-     * MatchingRuleEnum class.
+     * Gets the enumeration type for the usage string regardless of case.
      * 
-     * @return the Map by name of MatchingRuleEnums
+     * @param matchingRule the usage string
+     * @return the matchingRule enumeration type
      */
-    public static Map map()
+    public static MatchingRuleEnum getUsage( String matchingRule )
     {
-        return EnumUtils.getEnumMap( MatchingRuleEnum.class );
+        return valueOf( matchingRule );
     }
 }

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=476881&r1=476880&r2=476881
==============================================================================
--- 
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
 Sun Nov 19 10:52:17 2006
@@ -47,29 +47,33 @@
     /** value for attributes with dSAOperation usage */
     DSA_OPERATION( 3 );
 
+    /** Stores the integer value of each element of the enumeration */
     private int value;
 
     /**
      * Private construct so no other instances can be created other than the
      * public static constants in this class.
      * 
-     * @param name
-     *            a string name for the enumeration value.
-     * @param value
-     *            the integer value of the enumeration.
+     * @param value the integer value of the enumeration.
      */
     private UsageEnum( int value )
     {
         this.value = value;
     }
-
+    
+    /**
+     * @return The value associated with the current element.
+     */
+    public int getValue()
+    {
+        return value;
+    }
 
     /**
      * Gets the enumeration type for the attributeType usage string regardless
      * of case.
      * 
-     * @param usage
-     *            the usage string
+     * @param usage the usage string
      * @return the usage enumeration type
      */
     public static UsageEnum getUsage( String usage )
@@ -94,14 +98,5 @@
        {
                return null;
        }
-    }
-    
-    /**
-     * 
-     * @return The value associated with the current element.
-     */
-    public int getValue()
-    {
-       return value;
     }
 }


<Prev in Thread] Current Thread [Next in Thread>
  • svn commit: r476881 - in /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema: MatchingRuleEnum.java UsageEnum.java, elecharny <=