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.util.Strings; 025 026 027/** 028 * Type safe enumerations for an objectClass' type. An ObjectClass type can be 029 * one of the following types: 030 * <ul> 031 * <li>ABSTRACT</li> 032 * <li>AUXILIARY</li> 033 * <li>STRUCTURAL</li> 034 * </ul> 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 */ 038public enum ObjectClassTypeEnum 039{ 040 /** The enumeration constant value for the abstract objectClasses */ 041 ABSTRACT(0), 042 043 /** The enumeration constant value for the auxillary objectClasses */ 044 AUXILIARY(1), 045 046 /** The enumeration constant value for the structural objectClasses */ 047 STRUCTURAL(2); 048 049 /** The int constant value for the abstract objectClasses */ 050 public static final int ABSTRACT_VAL = 0; 051 052 /** The int constant value for the auxillary objectClasses */ 053 public static final int AUXILIARY_VAL = 1; 054 055 /** The int constant value for the structural objectClasses */ 056 public static final int STRUCTURAL_VAL = 2; 057 058 /** Stores the integer value of each element of the enumeration */ 059 private int value; 060 061 062 /** 063 * Private constructor so no other instances can be created other than the 064 * public static constants in this class. 065 * 066 * @param name 067 * a string name for the enumeration value. 068 * @param value 069 * the integer value of the enumeration. 070 */ 071 ObjectClassTypeEnum( int value ) 072 { 073 this.value = value; 074 } 075 076 077 /** 078 * @return The value associated with the current element. 079 */ 080 public int getValue() 081 { 082 return value; 083 } 084 085 086 /** 087 * Gets the objectClass type enumeration of AUXILIARY, STRUCTURAL, or, 088 * ABSTRACT. 089 * 090 * @param name options are AUXILIARY, STRUCTURAL, or, ABSTRACT 091 * 092 * @return the type safe enumeration for the objectClass type 093 */ 094 public static ObjectClassTypeEnum getClassType( String name ) 095 { 096 String upperCase = Strings.upperCase( name.trim() ); 097 098 if ( upperCase.equals( "STRUCTURAL" ) ) 099 { 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}