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 package org.apache.directory.shared.ldap.util; 020 021 022 import javax.naming.NamingEnumeration; 023 import javax.naming.NamingException; 024 import javax.naming.directory.Attribute; 025 import javax.naming.directory.DirContext; 026 027 import org.apache.directory.shared.i18n.I18n; 028 029 030 /** 031 * A read only wrapper around an Attributes object. 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 * @version $Rev$, $Date$ 035 */ 036 public class ImmutableAttributeWrapper implements Attribute 037 { 038 private final Attribute wrapped; 039 040 041 public ImmutableAttributeWrapper( Attribute wrapped ) 042 { 043 this.wrapped = wrapped; 044 } 045 046 047 public NamingEnumeration<?> getAll() throws NamingException 048 { 049 return wrapped.getAll(); 050 } 051 052 053 public Object get() throws NamingException 054 { 055 return wrapped.get(); 056 } 057 058 059 public int size() 060 { 061 return wrapped.size(); 062 } 063 064 065 public String getID() 066 { 067 return wrapped.getID(); 068 } 069 070 071 public boolean contains( Object attrVal ) 072 { 073 return wrapped.contains( attrVal ); 074 } 075 076 077 public boolean add( Object attrVal ) 078 { 079 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04392 ) ); 080 } 081 082 083 public boolean remove( Object attrval ) 084 { 085 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04393 ) ); 086 } 087 088 089 public void clear() 090 { 091 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04394 ) ); 092 } 093 094 095 public DirContext getAttributeSyntaxDefinition() throws NamingException 096 { 097 return wrapped.getAttributeSyntaxDefinition(); 098 } 099 100 101 public DirContext getAttributeDefinition() throws NamingException 102 { 103 return wrapped.getAttributeDefinition(); 104 } 105 106 107 public Object clone() 108 { 109 throw new IllegalStateException( I18n.err( I18n.ERR_04395 ) ); 110 } 111 112 113 public boolean isOrdered() 114 { 115 return wrapped.isOrdered(); 116 } 117 118 119 public Object get( int ix ) throws NamingException 120 { 121 return wrapped.get( ix ); 122 } 123 124 125 public Object remove( int ix ) 126 { 127 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04393 ) ); 128 } 129 130 131 public void add( int ix, Object attrVal ) 132 { 133 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04392 ) ); 134 } 135 136 137 public Object set( int ix, Object attrVal ) 138 { 139 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04396 ) ); 140 } 141 }