Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

freemarker.template.utility
Class Collections12.SingletonMap  view Collections12.SingletonMap download Collections12.SingletonMap.java

java.lang.Object
  extended byjava.util.AbstractMap
      extended byfreemarker.template.utility.Collections12.SingletonMap
All Implemented Interfaces:
java.util.Map, java.io.Serializable
Enclosing class:
Collections12

private static class Collections12.SingletonMap
extends java.util.AbstractMap
implements java.io.Serializable


Nested Class Summary
private static class Collections12.SingletonMap.ImmutableEntry
           
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
private  java.util.Set entrySet
           
private  java.lang.Object k
           
private  java.util.Set keySet
           
private  java.lang.Object v
           
private  java.util.Collection values
           
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
(package private) Collections12.SingletonMap(java.lang.Object key, java.lang.Object value)
           
 
Method Summary
 boolean containsKey(java.lang.Object key)
          Returns true if this contains a mapping for the given key.
 boolean containsValue(java.lang.Object value)
          Returns true if this contains at least one mapping with the given value.
 java.util.Set entrySet()
          Returns a set view of the mappings in this Map.
 java.lang.Object get(java.lang.Object key)
          Returns the value mapped by the given key.
 boolean isEmpty()
          Returns true if the map contains no mappings.
 java.util.Set keySet()
          Returns a set view of this map's keys.
 int size()
          Returns the number of key-value mappings in the map.
 java.util.Collection values()
          Returns a collection or bag view of this map's values.
 
Methods inherited from class java.util.AbstractMap
clear, clone, equals, hashCode, put, putAll, remove, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

k

private final java.lang.Object k

v

private final java.lang.Object v

keySet

private transient java.util.Set keySet

entrySet

private transient java.util.Set entrySet

values

private transient java.util.Collection values
Constructor Detail

Collections12.SingletonMap

Collections12.SingletonMap(java.lang.Object key,
                           java.lang.Object value)
Method Detail

size

public int size()
Description copied from class: java.util.AbstractMap
Returns the number of key-value mappings in the map. If there are more than Integer.MAX_VALUE mappings, return Integer.MAX_VALUE. This is implemented as entrySet().size().

Specified by:
size in interface java.util.Map

isEmpty

public boolean isEmpty()
Description copied from class: java.util.AbstractMap
Returns true if the map contains no mappings. This is implemented by size() == 0.

Specified by:
isEmpty in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Description copied from class: java.util.AbstractMap
Returns true if this contains a mapping for the given key. This implementation does a linear search, O(n), over the entrySet(), returning true if a match is found, false if the iteration ends. Many subclasses can implement this more efficiently.

Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Description copied from class: java.util.AbstractMap
Returns true if this contains at least one mapping with the given value. This implementation does a linear search, O(n), over the entrySet(), returning true if a match is found, false if the iteration ends. A match is defined as a value, v, where (value == null ? v == null : value.equals(v)). Subclasses are unlikely to implement this more efficiently.

Specified by:
containsValue in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Description copied from class: java.util.AbstractMap
Returns the value mapped by the given key. Returns null if there is no mapping. However, in Maps that accept null values, you must rely on containsKey to determine if a mapping exists. This iteration takes linear time, searching entrySet().iterator() of the key. Many implementations override this method.

Specified by:
get in interface java.util.Map

keySet

public java.util.Set keySet()
Description copied from class: java.util.AbstractMap
Returns a set view of this map's keys. The set is backed by the map, so changes in one show up in the other. Modifications while an iteration is in progress produce undefined behavior. The set supports removal if entrySet() does, but does not support element addition.

This implementation creates an AbstractSet, where the iterator wraps the entrySet iterator, size defers to the Map's size, and contains defers to the Map's containsKey. The set is created on first use, and returned on subsequent uses, although since no synchronization occurs, there is a slight possibility of creating two sets.

Specified by:
keySet in interface java.util.Map

entrySet

public java.util.Set entrySet()
Description copied from class: java.util.AbstractMap
Returns a set view of the mappings in this Map. Each element in the set must be an implementation of Map.Entry. The set is backed by the map, so that changes in one show up in the other. Modifications made while an iterator is in progress cause undefined behavior. If the set supports removal, these methods must be valid: Iterator.remove, Set.remove, removeAll, retainAll, and clear. Element addition is not supported via this set.

Specified by:
entrySet in interface java.util.Map

values

public java.util.Collection values()
Description copied from class: java.util.AbstractMap
Returns a collection or bag view of this map's values. The collection is backed by the map, so changes in one show up in the other. Modifications while an iteration is in progress produce undefined behavior. The collection supports removal if entrySet() does, but does not support element addition.

This implementation creates an AbstractCollection, where the iterator wraps the entrySet iterator, size defers to the Map's size, and contains defers to the Map's containsValue. The collection is created on first use, and returned on subsequent uses, although since no synchronization occurs, there is a slight possibility of creating two collections.

Specified by:
values in interface java.util.Map