KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > common > util > EMap


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: EMap.java,v 1.2 2005/06/08 06:19:08 nickb Exp $
16  */

17 package org.eclipse.emf.common.util;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.Map JavaDoc;
22 import java.util.Set JavaDoc;
23
24
25 /**
26  * A list of {@link java.util.Map.Entry java.util.Map.Entry} instances, i.e., entries, that
27  * supports a {@link #map} view
28  * as well as the full {@link java.util.Map} API,
29  * with the noteable exception of {@link java.util.Map#remove(Object)}.
30  * It's return type conflicts with that of {@link java.util.Collection#remove(Object)}.
31  * The {@link #removeKey removeKey(Object)} method may be used instead.
32  * The implementation of remove may delegate to <code>removeKey</code>
33  * for an object that is not an instance of <code>Map.Entry</code>.
34  */

35 public interface EMap extends EList
36 {
37   /**
38    * Returns the value associated with the key.
39    * The key, the value, or both may be <code>null</code>.
40    * @param key the key of the value.
41    * @return the value associated with the key.
42    */

43   Object JavaDoc get(Object JavaDoc key);
44
45   /**
46    * Associates the key with the value
47    * and returns the value previously associated with the key, or <code>null</code>.
48    * The key, the value, or both may be <code>null</code>.
49    * Either the existing entry is updated,
50    * or a new entry is added to the end of the list.
51    * @param key the key of the value.
52    * @param value the value associated with the key.
53    * @return the value formerly associated with the key, or <code>null</code>.
54    */

55   Object JavaDoc put(Object JavaDoc key, Object JavaDoc value);
56
57   /**
58    * Puts each {@link java.util.Map.Entry Map.Entry} of the given map into this one.
59    * @param map the map of entries.
60    * @see #put
61    */

62   void putAll(Map JavaDoc map);
63
64   /**
65    * Puts each {@link java.util.Map.Entry Map.Entry} of the given map into this one.
66    * @param map the map of entries.
67    * @see #put
68    */

69   void putAll(EMap map);
70
71   /**
72    * Returns the index in the list of the entry with the given key,
73    * or <code>-1</code>, if there is no such entry.
74    * @param key a key.
75    * @return the index of the entry with the given key.
76    */

77   int indexOfKey(Object JavaDoc key);
78
79   /**
80    * Returns whether the key is associated with a value.
81    * @param key a key associated with a value.
82    * @return whether the key is associated with a value.
83    */

84   boolean containsKey(Object JavaDoc key);
85
86   /**
87    * Returns whether the value is associated with a key.
88    * @param value a value associated with a key.
89    * @return whether the value is associated with a key.
90    */

91   boolean containsValue(Object JavaDoc value);
92
93   /**
94    * Disassociates the key from its value,
95    * and returns the value formerly associated with the key.
96    * An entry is removed from the list, if the key is found.
97    * @param key the key of a value.
98    * @return the value formerly associated with the key.
99    *
100    */

101   Object JavaDoc removeKey(Object JavaDoc key);
102
103   /**
104    * Returns a map view.
105    * @return a map view.
106    */

107   Map JavaDoc map();
108
109   /**
110    * Returns a set view of the entries.
111    * @return a set view of the entries.
112    */

113   Set JavaDoc entrySet();
114
115   /**
116    * Returns a set view of the keys of the entries.
117    * @return a set view of the keys of the entries.
118    */

119   Set JavaDoc keySet();
120
121   /**
122    * Returns a collection view the values of the entries.
123    * @return a collection view the values of the entries.
124    */

125   Collection JavaDoc values();
126
127   /**
128    * An internal interface implemented by the {@link #map() map view}.
129    * It provides access to the EMap view.
130    */

131   interface InternalMapView extends Map JavaDoc
132   {
133     /**
134      * Returns the EMap view of the map.
135      * @return the EMap view of the map.
136      */

137     EMap eMap();
138   }
139 }
140
Popular Tags