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   *    http://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.ldap.model.constants.SchemaConstants;
24  
25  
26  /**
27   * The SchemaObject types
28   *
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  public enum SchemaObjectType
32  {
33      /** An AttributeType */
34      ATTRIBUTE_TYPE(0),
35      
36      /** A Comparator */
37      COMPARATOR(1),
38      
39      /** */
40      DIT_CONTENT_RULE(2),
41      
42      /** */
43      DIT_STRUCTURE_RULE(3),
44      
45      /** A Syntax */
46      LDAP_SYNTAX(4),
47      
48      /** A MatchingRule */
49      MATCHING_RULE(5),
50      
51      /** A MatchingRuleUse */
52      MATCHING_RULE_USE(6),
53      
54      /** A NameForm */
55      NAME_FORM(7),
56      
57      /** A Normalizer */
58      NORMALIZER(8),
59      
60      /** An ObjectClass */
61      OBJECT_CLASS(9),
62      
63      /** A SyntaxChecker */
64      SYNTAX_CHECKER(10);
65  
66      /** The inner value*/
67      private int value;
68  
69  
70      /**
71       * A private constructor to associated a number to the type
72       */
73      SchemaObjectType( int value )
74      {
75          this.value = value;
76      }
77  
78  
79      /**
80       * @return The numeric value for this type
81       */
82      public int getValue()
83      {
84          return value;
85      }
86  
87  
88      /**
89       * Get the Rdn associated with a schemaObjectType
90       *
91       * @return The associated Rdn
92       */
93      public String getRdn()
94      {
95          String schemaObjectPath;
96  
97          switch ( this )
98          {
99              case ATTRIBUTE_TYPE:
100                 schemaObjectPath = SchemaConstants.ATTRIBUTE_TYPES_PATH;
101                 break;
102 
103             case COMPARATOR:
104                 schemaObjectPath = SchemaConstants.COMPARATORS_PATH;
105                 break;
106 
107             case DIT_CONTENT_RULE:
108                 schemaObjectPath = SchemaConstants.DIT_CONTENT_RULES_PATH;
109                 break;
110 
111             case DIT_STRUCTURE_RULE:
112                 schemaObjectPath = SchemaConstants.DIT_STRUCTURE_RULES_PATH;
113                 break;
114 
115             case LDAP_SYNTAX:
116                 schemaObjectPath = SchemaConstants.SYNTAXES_PATH;
117                 break;
118 
119             case MATCHING_RULE:
120                 schemaObjectPath = SchemaConstants.MATCHING_RULES_PATH;
121                 break;
122 
123             case MATCHING_RULE_USE:
124                 schemaObjectPath = SchemaConstants.MATCHING_RULE_USE_PATH;
125                 break;
126 
127             case NAME_FORM:
128                 schemaObjectPath = SchemaConstants.NAME_FORMS_PATH;
129                 break;
130 
131             case NORMALIZER:
132                 schemaObjectPath = SchemaConstants.NORMALIZERS_PATH;
133                 break;
134 
135             case OBJECT_CLASS:
136                 schemaObjectPath = SchemaConstants.OBJECT_CLASSES_PATH;
137                 break;
138 
139             case SYNTAX_CHECKER:
140                 schemaObjectPath = SchemaConstants.SYNTAX_CHECKERS_PATH;
141                 break;
142 
143             default:
144                 throw new IllegalArgumentException( "Unexpected SchemaObjectType " + this );
145         }
146 
147         return schemaObjectPath;
148     }
149 }