Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 82068 invoked from network); 28 Jul 2009 13:49:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 13:49:43 -0000 Received: (qmail 6077 invoked by uid 500); 28 Jul 2009 13:51:00 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 6048 invoked by uid 500); 28 Jul 2009 13:51:00 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 6039 invoked by uid 99); 28 Jul 2009 13:51:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 13:51:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 13:50:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 36CDE23888C5; Tue, 28 Jul 2009 13:50:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r798523 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java Date: Tue, 28 Jul 2009 13:50:37 -0000 To: commits@felix.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090728135037.36CDE23888C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Tue Jul 28 13:50:36 2009 New Revision: 798523 URL: http://svn.apache.org/viewvc?rev=798523&view=rev Log: FELIX-1284 to support the new activate and modified method signatures the ReadOnlyDictionary also implements the Map interface Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java?rev=798523&r1=798522&r2=798523&view=diff ============================================================================== --- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java (original) +++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java Tue Jul 28 13:50:36 2009 @@ -19,8 +19,13 @@ package org.apache.felix.scr.impl.helper; +import java.util.Collection; +import java.util.Collections; import java.util.Dictionary; import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; /** @@ -28,39 +33,53 @@ * {@link #put(Object, Object)} and {@link #remove(Object)} methods have * no effect and always return null. */ -public class ReadOnlyDictionary extends Dictionary +public class ReadOnlyDictionary extends Dictionary implements Map { - private final Dictionary delegatee; + private final Hashtable m_delegatee; public ReadOnlyDictionary( final Dictionary delegatee ) { - this.delegatee = delegatee; + if ( delegatee instanceof Hashtable ) + { + this.m_delegatee = ( Hashtable ) delegatee; + } + else + { + this.m_delegatee = new Hashtable(); + for ( Enumeration ke = delegatee.elements(); ke.hasMoreElements(); ) + { + Object key = ke.nextElement(); + this.m_delegatee.put( key, delegatee.get( key ) ); + } + } } + //---------- Dictionary API + public Enumeration elements() { - return delegatee.elements(); + return m_delegatee.elements(); } public Object get( final Object key ) { - return delegatee.get( key ); + return m_delegatee.get( key ); } public boolean isEmpty() { - return delegatee.isEmpty(); + return m_delegatee.isEmpty(); } public Enumeration keys() { - return delegatee.keys(); + return m_delegatee.keys(); } @@ -86,12 +105,56 @@ public int size() { - return delegatee.size(); + return m_delegatee.size(); } public String toString() { - return delegatee.toString(); + return m_delegatee.toString(); + } + + + //---------- Map API + + public void clear() + { + // nop, this map is read only + } + + + public boolean containsKey( Object key ) + { + return m_delegatee.containsKey( key ); + } + + + public boolean containsValue( Object value ) + { + return m_delegatee.containsValue( value ); + } + + + public Set entrySet() + { + return Collections.unmodifiableSet( m_delegatee.entrySet() ); + } + + + public Set keySet() + { + return Collections.unmodifiableSet( m_delegatee.keySet() ); + } + + + public void putAll( Map m ) + { + // nop, this map is read only + } + + + public Collection values() + { + return Collections.unmodifiableCollection( m_delegatee.values() ); } }