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