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   *     http://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.server.core.schema;
21  
22  
23  import java.util.Comparator;
24  
25  import javax.naming.NamingException;
26  
27  import org.apache.directory.server.schema.registries.ComparatorRegistry;
28  import org.apache.directory.server.schema.registries.NormalizerRegistry;
29  import org.apache.directory.server.schema.registries.Registries;
30  import org.apache.directory.server.schema.registries.SyntaxRegistry;
31  import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
32  import org.apache.directory.shared.ldap.schema.MutableSchemaObject;
33  import org.apache.directory.shared.ldap.schema.Normalizer;
34  import org.apache.directory.shared.ldap.schema.Syntax;
35  
36  
37  class MatchingRuleImpl extends AbstractMatchingRule implements MutableSchemaObject
38  {
39      private static final long serialVersionUID = 1L;
40      private final SyntaxRegistry syntaxRegistry;
41      private final ComparatorRegistry comparatorRegistry;
42      private final NormalizerRegistry normalizerRegistry;
43      private final String syntaxOid;
44      
45      /**
46       * Creates a MatchingRule using the minimal set of required information.
47       *
48       * @param oid the object identifier for this matching rule
49       */
50      protected MatchingRuleImpl( String oid, String syntaxOid, Registries registries )
51      {
52          super( oid );
53          this.syntaxOid = syntaxOid;
54          syntaxRegistry = registries.getSyntaxRegistry();
55          normalizerRegistry = registries.getNormalizerRegistry();
56          comparatorRegistry = registries.getComparatorRegistry();
57      }
58  
59  
60      public Syntax getSyntax() throws NamingException
61      {
62          return syntaxRegistry.lookup( syntaxOid );
63      }
64  
65  
66      public Comparator getComparator() throws NamingException
67      {
68          return comparatorRegistry.lookup( oid );
69      }
70  
71  
72      public Normalizer getNormalizer() throws NamingException
73      {
74          return normalizerRegistry.lookup( oid );
75      }
76      
77      
78      public void setSchema( String schema )
79      {
80          super.setSchema( schema );
81      }
82      
83  
84      public void setDescription( String description )
85      {
86          super.setDescription( description );
87      }
88      
89      
90      public void setNames( String[] names )
91      {
92          super.setNames( names );
93      }
94      
95      
96      public void setObsolete( boolean obsolete )
97      {
98          super.setObsolete( obsolete );
99      }
100 }