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/**
023 * This Enum is used to list the MatchingRules that will be subject to a PrepareString.
024 * 
025 * 
026 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
027 */
028public enum MatchingRuleTypeEnum
029{
030    // The EQUALITY matching rules
031    /** Case Exact Match */
032    CASE_EXACT_MATCH( "2.5.13.5" ),
033    
034    /** Case Exact IA5 Match */
035    CASE_EXACT_IA5_MATCH( "1.3.6.1.4.1.1466.109.114.1" ),
036
037    /** Case Ignore Match */
038    CASE_IGNORE_IA5_MATCH( "1.3.6.1.4.1.1466.109.114.2" ),
039
040    /** Case Ignore List Match */
041    CASE_IGNORE_LIST_MATCH( "2.5.13.11" ),
042    
043    /** Case Ignore Match */
044    CASE_IGNORE_MATCH( "2.5.13.2" ),
045    
046    /** DirectoryString First Component Match */
047    DIRECTORY_STRING_FIRST_COMPONENT_MATCH( "2.5.13.31" ),
048    
049    /** Numeric String Match */
050    NUMERIC_STRING_MATCH( "2.5.13.8" ),
051
052    /** Telephone Number Match */
053    TELEPHONE_NUMBER_MATCH( "2.5.13.20" ),
054    
055    /** Word Match */
056    WORD_MATCH( "2.5.13.32" ),
057
058    // The ORDERING matching rules
059    /** Case Exact Ordering Match */
060    CASE_EXACT_ORDERING_MATCH( "2.5.13.6" ),
061
062    /** Case Ignore Ordering Match */
063    CASE_IGNORE_ORDERING_MATCH( "2.5.13.3" ),
064
065    /** Numeric String Ordering Match */
066    NUMERIC_STRING_ORDERING_MATCH( "2.5.13.9" ),
067
068    // The SUBSTRING matching rules
069    /** Case Exact Substring Match */
070    CASE_EXACT_SUBSTRINGS_MATCH( "2.5.13.7" ),
071    
072    /** Case Ignore IA5 Substring Match */
073    CASE_IGNORE_IA5_SUBSTRINGS_MATCH( "1.3.6.1.4.1.1466.109.114.3" ),
074    
075    /** Case Ignore List Substring Match */
076    CASE_IGNORE_LIST_SUBSTRINGS_MATCH( "2.5.13.12" ),
077    
078    /** CaseIgnore Substring Match */
079    CASE_IGNORE_SUBSTRINGS_MATCH( "2.5.13.4" ),
080    
081    /** Numeric String Substring Match */
082    NUMERIC_STRING_SUBSTRINGS_MATCH( "2.5.13.10" ),
083    
084    /** Telephone Number Substring Match */
085    TELEPHONE_NUMBER_SUBSTRINGS_MATCH( "2.5.13.21" );
086
087    /** The interned MR OID */
088    private String oid;
089    
090    /**
091     * Create an instance of MatchingRuleTypeEnum
092     * 
093     * @param oid The MatchingRule OID
094     */
095    MatchingRuleTypeEnum( String oid )
096    {
097        this.oid = oid;
098    }
099    
100    
101    /**
102     * Get the MatchingRuleTypeEnum associated with an OID
103     * 
104     * @param oid The OID for which we want the MatchingRuleTypeEnum.
105     * @return The MatchingRuleTypeEnum we found, or null.
106     */
107    public static MatchingRuleTypeEnum getMatchingRuleType( String oid )
108    {
109        if ( CASE_EXACT_MATCH.oid.equals( oid ) )
110        {
111            return CASE_EXACT_MATCH;
112        }
113        
114        if ( CASE_EXACT_IA5_MATCH.oid.equals( oid ) )
115        {
116            return CASE_EXACT_IA5_MATCH;
117        }
118        
119        if ( CASE_IGNORE_IA5_MATCH.oid.equals( oid ) )
120        {
121            return CASE_IGNORE_IA5_MATCH;
122        }
123        
124        if ( CASE_IGNORE_LIST_MATCH.oid.equals( oid ) )
125        {
126            return CASE_IGNORE_LIST_MATCH;
127        }
128        
129        if ( CASE_IGNORE_MATCH.oid.equals( oid ) )
130        {
131            return CASE_IGNORE_MATCH;
132        }
133        
134        if ( DIRECTORY_STRING_FIRST_COMPONENT_MATCH.oid.equals( oid ) )
135        {
136            return DIRECTORY_STRING_FIRST_COMPONENT_MATCH;
137        }
138        
139        if ( NUMERIC_STRING_MATCH.oid.equals( oid ) )
140        {
141            return NUMERIC_STRING_MATCH;
142        }
143        
144        if ( TELEPHONE_NUMBER_MATCH.oid.equals( oid ) )
145        {
146            return TELEPHONE_NUMBER_MATCH;
147        }
148        
149        if ( WORD_MATCH.oid.equals( oid ) )
150        {
151            return WORD_MATCH;
152        }
153        
154        return null;
155    }
156}