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.i18n.I18n; 24 import org.apache.directory.api.util.Strings; 25 26 27 /** 28 * Type safe enumerations for an objectClass' type. An ObjectClass type can be 29 * one of the following types: 30 * <ul> 31 * <li>ABSTRACT</li> 32 * <li>AUXILIARY</li> 33 * <li>STRUCTURAL</li> 34 * </ul> 35 * 36 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 37 */ 38 public enum ObjectClassTypeEnum 39 { 40 /** The enumeration constant value for the abstract objectClasses */ 41 ABSTRACT(0), 42 43 /** The enumeration constant value for the auxillary objectClasses */ 44 AUXILIARY(1), 45 46 /** The enumeration constant value for the structural objectClasses */ 47 STRUCTURAL(2); 48 49 /** The int constant value for the abstract objectClasses */ 50 public static final int ABSTRACT_VAL = 0; 51 52 /** The int constant value for the auxillary objectClasses */ 53 public static final int AUXILIARY_VAL = 1; 54 55 /** The int constant value for the structural objectClasses */ 56 public static final int STRUCTURAL_VAL = 2; 57 58 /** Stores the integer value of each element of the enumeration */ 59 private int value; 60 61 62 /** 63 * Private constructor so no other instances can be created other than the 64 * public static constants in this class. 65 * 66 * @param name 67 * a string name for the enumeration value. 68 * @param value 69 * the integer value of the enumeration. 70 */ 71 ObjectClassTypeEnum( int value ) 72 { 73 this.value = value; 74 } 75 76 77 /** 78 * @return The value associated with the current element. 79 */ 80 public int getValue() 81 { 82 return value; 83 } 84 85 86 /** 87 * Gets the objectClass type enumeration of AUXILIARY, STRUCTURAL, or, 88 * ABSTRACT. 89 * 90 * @param name options are AUXILIARY, STRUCTURAL, or, ABSTRACT 91 * 92 * @return the type safe enumeration for the objectClass type 93 */ 94 public static ObjectClassTypeEnum getClassType( String name ) 95 { 96 String upperCase = Strings.upperCase( name.trim() ); 97 98 if ( upperCase.equals( "STRUCTURAL" ) ) 99 { 100 return STRUCTURAL; 101 } 102 else if ( upperCase.equals( "AUXILIARY" ) ) 103 { 104 return AUXILIARY; 105 } 106 else if ( upperCase.equals( "ABSTRACT" ) ) 107 { 108 return ABSTRACT; 109 } 110 111 throw new IllegalArgumentException( I18n.err( I18n.ERR_04327, name ) ); 112 } 113 }