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.server.schema.bootstrap;
021
022 import java.util.Comparator;
023
024 import javax.naming.NamingException;
025
026 import org.apache.directory.server.schema.registries.OidRegistry;
027 import org.apache.directory.server.schema.registries.Registries;
028 import org.apache.directory.shared.ldap.NotImplementedException;
029 import org.apache.directory.shared.ldap.schema.MatchingRule;
030 import org.apache.directory.shared.ldap.schema.Normalizer;
031 import org.apache.directory.shared.ldap.schema.Syntax;
032
033 /**
034 * Document me!
035 *
036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
037 * @version $Rev$
038 */
039 public class NameOrNumericIdMatch implements MatchingRule
040 {
041 private static final long serialVersionUID = 1L;
042
043 private final static String[] NAMES = new String[] { "nameOrNumericIdMatch" };
044 private final static String OID = "1.3.6.1.4.1.18060.0.4.0.1.0";
045 private transient Normalizer normalizer;
046 private transient Comparator comparator;
047 private transient Syntax syntax;
048 private final String schema;
049
050
051 public NameOrNumericIdMatch( String schema )
052 {
053 this.syntax = new ApachemetaSyntaxProducer.NameOrNumericIdSyntax();
054 this.schema = schema;
055 }
056
057
058 public NameOrNumericIdMatch( OidRegistry registry, String schema )
059 {
060 this.normalizer = new NameOrNumericIdNormalizer( registry );
061 this.comparator = new NameOrNumericIdComparator( registry );
062 this.syntax = new ApachemetaSyntaxProducer.NameOrNumericIdSyntax();
063 this.schema = schema;
064 }
065
066
067 public void setRegistries( Registries registries )
068 {
069 this.normalizer = new NameOrNumericIdNormalizer( registries.getOidRegistry() );
070 this.comparator = new NameOrNumericIdComparator( registries.getOidRegistry() );
071 this.syntax = new ApachemetaSyntaxProducer.NameOrNumericIdSyntax();
072 }
073
074
075 /* (non-Javadoc)
076 * @see org.apache.directory.shared.ldap.schema.MatchingRule#getComparator()
077 */
078 public Comparator getComparator() throws NamingException
079 {
080 return comparator;
081 }
082
083
084 /* (non-Javadoc)
085 * @see org.apache.directory.shared.ldap.schema.MatchingRule#getNormalizer()
086 */
087 public Normalizer getNormalizer() throws NamingException
088 {
089 return normalizer;
090 }
091
092
093 /* (non-Javadoc)
094 * @see org.apache.directory.shared.ldap.schema.MatchingRule#getSyntax()
095 */
096 public Syntax getSyntax() throws NamingException
097 {
098 return syntax;
099 }
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 }