View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.ldap.server.schema.bootstrap;
18  
19  
20  import java.util.Map;
21  import java.util.List;
22  
23  import org.apache.ldap.common.util.EnumUtils;
24  import org.apache.ldap.common.util.ValuedEnum;
25  
26  
27  /***
28   * Type safe enum for an BootstrapProducer tyoes.  This can be take one of the
29   * following values:
30   * <ul>
31   * <li>NormalizerProducer</li>
32   * <li>ComparatorProducer</li>
33   * <li>SyntaxCheckerProducer</li>
34   * <li>SyntaxProducer</li>
35   * <li>MatchingRuleProducer</li>
36   * <li>AttributeTypeProducer</li>
37   * <li>ObjectClassProducer</li>
38   * <li>MatchingRuleUseProducer</li>
39   * <li>DitContentRuleProducer</li>
40   * <li>NameFormProducer</li>
41   * <li>DitStructureRuleProducer</li>
42   * </ul>
43   *
44   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
45   * @version $Rev: 158889 $
46   */
47  public class ProducerTypeEnum extends ValuedEnum
48  {
49  	private static final long serialVersionUID = 3257284725524475954L;
50  
51  	private static final String[] producers = {
52          "NormalizerProducer", "ComparatorProducer", "SyntaxCheckerProducer",
53          "SyntaxProducer", "MatchingRuleProducer", "AttributeTypeProducer",
54          "ObjectClassProducer", "MatchingRuleUseProducer", "DitContentRuleProducer",
55          "NameFormProducer", "DitStructureRuleProducer",
56          "StateFactoryProducer", "ObjectFactoryProducer"
57      };
58  
59      /*** value for Normalizer BootstrapProducers */
60      public static final int NORMALIZER_PRODUCER_VAL = 0;
61      /*** value for Comparator BootstrapProducers */
62      public static final int COMPARATOR_PRODUCER_VAL = 1;
63      /*** value for SyntaxChecker BootstrapProducers */
64      public static final int SYNTAX_CHECKER_PRODUCER_VAL = 2;
65      /*** value for Syntax BootstrapProducers */
66      public static final int SYNTAX_PRODUCER_VAL = 3;
67      /*** value for MatchingRule BootstrapProducers */
68      public static final int MATCHING_RULE_PRODUCER_VAL = 4;
69      /*** value for AttributeType BootstrapProducers */
70      public static final int ATTRIBUTE_TYPE_PRODUCER_VAL = 5;
71      /*** value for ObjectClass BootstrapProducers */
72      public static final int OBJECT_CLASS_PRODUCER_VAL = 6;
73      /*** value for MatchingRuleUse BootstrapProducers */
74      public static final int MATCHING_RULE_USE_PRODUCER_VAL = 7;
75      /*** value for DitContentRule BootstrapProducers */
76      public static final int DIT_CONTENT_RULE_PRODUCER_VAL = 8;
77      /*** value for NameForm BootstrapProducers */
78      public static final int NAME_FORM_PRODUCER_VAL = 9;
79      /*** value for DitStructureRule BootstrapProducers */
80      public static final int DIT_STRUCTURE_RULE_PRODUCER_VAL = 10;
81      /*** value for StateFactory BootstrapProducers */
82      public static final int STATE_FACTORY_PRODUCER_VAL = 11;
83      /*** value for ObjectFactory BootstrapProducers */
84      public static final int OBJECT_FACTORY_PRODUCER_VAL = 12;
85  
86  
87      /*** enum for BootstrapProducers of Normalizer schema objects */
88      public static final ProducerTypeEnum NORMALIZER_PRODUCER =
89          new ProducerTypeEnum( producers[0], NORMALIZER_PRODUCER_VAL );
90      /*** enum for BootstrapProducers of Comparator schema objects */
91      public static final ProducerTypeEnum COMPARATOR_PRODUCER =
92          new ProducerTypeEnum( producers[1], COMPARATOR_PRODUCER_VAL );
93      /*** enum for BootstrapProducers of SyntaxChecker schema objects */
94      public static final ProducerTypeEnum SYNTAX_CHECKER_PRODUCER =
95          new ProducerTypeEnum( producers[2], SYNTAX_CHECKER_PRODUCER_VAL );
96      /*** enum for BootstrapProducers of Syntax schema objects */
97      public static final ProducerTypeEnum SYNTAX_PRODUCER =
98          new ProducerTypeEnum( producers[3], SYNTAX_PRODUCER_VAL );
99      /*** enum for BootstrapProducers of MatchingRule schema objects */
100     public static final ProducerTypeEnum MATCHING_RULE_PRODUCER =
101         new ProducerTypeEnum( producers[4], MATCHING_RULE_PRODUCER_VAL );
102     /*** enum for BootstrapProducers of AttributeType schema objects */
103     public static final ProducerTypeEnum ATTRIBUTE_TYPE_PRODUCER =
104         new ProducerTypeEnum( producers[5], ATTRIBUTE_TYPE_PRODUCER_VAL );
105     /*** enum for BootstrapProducers of ObjectClass schema objects */
106     public static final ProducerTypeEnum OBJECT_CLASS_PRODUCER =
107         new ProducerTypeEnum( producers[6], OBJECT_CLASS_PRODUCER_VAL );
108     /*** enum for BootstrapProducers of MatchingRule schema objects */
109     public static final ProducerTypeEnum MATCHING_RULE_USE_PRODUCER =
110         new ProducerTypeEnum( producers[7], MATCHING_RULE_USE_PRODUCER_VAL );
111     /*** enum for BootstrapProducers of DitContentRule schema objects */
112     public static final ProducerTypeEnum DIT_CONTENT_RULE_PRODUCER =
113         new ProducerTypeEnum( producers[8], DIT_CONTENT_RULE_PRODUCER_VAL );
114     /*** enum for BootstrapProducers of NameForm schema objects */
115     public static final ProducerTypeEnum NAME_FORM_PRODUCER =
116         new ProducerTypeEnum( producers[9], NAME_FORM_PRODUCER_VAL );
117     /*** enum for BootstrapProducers of DitStructureRule schema objects */
118     public static final ProducerTypeEnum DIT_STRUCTURE_RULE_PRODUCER =
119         new ProducerTypeEnum( producers[10], DIT_STRUCTURE_RULE_PRODUCER_VAL );
120     /*** enum for BootstrapProducers of StateFactory schema objects */
121     public static final ProducerTypeEnum STATE_FACTORY_PRODUCER =
122         new ProducerTypeEnum( producers[11], STATE_FACTORY_PRODUCER_VAL );
123     /*** enum for BootstrapProducers of ObjectFactory schema objects */
124     public static final ProducerTypeEnum OBJECT_FACTORY_PRODUCER =
125         new ProducerTypeEnum( producers[12], OBJECT_FACTORY_PRODUCER_VAL );
126 
127 
128     /***
129      * Private construct so no other instances can be created other than the
130      * public static constants in this class.
131      *
132      * @param name a string name for the enumeration value.
133      * @param value the integer value of the enumeration.
134      */
135     private ProducerTypeEnum( final String name, final int value )
136     {
137         super( name, value );
138     }
139     
140     
141     /***
142      * Gets the enumeration type for the attributeType producerType string regardless
143      * of case.
144      * 
145      * @param producerType the producerType string
146      * @return the producerType enumeration type
147      */
148     public static ProducerTypeEnum getProducerType( String producerType )
149     {
150         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.NORMALIZER_PRODUCER.getName() ) )
151         {
152             return ProducerTypeEnum.NORMALIZER_PRODUCER;
153         }
154         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.COMPARATOR_PRODUCER.getName() ) )
155         {
156             return ProducerTypeEnum.COMPARATOR_PRODUCER;
157         }
158         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.SYNTAX_CHECKER_PRODUCER.getName() ) )
159         {
160             return ProducerTypeEnum.SYNTAX_CHECKER_PRODUCER;
161         }
162         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.SYNTAX_PRODUCER.getName() ) )
163         {
164             return ProducerTypeEnum.SYNTAX_PRODUCER;
165         }
166         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.MATCHING_RULE_PRODUCER.getName() ) )
167         {
168             return ProducerTypeEnum.MATCHING_RULE_PRODUCER;
169         }
170         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER.getName() ) )
171         {
172             return ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER;
173         }
174         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.OBJECT_CLASS_PRODUCER.getName() ) )
175         {
176             return ProducerTypeEnum.OBJECT_CLASS_PRODUCER;
177         }
178         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.MATCHING_RULE_USE_PRODUCER.getName() ) )
179         {
180             return ProducerTypeEnum.MATCHING_RULE_USE_PRODUCER;
181         }
182         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.DIT_CONTENT_RULE_PRODUCER.getName() ) )
183         {
184             return ProducerTypeEnum.DIT_CONTENT_RULE_PRODUCER;
185         }
186         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.NAME_FORM_PRODUCER.getName() ) )
187         {
188             return ProducerTypeEnum.NAME_FORM_PRODUCER;
189         }
190         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.DIT_STRUCTURE_RULE_PRODUCER.getName() ) )
191         {
192             return ProducerTypeEnum.DIT_STRUCTURE_RULE_PRODUCER;
193         }
194         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.STATE_FACTORY_PRODUCER.getName() ) )
195         {
196             return ProducerTypeEnum.STATE_FACTORY_PRODUCER;
197         }
198         if ( producerType.equalsIgnoreCase( ProducerTypeEnum.OBJECT_FACTORY_PRODUCER.getName() ) )
199         {
200             return ProducerTypeEnum.OBJECT_FACTORY_PRODUCER;
201         }
202 
203         throw new IllegalArgumentException( "Unknown ProducerTypeEnum string"
204             + producerType );
205     }
206     
207     
208     /***
209      * Gets a List of the enumerations.
210      * 
211      * @return the List of enumerations in creation order for ProducerTypes
212      */
213     public static List list()
214     {
215         return EnumUtils.getEnumList( ProducerTypeEnum.class );
216     }
217     
218     
219     /***
220      * Gets the Map of ProducerTypeEnum objects by name.
221      * 
222      * @return the Map by name of ProducerTypeEnum
223      */
224     public static Map map()
225     {
226         return EnumUtils.getEnumMap( ProducerTypeEnum.class );
227     }
228 }