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