View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    https://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.model.schema;
21  
22  
23  import org.apache.directory.api.i18n.I18n;
24  import org.apache.directory.api.ldap.model.constants.SchemaConstants;
25  
26  
27  /**
28   * The SchemaObject types
29   *
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   */
32  public enum SchemaObjectType
33  {
34      /** An AttributeType */
35      ATTRIBUTE_TYPE(0),
36      
37      /** A Comparator */
38      COMPARATOR(1),
39      
40      /** */
41      DIT_CONTENT_RULE(2),
42      
43      /** */
44      DIT_STRUCTURE_RULE(3),
45      
46      /** A Syntax */
47      LDAP_SYNTAX(4),
48      
49      /** A MatchingRule */
50      MATCHING_RULE(5),
51      
52      /** A MatchingRuleUse */
53      MATCHING_RULE_USE(6),
54      
55      /** A NameForm */
56      NAME_FORM(7),
57      
58      /** A Normalizer */
59      NORMALIZER(8),
60      
61      /** An ObjectClass */
62      OBJECT_CLASS(9),
63      
64      /** A SyntaxChecker */
65      SYNTAX_CHECKER(10);
66  
67      /** The inner value*/
68      private int value;
69  
70  
71      /**
72       * A private constructor to associated a number to the type
73       * 
74       * @param value the value
75       */
76      SchemaObjectType( int value )
77      {
78          this.value = value;
79      }
80  
81  
82      /**
83       * @return The numeric value for this type
84       */
85      public int getValue()
86      {
87          return value;
88      }
89  
90  
91      /**
92       * Get the Rdn associated with a schemaObjectType
93       *
94       * @return The associated Rdn
95       */
96      public String getRdn()
97      {
98          String schemaObjectPath;
99  
100         switch ( this )
101         {
102             case ATTRIBUTE_TYPE:
103                 schemaObjectPath = SchemaConstants.ATTRIBUTE_TYPES_PATH;
104                 break;
105 
106             case COMPARATOR:
107                 schemaObjectPath = SchemaConstants.COMPARATORS_PATH;
108                 break;
109 
110             case DIT_CONTENT_RULE:
111                 schemaObjectPath = SchemaConstants.DIT_CONTENT_RULES_PATH;
112                 break;
113 
114             case DIT_STRUCTURE_RULE:
115                 schemaObjectPath = SchemaConstants.DIT_STRUCTURE_RULES_PATH;
116                 break;
117 
118             case LDAP_SYNTAX:
119                 schemaObjectPath = SchemaConstants.SYNTAXES_PATH;
120                 break;
121 
122             case MATCHING_RULE:
123                 schemaObjectPath = SchemaConstants.MATCHING_RULES_PATH;
124                 break;
125 
126             case MATCHING_RULE_USE:
127                 schemaObjectPath = SchemaConstants.MATCHING_RULE_USE_PATH;
128                 break;
129 
130             case NAME_FORM:
131                 schemaObjectPath = SchemaConstants.NAME_FORMS_PATH;
132                 break;
133 
134             case NORMALIZER:
135                 schemaObjectPath = SchemaConstants.NORMALIZERS_PATH;
136                 break;
137 
138             case OBJECT_CLASS:
139                 schemaObjectPath = SchemaConstants.OBJECT_CLASSES_PATH;
140                 break;
141 
142             case SYNTAX_CHECKER:
143                 schemaObjectPath = SchemaConstants.SYNTAX_CHECKERS_PATH;
144                 break;
145 
146             default:
147                 throw new IllegalArgumentException( I18n.err( I18n.ERR_13718_UNEXPECTED_SCHEMA_OBJECT_TYPE, this ) );
148         }
149 
150         return schemaObjectPath;
151     }
152 }