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