java.util
Class Collections.UnmodifiableMap.UnmodifiableEntrySet
java.lang.Object
|
+--java.util.Collections.UnmodifiableCollection
|
+--java.util.Collections.UnmodifiableSet
|
+--java.util.Collections.UnmodifiableMap.UnmodifiableEntrySet
- static class Collections.UnmodifiableMap.UnmodifiableEntrySet
- extends Collections.UnmodifiableSet
We need this class in addition to UnmodifiableSet as
Map.Entries themselves permit modification of the backing Map
via their setValue operation. This class is subtle: there are
many possible attacks that must be thwarted.
- See Also:
- Serialized Form
Inner Class Summary |
private static class |
Collections.UnmodifiableMap.UnmodifiableEntrySet.UnmodifiableEntry
This "wrapper class" serves two purposes: it prevents
the client from modifying the backing Map, by short-circuiting
the setValue method, and it protects the backing Map against
an ill-behaved Map.Entry that attempts to modify another
Map Entry when asked to perform an equality check. |
Method Summary |
boolean |
contains(Object o)
This method is overridden to protect the backing set against
an object with a nefarious equals function that senses
that the equality-candidate is Map.Entry and calls its
setValue method. |
boolean |
containsAll(Collection coll)
The next two methods are overridden to protect against
an unscrupulous List whose contains(Object o) method senses
when o is a Map.Entry, and calls o.setValue. |
boolean |
equals(Object o)
|
Iterator |
iterator()
|
Object[] |
toArray()
|
Object[] |
toArray(Object[] a)
|
Methods inherited from class java.lang.Object |
,
clone,
finalize,
getClass,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
Collections.UnmodifiableMap.UnmodifiableEntrySet
Collections.UnmodifiableMap.UnmodifiableEntrySet(Set s)
iterator
public Iterator iterator()
- Overrides:
- iterator in class Collections.UnmodifiableCollection
toArray
public Object[] toArray()
- Overrides:
- toArray in class Collections.UnmodifiableCollection
toArray
public Object[] toArray(Object[] a)
- Overrides:
- toArray in class Collections.UnmodifiableCollection
contains
public boolean contains(Object o)
- This method is overridden to protect the backing set against
an object with a nefarious equals function that senses
that the equality-candidate is Map.Entry and calls its
setValue method.
- Overrides:
- contains in class Collections.UnmodifiableCollection
containsAll
public boolean containsAll(Collection coll)
- The next two methods are overridden to protect against
an unscrupulous List whose contains(Object o) method senses
when o is a Map.Entry, and calls o.setValue.
- Overrides:
- containsAll in class Collections.UnmodifiableCollection
equals
public boolean equals(Object o)
- Overrides:
- equals in class Collections.UnmodifiableSet