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.api.ldap.model.schema.registries;
21  
22  
23  import java.util.Iterator;
24  
25  import org.apache.directory.api.i18n.I18n;
26  import org.apache.directory.api.ldap.model.exception.LdapException;
27  import org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException;
28  import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
29  import org.apache.directory.api.ldap.model.schema.LdapSyntax;
30  import org.apache.directory.api.ldap.model.schema.SchemaObjectType;
31  
32  
33  /**
34   * An immutable wrapper of the Syntax registry.
35   *
36   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   */
38  public class ImmutableLdapSyntaxRegistry implements LdapSyntaxRegistry
39  {
40      /** The wrapped LdapSyntax registry */
41      LdapSyntaxRegistry immutableLdapSyntaxRegistry;
42  
43  
44      /**
45       * Creates a new instance of ImmutableLdapSyntaxRegistry.
46       *
47       * @param ldapSyntaxRegistry The wrapped LdapSyntax registry
48       */
49      public ImmutableLdapSyntaxRegistry( LdapSyntaxRegistry ldapSyntaxRegistry )
50      {
51          immutableLdapSyntaxRegistry = ldapSyntaxRegistry;
52      }
53  
54  
55      /**
56       * {@inheritDoc}
57       */
58      public ImmutableLdapSyntaxRegistry copy()
59      {
60          return ( ImmutableLdapSyntaxRegistry ) immutableLdapSyntaxRegistry.copy();
61      }
62  
63  
64      /**
65       * {@inheritDoc}
66       */
67      public int size()
68      {
69          return immutableLdapSyntaxRegistry.size();
70      }
71  
72  
73      /**
74       * {@inheritDoc}
75       */
76      public boolean contains( String oid )
77      {
78          return immutableLdapSyntaxRegistry.contains( oid );
79      }
80  
81  
82      /**
83       * {@inheritDoc}
84       */
85      public String getOidByName( String name ) throws LdapException
86      {
87          return immutableLdapSyntaxRegistry.getOidByName( name );
88      }
89  
90  
91      /**
92       * {@inheritDoc}
93       */
94      public String getSchemaName( String oid ) throws LdapException
95      {
96          return immutableLdapSyntaxRegistry.getSchemaName( oid );
97      }
98  
99  
100     /**
101      * {@inheritDoc}
102      */
103     public SchemaObjectType getType()
104     {
105         return immutableLdapSyntaxRegistry.getType();
106     }
107 
108 
109     /**
110      * {@inheritDoc}
111      */
112     public Iterator<LdapSyntax> iterator()
113     {
114         return immutableLdapSyntaxRegistry.iterator();
115     }
116 
117 
118     /**
119      * {@inheritDoc}
120      */
121     public LdapSyntax lookup( String oid ) throws LdapException
122     {
123         return immutableLdapSyntaxRegistry.lookup( oid );
124     }
125 
126 
127     /**
128      * {@inheritDoc}
129      */
130     public Iterator<String> oidsIterator()
131     {
132         return immutableLdapSyntaxRegistry.oidsIterator();
133     }
134 
135 
136     /**
137      * {@inheritDoc}
138      */
139     public void register( LdapSyntax schemaObject ) throws LdapException
140     {
141         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
142     }
143 
144 
145     /**
146      * {@inheritDoc}
147      */
148     public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException
149     {
150         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
151     }
152 
153 
154     /**
155      * {@inheritDoc}
156      */
157     public LdapSyntax unregister( String numericOid ) throws LdapException
158     {
159         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
160     }
161 
162 
163     /**
164      * {@inheritDoc}
165      */
166     public void unregisterSchemaElements( String schemaName ) throws LdapException
167     {
168         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
169     }
170 
171 
172     /**
173      * {@inheritDoc}
174      */
175     public LdapSyntax get( String oid )
176     {
177         return immutableLdapSyntaxRegistry.get( oid );
178     }
179 
180 
181     /**
182      * {@inheritDoc}
183      */
184     public void clear() throws LdapException
185     {
186         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
187     }
188 
189 
190     /**
191      * {@inheritDoc}
192      */
193     public LdapSyntax unregister( LdapSyntax schemaObject ) throws LdapException
194     {
195         throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04279 ) );
196     }
197 }