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.schema.bootstrap;
21  
22  import java.util.Comparator;
23  
24  import javax.naming.NamingException;
25  
26  import org.apache.directory.server.schema.registries.OidRegistry;
27  import org.apache.directory.server.schema.registries.Registries;
28  import org.apache.directory.shared.ldap.NotImplementedException;
29  import org.apache.directory.shared.ldap.schema.MatchingRule;
30  import org.apache.directory.shared.ldap.schema.Normalizer;
31  import org.apache.directory.shared.ldap.schema.Syntax;
32  
33  /**
34   * Document me!
35   *
36   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   * @version $Rev$
38   */
39  public class NameOrNumericIdMatch implements MatchingRule
40  {
41      private static final long serialVersionUID = 1L;
42      
43      private final static String[] NAMES = new String[] { "nameOrNumericIdMatch" }; 
44      private final static String OID = "1.3.6.1.4.1.18060.0.4.0.1.0";
45      private transient Normalizer normalizer;
46      private transient Comparator comparator;
47      private transient Syntax syntax;
48      private final String schema;
49      
50      
51      public NameOrNumericIdMatch( String schema )
52      {
53          this.syntax = new ApachemetaSyntaxProducer.NameOrNumericIdSyntax();
54          this.schema = schema;
55      }
56  
57      
58      public NameOrNumericIdMatch( OidRegistry registry, String schema )
59      {
60          this.normalizer = new NameOrNumericIdNormalizer( registry );
61          this.comparator = new NameOrNumericIdComparator( registry );
62          this.syntax = new ApachemetaSyntaxProducer.NameOrNumericIdSyntax();
63          this.schema = schema;
64      }
65      
66  
67      public void setRegistries( Registries registries )
68      {
69          this.normalizer = new NameOrNumericIdNormalizer( registries.getOidRegistry() );
70          this.comparator = new NameOrNumericIdComparator( registries.getOidRegistry() );
71          this.syntax = new ApachemetaSyntaxProducer.NameOrNumericIdSyntax();
72      }
73  
74      
75      /* (non-Javadoc)
76       * @see org.apache.directory.shared.ldap.schema.MatchingRule#getComparator()
77       */
78      public Comparator getComparator() throws NamingException
79      {
80          return comparator;
81      }
82  
83  
84      /* (non-Javadoc)
85       * @see org.apache.directory.shared.ldap.schema.MatchingRule#getNormalizer()
86       */
87      public Normalizer getNormalizer() throws NamingException
88      {
89          return normalizer;
90      }
91  
92  
93      /* (non-Javadoc)
94       * @see org.apache.directory.shared.ldap.schema.MatchingRule#getSyntax()
95       */
96      public Syntax getSyntax() throws NamingException
97      {
98          return syntax;
99      }
100 
101 
102     /* (non-Javadoc)
103      * @see org.apache.directory.shared.ldap.schema.SchemaObject#getDescription()
104      */
105     public String getDescription()
106     {
107         return "A name or numeric id matchingRule";
108     }
109 
110 
111     /* (non-Javadoc)
112      * @see org.apache.directory.shared.ldap.schema.SchemaObject#getName()
113      */
114     public String getName()
115     {
116         return NAMES[0];
117     }
118 
119 
120     /* (non-Javadoc)
121      * @see org.apache.directory.shared.ldap.schema.SchemaObject#getNamesRef()
122      */
123     public String[] getNamesRef()
124     {
125         return NAMES;
126     }
127 
128 
129     /* (non-Javadoc)
130      * @see org.apache.directory.shared.ldap.schema.SchemaObject#getOid()
131      */
132     public String getOid()
133     {
134         return OID;
135     }
136 
137 
138     /* (non-Javadoc)
139      * @see org.apache.directory.shared.ldap.schema.SchemaObject#isObsolete()
140      */
141     public boolean isObsolete()
142     {
143         return false;
144     }
145 
146 
147     public String getSchema()
148     {
149         return schema;
150     }
151 
152 
153     public void setSchema( String schemaName )
154     {
155         throw new NotImplementedException();
156     }
157 }