directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r477604 - /directory/trunks/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
Date Tue, 21 Nov 2006 10:17:35 GMT
Author: elecharny
Date: Tue Nov 21 02:17:34 2006
New Revision: 477604

URL: http://svn.apache.org/viewvc?view=rev&rev=477604
Log:
Changed the ProducerTypeEnum to become an enum instead of an subclass
of ValuedEnum (Java 5 migration)

Modified:
    directory/trunks/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java

Modified: directory/trunks/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java?view=diff&rev=477604&r1=477603&r2=477604
==============================================================================
--- directory/trunks/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
(original)
+++ directory/trunks/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
Tue Nov 21 02:17:34 2006
@@ -19,13 +19,9 @@
  */
 package org.apache.directory.server.core.schema.bootstrap;
 
-
-import java.util.Map;
+import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.directory.shared.ldap.util.EnumUtils;
-import org.apache.directory.shared.ldap.util.ValuedEnum;
-
 
 /**
  * Type safe enum for an BootstrapProducer tyoes.  This can be take one of the
@@ -47,95 +43,67 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ProducerTypeEnum extends ValuedEnum
+public enum ProducerTypeEnum
 {
-    private static final long serialVersionUID = 3257284725524475954L;
-
-    private static final String[] producers =
-        { "NormalizerProducer", "ComparatorProducer", "SyntaxCheckerProducer", "SyntaxProducer",
-            "MatchingRuleProducer", "AttributeTypeProducer", "ObjectClassProducer", "MatchingRuleUseProducer",
-            "DitContentRuleProducer", "NameFormProducer", "DitStructureRuleProducer", "StateFactoryProducer",
-            "ObjectFactoryProducer" };
-
     /** value for Normalizer BootstrapProducers */
-    public static final int NORMALIZER_PRODUCER_VAL = 0;
+    NORMALIZER_PRODUCER( 0 ),
+
     /** value for Comparator BootstrapProducers */
-    public static final int COMPARATOR_PRODUCER_VAL = 1;
+    COMPARATOR_PRODUCER( 1 ),
+    
     /** value for SyntaxChecker BootstrapProducers */
-    public static final int SYNTAX_CHECKER_PRODUCER_VAL = 2;
+    SYNTAX_CHECKER_PRODUCER( 2 ),
+    
     /** value for Syntax BootstrapProducers */
-    public static final int SYNTAX_PRODUCER_VAL = 3;
+    SYNTAX_PRODUCER( 3 ),
+    
     /** value for MatchingRule BootstrapProducers */
-    public static final int MATCHING_RULE_PRODUCER_VAL = 4;
+    MATCHING_RULE_PRODUCER( 4 ),
+    
     /** value for AttributeType BootstrapProducers */
-    public static final int ATTRIBUTE_TYPE_PRODUCER_VAL = 5;
+    ATTRIBUTE_TYPE_PRODUCER( 5 ),
+    
     /** value for ObjectClass BootstrapProducers */
-    public static final int OBJECT_CLASS_PRODUCER_VAL = 6;
+    OBJECT_CLASS_PRODUCER( 6 ),
+    
     /** value for MatchingRuleUse BootstrapProducers */
-    public static final int MATCHING_RULE_USE_PRODUCER_VAL = 7;
+    MATCHING_RULE_USE_PRODUCER( 7 ),
+    
     /** value for DitContentRule BootstrapProducers */
-    public static final int DIT_CONTENT_RULE_PRODUCER_VAL = 8;
+    DIT_CONTENT_RULE_PRODUCER( 8 ),
+    
     /** value for NameForm BootstrapProducers */
-    public static final int NAME_FORM_PRODUCER_VAL = 9;
+    NAME_FORM_PRODUCER( 9 ),
+    
     /** value for DitStructureRule BootstrapProducers */
-    public static final int DIT_STRUCTURE_RULE_PRODUCER_VAL = 10;
+    DIT_STRUCTURE_RULE_PRODUCER( 10 ),
+    
     /** value for StateFactory BootstrapProducers */
-    public static final int STATE_FACTORY_PRODUCER_VAL = 11;
+    STATE_FACTORY_PRODUCER( 11 ),
+    
     /** value for ObjectFactory BootstrapProducers */
-    public static final int OBJECT_FACTORY_PRODUCER_VAL = 12;
-
-    /** enum for BootstrapProducers of Normalizer schema objects */
-    public static final ProducerTypeEnum NORMALIZER_PRODUCER = new ProducerTypeEnum( producers[0],
-        NORMALIZER_PRODUCER_VAL );
-    /** enum for BootstrapProducers of Comparator schema objects */
-    public static final ProducerTypeEnum COMPARATOR_PRODUCER = new ProducerTypeEnum( producers[1],
-        COMPARATOR_PRODUCER_VAL );
-    /** enum for BootstrapProducers of SyntaxChecker schema objects */
-    public static final ProducerTypeEnum SYNTAX_CHECKER_PRODUCER = new ProducerTypeEnum(
producers[2],
-        SYNTAX_CHECKER_PRODUCER_VAL );
-    /** enum for BootstrapProducers of Syntax schema objects */
-    public static final ProducerTypeEnum SYNTAX_PRODUCER = new ProducerTypeEnum( producers[3],
SYNTAX_PRODUCER_VAL );
-    /** enum for BootstrapProducers of MatchingRule schema objects */
-    public static final ProducerTypeEnum MATCHING_RULE_PRODUCER = new ProducerTypeEnum( producers[4],
-        MATCHING_RULE_PRODUCER_VAL );
-    /** enum for BootstrapProducers of AttributeType schema objects */
-    public static final ProducerTypeEnum ATTRIBUTE_TYPE_PRODUCER = new ProducerTypeEnum(
producers[5],
-        ATTRIBUTE_TYPE_PRODUCER_VAL );
-    /** enum for BootstrapProducers of ObjectClass schema objects */
-    public static final ProducerTypeEnum OBJECT_CLASS_PRODUCER = new ProducerTypeEnum( producers[6],
-        OBJECT_CLASS_PRODUCER_VAL );
-    /** enum for BootstrapProducers of MatchingRule schema objects */
-    public static final ProducerTypeEnum MATCHING_RULE_USE_PRODUCER = new ProducerTypeEnum(
producers[7],
-        MATCHING_RULE_USE_PRODUCER_VAL );
-    /** enum for BootstrapProducers of DitContentRule schema objects */
-    public static final ProducerTypeEnum DIT_CONTENT_RULE_PRODUCER = new ProducerTypeEnum(
producers[8],
-        DIT_CONTENT_RULE_PRODUCER_VAL );
-    /** enum for BootstrapProducers of NameForm schema objects */
-    public static final ProducerTypeEnum NAME_FORM_PRODUCER = new ProducerTypeEnum( producers[9],
-        NAME_FORM_PRODUCER_VAL );
-    /** enum for BootstrapProducers of DitStructureRule schema objects */
-    public static final ProducerTypeEnum DIT_STRUCTURE_RULE_PRODUCER = new ProducerTypeEnum(
producers[10],
-        DIT_STRUCTURE_RULE_PRODUCER_VAL );
-    /** enum for BootstrapProducers of StateFactory schema objects */
-    public static final ProducerTypeEnum STATE_FACTORY_PRODUCER = new ProducerTypeEnum( producers[11],
-        STATE_FACTORY_PRODUCER_VAL );
-    /** enum for BootstrapProducers of ObjectFactory schema objects */
-    public static final ProducerTypeEnum OBJECT_FACTORY_PRODUCER = new ProducerTypeEnum(
producers[12],
-        OBJECT_FACTORY_PRODUCER_VAL );
-
+    OBJECT_FACTORY_PRODUCER( 12 );
+    
+    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.
      */
-    private ProducerTypeEnum(final String name, final int value)
+    private ProducerTypeEnum( int value )
     {
-        super( name, value );
+        this.value = value;
     }
 
+    /**
+     * @return return the value for this producer type
+     */
+    public int getValue()
+    {
+        return value;
+    }
 
     /**
      * Gets the enumeration type for the attributeType producerType string regardless
@@ -146,81 +114,79 @@
      */
     public static ProducerTypeEnum getProducerType( String producerType )
     {
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.NORMALIZER_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.NORMALIZER_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.COMPARATOR_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.COMPARATOR_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.SYNTAX_CHECKER_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.SYNTAX_CHECKER_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.SYNTAX_PRODUCER.getName() )
)
-        {
-            return ProducerTypeEnum.SYNTAX_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.MATCHING_RULE_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.MATCHING_RULE_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.OBJECT_CLASS_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.OBJECT_CLASS_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.MATCHING_RULE_USE_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.MATCHING_RULE_USE_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.DIT_CONTENT_RULE_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.DIT_CONTENT_RULE_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.NAME_FORM_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.NAME_FORM_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.DIT_STRUCTURE_RULE_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.DIT_STRUCTURE_RULE_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.STATE_FACTORY_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.STATE_FACTORY_PRODUCER;
-        }
-        if ( producerType.equalsIgnoreCase( ProducerTypeEnum.OBJECT_FACTORY_PRODUCER.getName()
) )
-        {
-            return ProducerTypeEnum.OBJECT_FACTORY_PRODUCER;
-        }
-
-        throw new IllegalArgumentException( "Unknown ProducerTypeEnum string" + producerType
);
+        return valueOf( producerType );
     }
-
-
+    
     /**
-     * Gets a List of the enumerations.
      * 
-     * @return the List of enumerations in creation order for ProducerTypes
+     * @return A list of Producer Type
      */
-    public static List list()
+    public static List<ProducerTypeEnum> getList()
     {
-        return EnumUtils.getEnumList( ProducerTypeEnum.class );
+        List<ProducerTypeEnum> list = new ArrayList<ProducerTypeEnum>();
+        
+        list.add(NORMALIZER_PRODUCER );
+        list.add(COMPARATOR_PRODUCER );
+        list.add(SYNTAX_CHECKER_PRODUCER );
+        list.add(SYNTAX_PRODUCER );
+        list.add(MATCHING_RULE_PRODUCER );
+        list.add(ATTRIBUTE_TYPE_PRODUCER );
+        list.add(OBJECT_CLASS_PRODUCER );
+        list.add(MATCHING_RULE_USE_PRODUCER );
+        list.add(DIT_CONTENT_RULE_PRODUCER );
+        list.add(NAME_FORM_PRODUCER );
+        list.add(DIT_STRUCTURE_RULE_PRODUCER );
+        list.add(STATE_FACTORY_PRODUCER );
+        list.add(OBJECT_FACTORY_PRODUCER );
+        
+        return list;
     }
-
-
-    /**
-     * Gets the Map of ProducerTypeEnum objects by name.
-     * 
-     * @return the Map by name of ProducerTypeEnum
-     */
-    public static Map map()
+    
+    public String getName()
     {
-        return EnumUtils.getEnumMap( ProducerTypeEnum.class );
+        switch ( this )
+        {
+            case NORMALIZER_PRODUCER :
+                return "NormalizerProducer";
+
+            case COMPARATOR_PRODUCER :
+                return "ComparatorProducer";
+            
+            case SYNTAX_CHECKER_PRODUCER :
+                return "SyntaxCheckerProducer";
+            
+            case SYNTAX_PRODUCER :
+                return "SyntaxProducer";
+            
+            case MATCHING_RULE_PRODUCER :
+                return "MatchingRuleProducer";
+            
+            case ATTRIBUTE_TYPE_PRODUCER :
+                return "AttributeTypeProducer";
+            
+            case OBJECT_CLASS_PRODUCER :
+                return "ObjectClassProducer";
+            
+            case MATCHING_RULE_USE_PRODUCER:
+                return "MatchingRuleUseProducer";
+            
+            case DIT_CONTENT_RULE_PRODUCER:
+                return "DitContentRuleProducer";
+            
+            case NAME_FORM_PRODUCER :
+                return "NameFormProducer";
+            
+            case DIT_STRUCTURE_RULE_PRODUCER :
+                return "DitStructureRuleProducer";
+            
+            case STATE_FACTORY_PRODUCER :
+                return "StateFactoryProducer";
+            
+            case OBJECT_FACTORY_PRODUCER :
+                return "ObjectFactoryProducer";
+                
+            default :
+                return "";
+        }
     }
 }



Mime
View raw message