001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.model.schema; 021 022 023import org.apache.directory.api.i18n.I18n; 024import org.apache.directory.api.ldap.model.constants.SchemaConstants; 025 026 027/** 028 * The SchemaObject types 029 * 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 */ 032public enum SchemaObjectType 033{ 034 /** An AttributeType */ 035 ATTRIBUTE_TYPE(0), 036 037 /** A Comparator */ 038 COMPARATOR(1), 039 040 /** */ 041 DIT_CONTENT_RULE(2), 042 043 /** */ 044 DIT_STRUCTURE_RULE(3), 045 046 /** A Syntax */ 047 LDAP_SYNTAX(4), 048 049 /** A MatchingRule */ 050 MATCHING_RULE(5), 051 052 /** A MatchingRuleUse */ 053 MATCHING_RULE_USE(6), 054 055 /** A NameForm */ 056 NAME_FORM(7), 057 058 /** A Normalizer */ 059 NORMALIZER(8), 060 061 /** An ObjectClass */ 062 OBJECT_CLASS(9), 063 064 /** A SyntaxChecker */ 065 SYNTAX_CHECKER(10); 066 067 /** The inner value*/ 068 private int value; 069 070 071 /** 072 * A private constructor to associated a number to the type 073 * 074 * @param value the value 075 */ 076 SchemaObjectType( int value ) 077 { 078 this.value = value; 079 } 080 081 082 /** 083 * @return The numeric value for this type 084 */ 085 public int getValue() 086 { 087 return value; 088 } 089 090 091 /** 092 * Get the Rdn associated with a schemaObjectType 093 * 094 * @return The associated Rdn 095 */ 096 public String getRdn() 097 { 098 String schemaObjectPath; 099 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}