java.util

Interface Map<K,V>

Known Subinterfaces:
BidiMap, Bindings, BoundedMap, ConcurrentMap<K,V>, Context, IterableMap, LogicalMessageContext, MappedRecord, MessageContext, MultiMap, OrderedBidiMap, OrderedMap, SOAPMessageContext, SortedBidiMap, SortedMap<K,V>
Known Implementing Classes:
AbstractBidiMapDecorator, AbstractDualBidiMap, AbstractHashedMap, AbstractLinkedMap, AbstractMap<K,V>, AbstractMapDecorator, AbstractOrderedBidiMapDecorator, AbstractOrderedMapDecorator, AbstractReferenceMap, AbstractSortedBidiMapDecorator, AbstractSortedMapDecorator, ApplicationMap, AttributeMap, Attributes, AuthProvider, BeanMap, BeanMap, BinaryTree, BlockDiskKeyStore.LRUMap, CacheMap, CachingMapDecorator, CaseInsensitiveMap, CharacterFilter, CompositeMap, ConcurrentHashMap<K,V>, ConfigurationDynaBean, ConfigurationMap, ContextBase, CustomProperties, DefaultedMap, DoubleOrderedMap, DualHashBidiMap, DualTreeBidiMap, DualTreeBidiMap.ViewMap, DublinCoreSchema, DynaBeanMapDecorator, EnumeratedMap, EnumMap<K,extends,Enum,K,V>, ExtendedProperties, FacesWebContext, FastHashMap, FastHashMap, FastTreeMap, FixedSizeMap, FixedSizeSortedMap, Flat3Map, HashedMap, HashMap<K,V>, HashMapContext, Hashtable<K,V>, Html2Ecs, HtmlTagMap, IdentityHashMap<K,V>, IdentityMap, IdentityMap, IndexedDiskCache.LRUMap, JRAbstractLRUVirtualizer.Cache.LRUScanMap, JUnit4TestAdapterCache, LangAlt, LazyMap, LazySortedMap, LinkedHashMap<K,V>, LinkedMap, ListOrderedMap, LRUMap, LRUMap, LRUMap, LRUMapJCS, ManagedMap, ManagedProperties, MapProxy, MultiHashMap, MultiKeyMap, MultiValueMap, OptimisticMapWrapper, PdfA1Schema, PdfSchema, PersistentMap, PersistentSortedMap, PessimisticMapWrapper, PortletApplicationMap, PortletRequestMap, PortletSessionMap, PortletWebContext, PredicatedMap, PredicatedSortedMap, PrinterStateReasons, Properties, PropertyIDMap, Provider, ProxyMap, ReferenceIdentityMap, ReferenceMap, ReferenceMap, RegexpFilter, RenderingHints, RequestMap, SectionIDMap, SequencedHashMap, ServletWebContext, SessionMap, SimpleBindings, SingletonMap, StaticBucketMap, StaticBucketMap, StringFilter, TabularDataSupport, TagMap, TransactionalMapWrapper, TransformedMap, TransformedSortedMap, TreeBidiMap, TreeMap<K,V>, UIDefaults, UnmodifiableBidiMap, UnmodifiableMap, UnmodifiableOrderedBidiMap, UnmodifiableOrderedMap, UnmodifiableSortedBidiMap, UnmodifiableSortedMap, WeakHashMap<K,V>, WeakHashtable, WebColors, WebContext, WordFilter, XmpBasicSchema, XmpMMSchema, XmpSchema

public interface Map<K,V>

An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.

The Map interface provides three collection views, which allow a map's contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The order of a map is defined as the order in which the iterators on the map's collection views return their elements. Some map implementations, like the TreeMap class, make specific guarantees as to their order; others, like the HashMap class, do not.

Note: great care must be exercised if mutable objects are used as map keys. The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map. A special case of this prohibition is that it is not permissible for a map to contain itself as a key. While it is permissible for a map to contain itself as a value, extreme caution is advised: the equals and hashCode methods are no longer well defined on a such a map.

All general-purpose map implementation classes should provide two "standard" constructors: a void (no arguments) constructor which creates an empty map, and a constructor with a single argument of type Map, which creates a new map with the same key-value mappings as its argument. In effect, the latter constructor allows the user to copy any map, producing an equivalent map of the desired class. There is no way to enforce this recommendation (as interfaces cannot contain constructors) but all of the general-purpose map implementations in the JDK comply.

The "destructive" methods contained in this interface, that is, the methods that modify the map on which they operate, are specified to throw UnsupportedOperationException if this map does not support the operation. If this is the case, these methods may, but are not required to, throw an UnsupportedOperationException if the invocation would have no effect on the map. For example, invoking the putAll(Map) method on an unmodifiable map may, but is not required to, throw the exception if the map whose mappings are to be "superimposed" is empty.

Some map implementations have restrictions on the keys and values they may contain. For example, some implementations prohibit null keys and values, and some have restrictions on the types of their keys. Attempting to insert an ineligible key or value throws an unchecked exception, typically NullPointerException or ClassCastException. Attempting to query the presence of an ineligible key or value may throw an exception, or it may simply return false; some implementations will exhibit the former behavior and some will exhibit the latter. More generally, attempting an operation on an ineligible key or value whose completion would not result in the insertion of an ineligible element into the map may throw an exception or it may succeed, at the option of the implementation. Such exceptions are marked as "optional" in the specification for this interface.

This interface is a member of the ../../../guide/collections/index.html"> Java Collections Framework.

Many methods in Collections Framework interfaces are defined in terms of the equals method. For example, the specification for the contains(Object key) method says: "returns true if and only if this map contain a mapping for a key k such that (key==null ? k==null : key.equals(k))." This specification should not be construed to imply that invoking Map.containsKey with a non-null argument key will cause key.equals(k) to be invoked for any key k. Implementations are free to implement optimizations whereby the equals invocation is avoided, for example, by first comparing the hash codes of the two keys. (The Object.hashCode() specification guarantees that two objects with unequal hash codes cannot be equal.) More generally, implementations of the various Collections Framework interfaces are free to take advantage of the specified behavior of underlying Object methods wherever the implementor deems it appropriate.

Since:
1.2
See Also:
HashMap, TreeMap, Hashtable, SortedMap, Collection, Set

Nested Class Summary

static interface
Map.Entry
A map entry (key-value pair).

Method Summary

Set
V>> entrySet()
Returns a set view of the mappings contained in this map.
void
clear()
Removes all mappings from this map (optional operation).
boolean
containsKey(Object key)
Returns true if this map contains a mapping for the specified key.
boolean
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
boolean
equals(Object o)
Compares the specified object with this map for equality.
V
get(Object key)
Returns the value to which this map maps the specified key.
int
hashCode()
Returns the hash code value for this map.
boolean
isEmpty()
Returns true if this map contains no key-value mappings.
Set
keySet()
Returns a set view of the keys contained in this map.
V
put(K key, V value)
Associates the specified value with the specified key in this map (optional operation).
void
putAll(extends K, V> t)
Copies all of the mappings from the specified map to this map (optional operation).
V
remove(Object key)
Removes the mapping for this key from this map if it is present (optional operation).
int
size()
Returns the number of key-value mappings in this map.
Collection
values()
Returns a collection view of the values contained in this map.

Method Details

V>> entrySet

public SetV>> entrySet()
Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
Returns:
a set view of the mappings contained in this map.

clear

public void clear()
Removes all mappings from this map (optional operation).
Throws:
UnsupportedOperationException - clear is not supported by this map.
Usages and Demos :

View More Examples of clear()
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5: {
   6:     private final Map values = new HashMap();
   7:     public void setValue(String  key, Object value)
   8:         ...
   9:     {
  10:         values.clear();
  11:     }

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5: public class HashMapWorld implements World {
   6:     private final Map map = new HashMap();
   7: 
   8:         ...
   9:     public void clear() {
  10:         map.clear();
  11:     }

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5: public class CachedFetcher extends DelegatedFetcher {
   6:     private Map cache = new HashMap();
   7: 
   8:         ...
   9:     public void purge() {
  10:         cache.clear();
  11:     }

View Full Code Here
   1: 
   2: import java.util.Map;
   3: 
   4:         ...
   5:     
   6:     protected final Map map;
   7:     
   8:         ...
   9:     public void close() {
  10:         map.clear();
  11:     }

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5: public class HashMapWorld implements World {
   6:     private final Map map = new HashMap();
   7: 
   8:         ...
   9:     public void clear() {
  10:         map.clear();
  11:     }

View Full Code Here

containsKey

public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)
Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.
Throws:
ClassCastException - if the key is of an inappropriate type for this map (optional).
NullPointerException - if the key is null and this map does not permit null keys (optional).
Usages and Demos :

View More Examples of containsKey(Object key)
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5: 
   6:   Map varEvol_;
   7: 
   8:         ...
   9:     if (varEvol_ == null) varEvol_ = new HashMap();
  10:     if (varEvol_.containsKey(_evol) && (varEvol_.get(_evol) != _t)) {
  11:       varEvol_.put(_evol, null);
  12:         ...
  13:   public boolean isSet(H2dEvolution _e){
  14:     return varEvol_!=null && varEvol_.containsKey(_e);

View Full Code Here
   1: 
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5:     public void testPutGet() throws Exception {
   6:         Map map = new CollationKeyMap(Locale.GERMANY, Collator.SECONDARY);
   7:         map.put("Hello", "Hello");
   8:         ...
   9:         map.put("Hello", "Hello");
  10:         assertTrue("Failed to get item from map.", map.containsKey("hellO"));
  11:     }

View Full Code Here
   1: 
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5:     public void testPutGet() throws Exception {
   6:         Map map = new CaseInsensitiveMap();
   7:         map.put("Hello", "Hello");
   8:         ...
   9:         map.put("Hello", "Hello");
  10:         assertTrue("Failed to get item from map.", map.containsKey("hellO"));
  11:     }
  12:         ...
  13:         assertNull(map.get("Java"));
  14:         assertTrue(map.containsKey("Java"));

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5:     {
   6:         Map attributes = getAttributes(edge);
   7:         assert attributes != null : this + ": No attributes for " + edge;
   8:         ...
   9:     {
  10:         Map attributes = getAttributes(edge);
  11:         assert attributes != null : this + ": No attributes for " + edge;
  12:         ...
  13:         }
  14:         return attributes.containsKey("removed");

View Full Code Here
   1:         OrderedMapIterator it = makeEmptyOrderedMapIterator();
   2:         Map map = getMap();
   3:         assertEquals(false, it.hasPrevious());
   4:         ...
   5:         OrderedMapIterator it = makeFullOrderedMapIterator();
   6:         Map map = getMap();
   7: 
   8:         ...
   9:             assertSame("it.next() should equals getKey()", key, it.getKey());
  10:             assertTrue("Key must be in map", map.containsKey(key));
  11:             assertTrue("Key must be unique", set.add(key));
  12:         ...
  13:             assertSame("it.previous() should equals getKey()", key, it.getKey());
  14:             assertTrue("Key must be in map", map.containsKey(key));

View Full Code Here

containsValue

public boolean containsValue(Object value)
Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==null ? v==null : value.equals(v)). This operation will probably require time linear in the map size for most implementations of the Map interface.
Parameters:
value - value whose presence in this map is to be tested.
Returns:
true if this map maps one or more keys to the specified value.
Throws:
ClassCastException - if the value is of an inappropriate type for this map (optional).
NullPointerException - if the value is null and this map does not permit null values (optional).
Usages and Demos :

View More Examples of containsValue(Object value)
   1: class GenericCollection extends AbstractCollection {
   2:     private Map map;
   3:     private Vector keys;
   4:         ...
   5: 
   6:     GenericCollection(Vector keys, Map map) {
   7:         this.keys = keys;
   8:         ...
   9:     public boolean contains(Object o) {
  10:         return map.containsValue(o);
  11:     }
  12:         ...
  13:         while (iter.hasNext()) {
  14:             if (!map.containsValue(iter.next())) {

View Full Code Here
   1: 
   2: import java.util.Map;
   3: 
   4:         ...
   5:         Object value = _valueValueFunction.execute(executeFunctionArgs);
   6:         Map map = (Map) _hashTableFunction.execute(executeFunctionArgs);
   7: 
   8:         ...
   9: 
  10:         return map.containsValue(value);
  11:     }

View Full Code Here
   1:     rsp = Collections2.rsp;
   2:   public static void tiskKlicu(Map m) {
   3:     System.out.print("Velikost = " + m.size() +", ");
   4:         ...
   5:   }
   6:   public static void tiskHodnot(Map m) {
   7:     System.out.print("Hodnoty: ");
   8:         ...
   9:   }
  10:   public static void test(Map m) {
  11:     Collections2.fill(m, geo, 25);
  12:         ...
  13:       + hodnota + "\"): " + 
  14:       m.containsValue(hodnota)); 

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5: 
   6:     private Map fInformationControls= new HashMap();
   7: 
   8:         ...
   9:     public boolean canReuse(IInformationControl control) {
  10:         return fInformationControls.containsValue(control);
  11:     }

View Full Code Here
   1: 
   2: public class CollationKeyMap implements Map, Serializable {
   3:         ...
   4:     private Map map;
   5:     private Locale locale;
   6:         ...
   7:     public boolean containsValue(Object value) {
   8:         return map.containsValue(value);
   9:     }

View Full Code Here

equals

public boolean equals(Object o)
Compares the specified object with this map for equality. Returns true if the given object is also a map and the two Maps represent the same mappings. More formally, two maps t1 and t2 represent the same mappings if t1.entrySet().equals(t2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.
Overrides:
equals in interface Object
Parameters:
o - object to be compared for equality with this map.
Returns:
true if the specified object is equal to this map.
Usages and Demos :

View More Examples of equals(Object o)
   1: import java.util.AbstractMap;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: {
   6:     private Map _inner;
   7: 
   8:         ...
   9:     {
  10:         return _inner.equals(o);
  11:     }
  12:         ...
  13: 
  14:     public void setInner(Map map)

View Full Code Here
   1: import java.util.List;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: 
   6: public class ContentVersionBean implements Map {
   7:         ...
   8:     private Map delegate = new HashMap();
   9:     
  10:         ...
  11:     public Set entrySet() { return delegate.entrySet(); }
  12:     public boolean equals(Object o) { return delegate.equals(o); }

View Full Code Here
   1: import edu.emory.mathcs.backport.java.util.concurrent.locks.*;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: 
   6: public class SMap implements Map {
   7:         ...
   8:     private final Map m;
   9:     public SMap(Map m) {
  10:         ...
  11:     public synchronized boolean equals(Object o) {
  12:         return m.equals(o);

View Full Code Here
   1: {
   2:     private Map                map = new HashMap();
   3: 
   4:         ...
   5:     {
   6:         map.clear();
   7:     }
   8:         ...
   9:     {
  10:         return map.containsKey(key);
  11:     }
  12:         ...
  13:     {
  14:         return map.equals(o);

View Full Code Here
   1: import java.util.List;
   2: import java.util.Map;
   3: 
   4:         ...
   5: public abstract class ChoicePermission extends Permission {
   6:   private Map attributes;
   7: 
   8:         ...
   9: 
  10:   public ChoicePermission(String name, String description, Map attributes) {
  11:     super(name, description);
  12:         ...
  13:     return super.equalContents(obj) &&
  14:     attributes.equals(((ChoicePermission)obj).attributes);

View Full Code Here

get

public V get(Object key)
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

Parameters:
key - key whose associated value is to be returned.
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for this key.
Throws:
ClassCastException - if the key is of an inappropriate type for this map (optional).
NullPointerException - if the key is null and this map does not permit null keys (optional).
Usages and Demos :

View More Examples of get(Object key)
   1: 
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5:     public void testPutGet() throws Exception {
   6:         Map map = new CollationKeyMap(Locale.GERMANY, Collator.SECONDARY);
   7:         map.put("Hello", "Hello");
   8:         ...
   9:         assertNotNull("Failed to get item from map.", map.get("hellO"));
  10:     }
  11:         ...
  12:         map.put("?berm??ig", "Hello");
  13:         assertNotNull("Failed to get item from map.", map.get("ubermassig"));

View Full Code Here
   1: 
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5:     public void testPutGet() throws Exception {
   6:         Map map = new CaseInsensitiveMap();
   7:         map.put("Hello", "Hello");
   8:         ...
   9:         assertNotNull("Failed to get item from map.", map.get("hellO"));
  10:     }
  11:         ...
  12:         map.put("Java", "zweiter Eintrag");
  13:         assertEquals("zweiter Eintrag", map.get("java"));

View Full Code Here
   1: 
   2: import java.util.Map;
   3: 
   4:         ...
   5:     {
   6:         Map map = getClientCache();
   7:         ...
   8:         return map != null ? map.get(key) : null;
   9:     }

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5:     {
   6:         Map map = getClientCache();
   7:         ...
   8:         return map != null ? (Resource) map.get(resourceKey) : null;
   9:     }

View Full Code Here
   1: 
   2: import java.util.Map;
   3: 
   4:         ...
   5:     private Value value;
   6:     private final Map meta;
   7: 
   8:         ...
   9: 
  10:     public Record(Key key, Value value, Map meta) {
  11:         this.key = key;
  12:         ...
  13:     public Object getMetaData(Object name) {
  14:         return meta != null ? meta.get(name) : null;

View Full Code Here

hashCode

public int hashCode()
Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hashCodes of each entry in the map's entrySet view. This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two maps t1 and t2, as required by the general contract of Object.hashCode.
Overrides:
hashCode in interface Object
Returns:
the hash code value for this map.
Usages and Demos :

View More Examples of hashCode()
   1: import java.util.Collection;
   2: import java.util.Map;
   3: import java.util.Properties;
   4:         ...
   5:     
   6:     private Map delegate;
   7: 
   8:         ...
   9:     public PersistentMapDecorator( Map delegate )
  10:     {
  11:         ...
  12:     {
  13:         return delegate.hashCode();

View Full Code Here
   1: import java.util.AbstractMap;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: {
   6:     private Map _inner;
   7: 
   8:         ...
   9:     {
  10:         return _inner.hashCode();
  11:     }
  12:         ...
  13: 
  14:     public void setInner(Map map)

View Full Code Here
   1: import java.util.List;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: 
   6: public class ContentVersionBean implements Map {
   7:         ...
   8:     private Map delegate = new HashMap();
   9:     
  10:         ...
  11:     public boolean equals(Object o) { return delegate.equals(o); }
  12:     public int hashCode() { return delegate.hashCode(); }

View Full Code Here
   1: public class ShopcartModel implements Serializable {
   2:     private Map coffeeQuantities = new HashMap();
   3: 
   4:         ...
   5:     public int hashCode() {
   6:         return coffeeQuantities.hashCode();
   7:     }
   8: 
   9:     public String toString() {

View Full Code Here
   1: import edu.emory.mathcs.backport.java.util.concurrent.locks.*;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: 
   6: public class SMap implements Map {
   7:         ...
   8:     private final Map m;
   9:     public SMap(Map m) {
  10:         ...
  11:     public synchronized int hashCode() {
  12:         return m.hashCode();

View Full Code Here

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.
Returns:
true if this map contains no key-value mappings.
Usages and Demos :

View More Examples of isEmpty()
   1:     private List urlsChecked;
   2:     private Map failedLinks;
   3:     private String domainName;
   4:         ...
   5:             "Failed links (from => to): " + failedLinks.toString(),
   6:             failedLinks.isEmpty());
   7:     }
   8: 
   9:     private void checkAllLinksOnPage(Page page) throws IOException {

View Full Code Here
   1:     
   2:     private Map changedResources = new HashMap();
   3:     private Set removedResources = new HashSet();
   4:         ...
   5:     private Map addedResources = new HashMap();
   6:     
   7:         ...
   8:     public boolean isEmpty() {
   9:         return changedResources.isEmpty() && removedResources.isEmpty() && addedResources.isEmpty() && errors.isEmpty();
  10:     }

View Full Code Here
   1:     
   2:     private Map changedResources = new HashMap();
   3:     private Set removedResources = new HashSet();
   4:         ...
   5:     private Map addedResources = new HashMap();
   6:     
   7:         ...
   8:     public boolean isEmpty() {
   9:         return changedResources.isEmpty() && removedResources.isEmpty() && addedResources.isEmpty();
  10:     }

View Full Code Here
   1:         Set removed = new HashSet();
   2:         Map changed = new HashMap();
   3:         private final BatchingChangeSetManager collector;
   4:         ...
   5:         public boolean isEmpty() {
   6:             return changed.isEmpty() && added.isEmpty() && removed.isEmpty();
   7:         }
   8:         ...
   9:     private void fireChanges(final IProgressMonitor monitor) {
  10:         if (changes.isEmpty()) {
  11:             return;

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5:     private Cache backingCache;
   6:     private Map localChanges;
   7:         ...
   8:     private Map localRemoves;
   9:     private boolean clear;
  10:         ...
  11:     public boolean isModifiedInTransaction() {
  12:         return clear || !localChanges.isEmpty() || !localRemoves.isEmpty();

View Full Code Here

keySet

public Set keySet()
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.
Returns:
a set view of the keys contained in this map.
Usages and Demos :

View More Examples of keySet()
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5:     {
   6:         Map map = getClientCache();
   7:         return map != null ? (Resource) map.get(resourceKey) : null;
   8:         ...
   9:         Map map = getClientCache();
  10:         return map != null ? map.keySet().iterator() : Collections.EMPTY_LIST
  11:             .iterator();

View Full Code Here
   1: import java.util.ListIterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5: 
   6:     private Map _attributeNameMappingMap = new HashMap();
   7: 
   8:         ...
   9:             _errorHandler.error(LOG, ParseMessages.extraMappings(
  10:                     _attributeNameMappingMap.keySet(),
  11:                     _elementModel), _elementModel.getLocation(), null);

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5:     super(name);
   6:     Map map = createMap(Collections.EMPTY_MAP);    
   7:     if (map instanceof XMap)
   8:         ...
   9:       this.keyType = classTypeID(((XMap) map).keySet().getComponentType());
  10:     else
  11:         ...
  12:     
  13:     for (Object k : mappings.keySet())

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: import java.util.Properties;
   4:         ...
   5:     
   6:     public static Object evaluateExpression(String exp, String[] imports, Map params) throws Exception
   7:     {
   8:         ...
   9:         ITerm term = parser.parseExpression(exp, 
  10:             params!=null? SUtil.arrayToList(params.keySet().toArray()): null);
  11:         return term.getValue(params);
  12:         ...
  13:                 System.out.println("\n"+args[i]);
  14:                 Map    params    = new HashMap();

View Full Code Here
   1: 
   2:     private final Map oldValues;
   3:         ...
   4:     private final Map newValues;
   5: 
   6:         ...
   7:     public NodeEvent(String machineName, String builderName, int nodeNumber, Map oldValues, Map newValues, int eventType ){
   8:         super(machineName, eventType);
   9:         ...
  10:         case TYPE_NEW:
  11:             return newValues.keySet();

View Full Code Here

put

public V put(K key,
             V value)
Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for this key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.))
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
Throws:
UnsupportedOperationException - if the put operation is not supported by this map.
ClassCastException - if the class of the specified key or value prevents it from being stored in this map.
IllegalArgumentException - if some aspect of this key or value prevents it from being stored in this map.
NullPointerException - if this map does not permit null keys or values, and the specified key or value is null.
Usages and Demos :

View More Examples of put(K key,V value)
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5:     {
   6:         Map map = getClientCache();
   7:         return map != null ? (Resource) map.get(resourceKey) : null;
   8:         ...
   9:         Map map = getClientCache();
  10:         return map != null ? (Resource) map.put(resourceKey, resource) : null;
  11:     }

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5:     int hashCode =0;
   6:     Map parameterMap = new HashMap();
   7:     
   8:         ...
   9:     public IndexQuery setParameter(String name, Object value){
  10:         parameterMap.put(name, value);
  11:         return this;
  12:         ...
  13:     public IndexQuery setParameter(int parameter, Object value){
  14:         parameterMap.put(""+parameter, value);

View Full Code Here
   1: import java.util.LinkedList;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: 
   6:     private static final Map negations = new HashMap();
   7:     
   8:         ...
   9:         
  10:         negations.put("and", "or");
  11:         ...
  12:         negations.put("or", "and");

View Full Code Here
   1: import java.util.LinkedList;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5:     
   6:     private static final Map negations = new HashMap();
   7:     
   8:         ...
   9:         
  10:         negations.put("and", "or");
  11:         ...
  12:         negations.put("or", "and");

View Full Code Here
   1:                     
   2:                     Map    dl_state = (Map)download.getDownload().getData( channel_key );
   3:                     
   4:         ...
   5:                     
   6:                     dl_state.put( ""+channel_id, "" );
   7:                 }
   8:         ...
   9:             
  10:             Map    dl_state = (Map)download.getDownload().getData( channel_key );
  11:             

View Full Code Here

putAll

public void putAll(extends K,
                   V> t)
Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is unspecified if the specified map is modified while the operation is in progress.
Parameters:
t - Mappings to be stored in this map.
Throws:
UnsupportedOperationException - if the putAll method is not supported by this map.
ClassCastException - if the class of a key or value in the specified map prevents it from being stored in this map.
IllegalArgumentException - some aspect of a key or value in the specified map prevents it from being stored in this map.
NullPointerException - if the specified map is null, or if this map does not permit null keys or values, and the specified map contains null keys or values.
Usages and Demos :

View More Examples of putAll(extends K,V> t)
   1: import java.util.HashSet;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5: 
   6:     public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration) throws CoreException {
   7:         return getWorkspaceBundleMap(configuration, null);
   8:         ...
   9:     
  10:     public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration, Set set) throws CoreException {
  11:         Map map = new HashMap();
  12:         ...
  13:         Map map = getWorkspaceBundleMap(configuration, set);
  14:         map.putAll(getTargetBundleMap(configuration, set));        

View Full Code Here
   1: import java.util.List;
   2: import java.util.Map;
   3: 
   4:         ...
   5: 
   6:     private Map paramMap;
   7:     private Principal principal = null;
   8:         ...
   9:         
  10:         paramMap.putAll(PathParser.parsePathParameters(PortalControlURL.IG, req.getServletPath(), false));
  11: 
  12:         ...
  13:     
  14:     public Map getParameterMap() 

View Full Code Here
   1: 
   2:     Map options = new HashMap(13);
   3:     options.put("debug", "true");
   4:         ...
   5:     options.putAll(getHttpsOptions(httpsPort, cip));
   6: 
   7:         ...
   8: 
   9:   private static Map getHttpsOptions(
  10:       int httpsPort, String cip) {
  11:         ...
  12:     Map httpsOptions;

View Full Code Here
   1:     private HttpServletRequest req = null;
   2:     private Map renderParams = null;
   3:         ...
   4:     private Map persistParams = null;
   5:         ...
   6:     private Map params = null;
   7:     private String targetedCid = null;
   8:         ...
   9: 
  10:         renderParams.putAll(parseQueryString(queryString, true));

View Full Code Here
   1: 
   2:         Map params = new HashMap();
   3:         String context =  ((javax.servlet.http.HttpServletRequest)pageContext.getRequest()).getContextPath();
   4:         ...
   5:         }
   6:         params.putAll(Referids.getReferids(referids, this));
   7:         Iterator i = extraParameters.iterator();
   8:         ...
   9:         while (i.hasNext()) {
  10:             Map.Entry entry = (Map.Entry) i.next();
  11:             params.put(entry.getKey(), entry.getValue());

View Full Code Here

remove

public V remove(Object key)
Removes the mapping for this key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that (key==null ? k==null : key.equals(k)), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which the map previously associated the key, or null if the map contained no mapping for this key. (A null return can also indicate that the map previously associated null with the specified key if the implementation supports null values.) The map will not contain a mapping for the specified key once the call returns.

Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or null if there was no mapping for key.
Throws:
ClassCastException - if the key is of an inappropriate type for this map (optional).
NullPointerException - if the key is null and this map does not permit null keys (optional).
UnsupportedOperationException - if the remove method is not supported by this map.
Usages and Demos :

View More Examples of remove(Object key)
   1: 
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5:     public void testPutGet() throws Exception {
   6:         Map map = new CollationKeyMap(Locale.GERMANY, Collator.SECONDARY);
   7:         map.put("Hello", "Hello");
   8:         ...
   9:         map.put("Hello", "Hello");
  10:         assertNotNull("Failed to get item from map.", map.remove("hellO"));
  11:     }

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5: 
   6:         Map params = new HashMap();
   7:         params.put("1", new Integer(1));
   8:         ...
   9: 
  10:         Map params = new HashMap();
  11:         params.put("1", new Integer(1));
  12:         ...
  13: 
  14:         params.remove("4");

View Full Code Here
   1: 
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5:     public void testPutGet() throws Exception {
   6:         Map map = new CaseInsensitiveMap();
   7:         map.put("Hello", "Hello");
   8:         ...
   9:         map.put("Hello", "Hello");
  10:         assertNotNull("Failed to get item from map.", map.remove("hellO"));
  11:     }

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5:     {
   6:         Map map = getClientCache();
   7:         return map != null ? (Resource) map.get(resourceKey) : null;
   8:         ...
   9:         Map map = getClientCache();
  10:         return map != null ? (Resource) map.remove(resourceKey) : null;
  11:     }

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5:     private static final long serialVersionUID = 1L;
   6:     private Map fProperties;
   7: 
   8:         ...
   9:         if (value == null || value.trim().length() == 0)
  10:             fProperties.remove(key);
  11:         else 
  12:         ...
  13:     
  14:     public void load(Map properties) {

View Full Code Here

size

public int size()
Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
Returns:
the number of key-value mappings in this map.
Usages and Demos :

View More Examples of size()
   1: 
   2: import java.util.Map;
   3: 
   4:         ...
   5:   public void mainCheck() {
   6:     Map numbers = FactoryTest2.getNumbers();
   7:     assert null != numbers.get(new Integer(42))
   8:         ...
   9:       : "Didn't find 43";
  10:     assert 2 == numbers.size()
  11:         ...
  12:       : "Expected 2 numbers, found " + (numbers.size());

View Full Code Here
   1: import java.util.HashMap;
   2: import java.util.Map;
   3: 
   4:         ...
   5:     {
   6:         Map outputs = executeWorkflow("XMLSplitterArrays", new HashMap(), defaultWorkflowEventListener());
   7:         ...
   8:         assertEquals("wrong number of outputs",1,outputs.size());
   9:         DataThing output = (DataThing) outputs.get("out");

View Full Code Here
   1: 
   2: import java.util.Map;
   3: 
   4:         ...
   5:     private final String publicationOutputLabel;
   6:     private final Map publicationProperties;
   7: 
   8:         ...
   9:     public PublicationSpec(String publicationTypeName, String publicationOutputName, String publicationOutputLabel, Map properties) {
  10:         if (publicationTypeName == null)
  11:         ...
  12: 
  13:         Map.Entry[] entries = (Map.Entry[])publicationProperties.entrySet().toArray(new Map.Entry[publicationProperties.size()]);

View Full Code Here
   1: import java.io.DataOutputStream;
   2: import java.util.Map;
   3: import java.util.Properties;
   4:         ...
   5: 
   6:         if(props.size() > 0) {
   7:             log.error("the following properties are not recognized: " + props);
   8:         ...
   9:                 out.flush();
  10:                 return out_stream.size();
  11:             }
  12:         ...
  13:             return 0;
  14:         Map hdrs=msg.getHeaders();

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5:         
   6:         Map queries = (Map)PrivilegedAccessor.getValue(qd, "QUERIES");
   7: 
   8:         ...
   9:         assertEquals("should not be any queries", 0, queries.size());
  10: 
  11:         ...
  12:         Thread.sleep(3000);
  13:         assertEquals("unexpected queries size", 1, queries.size());

View Full Code Here

values

public Collection values()
Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
Returns:
a collection view of the values contained in this map.
Usages and Demos :

View More Examples of values()
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5:                 new Object[] { sourceLayerDescription()});
   6:         Map layerToSpecifiedFeaturesMap = layerToSpecifiedFeaturesMap();
   7:         if (layerToSpecifiedFeaturesMap.isEmpty()) {
   8:         ...
   9:     public static UndoableCommand createUndoableCommand(String name,
  10:             SourceState state, Map layerToSpecifiedFeaturesMap,
  11:             ToolboxModel toolboxModel, ErrorHandler errorHandler) {
  12:         ...
  13:         for (Iterator i = CollectionUtil.concatenate(
  14:                 layerToSpecifiedFeaturesMap.values()).iterator(); i.hasNext();) {

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: 
   4:         ...
   5: public final class ColMap extends Col {
   6:     private Map _item;
   7: 
   8:         ...
   9:         if ((_item == null) || (_item.size() == 0)) { return false; }
  10:         return _item.values().contains(item);
  11:     }
  12:         ...
  13:         if ((_item == null) || (_item.size() == 0)) { return EMPTY_ITORATOR; }
  14:         return _item.values().iterator();

View Full Code Here
   1: 
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5: 
   6:     private Map _item;
   7: 
   8:         ...
   9: 
  10:         return _item.values().contains( item );
  11:     }
  12:         ...
  13: 
  14:         return _item.values().iterator();

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: import java.util.Set;
   4:         ...
   5:     super(name);
   6:     Map map = createMap(Collections.EMPTY_MAP);    
   7:     if (map instanceof XMap)
   8:         ...
   9:     
  10:     for (Object v : mappings.values())
  11:     {
  12:         ...
  13:       assertTrue(map.containsValue(v));
  14:       assertTrue(map.values().contains(v));

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.Map;
   3: import java.util.HashMap;
   4:         ...
   5:         ClassInfo annotationClassInfo = AsmClassInfo.getClassInfo(annotationClassName, loader);
   6:         Map annotationElementValueHoldersByName = new HashMap();
   7: 
   8:         ...
   9:                     new Java5AnnotationInvocationHandler(annotationClassName,
  10:                                                          annotationElementValueHoldersByName.values()
  11:                     )

View Full Code Here