project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/UnmodifiableKeyMap.java
changeset 0 fb279309251b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project/com.nokia.carbide.cpp.epoc.engine/src/com/nokia/carbide/internal/cpp/epoc/engine/model/UnmodifiableKeyMap.java	Fri Apr 03 23:33:03 2009 +0100
@@ -0,0 +1,121 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+package com.nokia.carbide.internal.cpp.epoc.engine.model;
+
+import java.util.*;
+
+/**
+ * This is a map whose keys are unmodifiable.
+ *
+ */
+public class UnmodifiableKeyMap<K, V> implements Map<K, V> {
+
+	private static final String MSG = "The keys in this map may not be modified."; //$NON-NLS-1$
+	private Map<K, V> map;
+	
+	public UnmodifiableKeyMap(Map<K, V> realMap) {
+		this.map = realMap;
+	}
+	/* (non-Javadoc)
+	 * @see java.util.Map#clear()
+	 */
+	public void clear() {
+		throw new UnsupportedOperationException(MSG);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#containsKey(java.lang.Object)
+	 */
+	public boolean containsKey(Object key) {
+		return map.containsKey(key);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#containsValue(java.lang.Object)
+	 */
+	public boolean containsValue(Object value) {
+		return map.containsValue(value);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#entrySet()
+	 */
+	public Set<java.util.Map.Entry<K, V>> entrySet() {
+		return Collections.unmodifiableSet(map.entrySet());
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#get(java.lang.Object)
+	 */
+	public V get(Object key) {
+		return map.get(key);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#isEmpty()
+	 */
+	public boolean isEmpty() {
+		return map.isEmpty();
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#keySet()
+	 */
+	public Set<K> keySet() {
+		return Collections.unmodifiableSet(map.keySet());
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+	 */
+	public V put(K key, V value) {
+		if (!map.containsKey(key))
+			throw new UnsupportedOperationException(MSG);
+		return map.put(key, value);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#putAll(java.util.Map)
+	 */
+	public void putAll(Map<? extends K, ? extends V> t) {
+		for (Map.Entry<? extends K, ? extends V> entry : t.entrySet()) {
+			put(entry.getKey(), entry.getValue());
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#remove(java.lang.Object)
+	 */
+	public V remove(Object key) {
+		throw new UnsupportedOperationException(MSG);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#size()
+	 */
+	public int size() {
+		return map.size();
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Map#values()
+	 */
+	public Collection<V> values() {
+		return map.values();
+	}
+}