directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r474737 - /directory/branches/apacheds-schema/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
Date Tue, 14 Nov 2006 11:22:27 GMT
Author: elecharny
Date: Tue Nov 14 03:22:26 2006
New Revision: 474737

URL: http://svn.apache.org/viewvc?view=rev&rev=474737
Log:
End the switch to Enums.

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

Modified: directory/branches/apacheds-schema/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java?view=diff&rev=474737&r1=474736&r2=474737
==============================================================================
--- directory/branches/apacheds-schema/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
(original)
+++ directory/branches/apacheds-schema/apacheds/core-shared/src/main/java/org/apache/directory/server/core/schema/bootstrap/ProducerTypeEnum.java
Tue Nov 14 03:22:26 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
@@ -49,93 +45,65 @@
  */
 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,59 +114,31 @@
      */
     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 );
     }
+    
+    /**
+     * 
+     * @return A list of Producer Type
+     */
+    public static List<ProducerTypeEnum> getList()
+    {
+    	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;
+  	}
 }



Mime
View raw message