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     * Type safe enum for a matching rule's comparator and normalizer component
024     * usage string. This can be take one of the following three values:
025     * <ul>
026     * <li>ORDERING</li>
027     * <li>EQUALITY</li>
028     * <li>SUBSTRING</li>
029     * </ul>
030     * 
031     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032     */
033    public enum MatchingRuleEnum
034    {
035        /** value for ordering usage */
036        ORDERING( 0 ),
037    
038        /** value for equality usage */
039        EQUALITY( 1 ),
040    
041        /** value for substring usage */
042        SUBSTRING( 2 );
043    
044        /** Stores the integer value of each element of the enumeration */
045        private int value;
046        
047        /**
048         * Private constructor so no other instances can be created other than the
049         * public static constants in this class.
050         * 
051         * @param value
052         *            the integer value of the enumeration.
053         */
054        private MatchingRuleEnum( int value )
055        {
056           this.value = value;
057        }
058    
059        
060        /**
061         * @return The value associated with the current element.
062         */
063        public int getValue()
064        {
065            return value;
066        }
067    
068        /**
069         * Gets the enumeration type for the usage string regardless of case.
070         * 
071         * @param matchingRule the usage string
072         * @return the matchingRule enumeration type
073         */
074        public static MatchingRuleEnum getUsage( String matchingRule )
075        {
076            return valueOf( matchingRule );
077        }
078    }