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 */ 020package org.apache.directory.api.ldap.model.schema.registries; 021 022 023import java.util.Iterator; 024 025import org.apache.directory.api.i18n.I18n; 026import org.apache.directory.api.ldap.model.exception.LdapException; 027import org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException; 028import org.apache.directory.api.ldap.model.message.ResultCodeEnum; 029import org.apache.directory.api.ldap.model.schema.LdapComparator; 030import org.apache.directory.api.ldap.model.schema.SchemaObjectType; 031 032 033/** 034 * An immutable wrapper of the Comparator registry. 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 */ 038public class ImmutableComparatorRegistry implements ComparatorRegistry 039{ 040 /** The wrapped LdapComparator registry */ 041 ComparatorRegistry immutableComparatorRegistry; 042 043 044 /** 045 * Creates a new immutable ComparatorRegistry instance. 046 * 047 * @param comparatorRegistry The wrapped LdapComparator registry 048 */ 049 public ImmutableComparatorRegistry( ComparatorRegistry comparatorRegistry ) 050 { 051 immutableComparatorRegistry = comparatorRegistry; 052 } 053 054 055 /** 056 * {@inheritDoc} 057 */ 058 public void register( LdapComparator<?> comparator ) throws LdapException 059 { 060 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) ); 061 } 062 063 064 /** 065 * {@inheritDoc} 066 */ 067 public LdapComparator<?> unregister( String numericOid ) throws LdapException 068 { 069 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) ); 070 } 071 072 073 /** 074 * {@inheritDoc} 075 */ 076 public void unregisterSchemaElements( String schemaName ) throws LdapException 077 { 078 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) ); 079 } 080 081 082 /** 083 * {@inheritDoc} 084 */ 085 public ImmutableComparatorRegistry copy() 086 { 087 return ( ImmutableComparatorRegistry ) immutableComparatorRegistry.copy(); 088 } 089 090 091 /** 092 * {@inheritDoc} 093 */ 094 public int size() 095 { 096 return immutableComparatorRegistry.size(); 097 } 098 099 100 /** 101 * {@inheritDoc} 102 */ 103 public boolean contains( String oid ) 104 { 105 return immutableComparatorRegistry.contains( oid ); 106 } 107 108 109 /** 110 * {@inheritDoc} 111 */ 112 public String getOidByName( String name ) throws LdapException 113 { 114 return immutableComparatorRegistry.getOidByName( name ); 115 } 116 117 118 /** 119 * {@inheritDoc} 120 */ 121 public String getSchemaName( String oid ) throws LdapException 122 { 123 return immutableComparatorRegistry.getSchemaName( oid ); 124 } 125 126 127 /** 128 * {@inheritDoc} 129 */ 130 public SchemaObjectType getType() 131 { 132 return immutableComparatorRegistry.getType(); 133 } 134 135 136 /** 137 * {@inheritDoc} 138 */ 139 public Iterator<LdapComparator<?>> iterator() 140 { 141 return immutableComparatorRegistry.iterator(); 142 } 143 144 145 /** 146 * {@inheritDoc} 147 */ 148 public LdapComparator<?> lookup( String oid ) throws LdapException 149 { 150 return immutableComparatorRegistry.lookup( oid ); 151 } 152 153 154 /** 155 * {@inheritDoc} 156 */ 157 public Iterator<String> oidsIterator() 158 { 159 return immutableComparatorRegistry.oidsIterator(); 160 } 161 162 163 /** 164 * {@inheritDoc} 165 */ 166 public void renameSchema( String originalSchemaName, String newSchemaName ) throws LdapException 167 { 168 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) ); 169 } 170 171 172 /** 173 * {@inheritDoc} 174 */ 175 public LdapComparator<?> get( String oid ) 176 { 177 return immutableComparatorRegistry.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_04276 ) ); 187 } 188 189 190 /** 191 * {@inheritDoc} 192 */ 193 public LdapComparator<?> unregister( LdapComparator<?> schemaObject ) throws LdapException 194 { 195 throw new LdapUnwillingToPerformException( ResultCodeEnum.NO_SUCH_OPERATION, I18n.err( I18n.ERR_04276 ) ); 196 } 197}