View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    https://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.model.schema;
21  
22  /**
23   * This Enum is used to list the MatchingRules that will be subject to a PrepareString.
24   * 
25   * 
26   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
27   */
28  public enum MatchingRuleTypeEnum
29  {
30      // The EQUALITY matching rules
31      /** Case Exact Match */
32      CASE_EXACT_MATCH( "2.5.13.5" ),
33      
34      /** Case Exact IA5 Match */
35      CASE_EXACT_IA5_MATCH( "1.3.6.1.4.1.1466.109.114.1" ),
36  
37      /** Case Ignore Match */
38      CASE_IGNORE_IA5_MATCH( "1.3.6.1.4.1.1466.109.114.2" ),
39  
40      /** Case Ignore List Match */
41      CASE_IGNORE_LIST_MATCH( "2.5.13.11" ),
42      
43      /** Case Ignore Match */
44      CASE_IGNORE_MATCH( "2.5.13.2" ),
45      
46      /** DirectoryString First Component Match */
47      DIRECTORY_STRING_FIRST_COMPONENT_MATCH( "2.5.13.31" ),
48      
49      /** Numeric String Match */
50      NUMERIC_STRING_MATCH( "2.5.13.8" ),
51  
52      /** Telephone Number Match */
53      TELEPHONE_NUMBER_MATCH( "2.5.13.20" ),
54      
55      /** Word Match */
56      WORD_MATCH( "2.5.13.32" ),
57  
58      // The ORDERING matching rules
59      /** Case Exact Ordering Match */
60      CASE_EXACT_ORDERING_MATCH( "2.5.13.6" ),
61  
62      /** Case Ignore Ordering Match */
63      CASE_IGNORE_ORDERING_MATCH( "2.5.13.3" ),
64  
65      /** Numeric String Ordering Match */
66      NUMERIC_STRING_ORDERING_MATCH( "2.5.13.9" ),
67  
68      // The SUBSTRING matching rules
69      /** Case Exact Substring Match */
70      CASE_EXACT_SUBSTRINGS_MATCH( "2.5.13.7" ),
71      
72      /** Case Ignore IA5 Substring Match */
73      CASE_IGNORE_IA5_SUBSTRINGS_MATCH( "1.3.6.1.4.1.1466.109.114.3" ),
74      
75      /** Case Ignore List Substring Match */
76      CASE_IGNORE_LIST_SUBSTRINGS_MATCH( "2.5.13.12" ),
77      
78      /** CaseIgnore Substring Match */
79      CASE_IGNORE_SUBSTRINGS_MATCH( "2.5.13.4" ),
80      
81      /** Numeric String Substring Match */
82      NUMERIC_STRING_SUBSTRINGS_MATCH( "2.5.13.10" ),
83      
84      /** Telephone Number Substring Match */
85      TELEPHONE_NUMBER_SUBSTRINGS_MATCH( "2.5.13.21" );
86  
87      /** The interned MR OID */
88      private String oid;
89      
90      /**
91       * Create an instance of MatchingRuleTypeEnum
92       * 
93       * @param oid The MatchingRule OID
94       */
95      MatchingRuleTypeEnum( String oid )
96      {
97          this.oid = oid;
98      }
99      
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 }