| 1 | package java.util; |
| 2 | |
| 3 | public abstract class AbstractMap |
| 4 | implements Map |
| 5 | { |
| 6 | |
| 7 | protected AbstractMap() |
| 8 | { |
| 9 | } |
| 10 | |
| 11 | public int size() |
| 12 | { |
| 13 | return entrySet().size(); |
| 14 | } |
| 15 | |
| 16 | public boolean isEmpty() |
| 17 | { |
| 18 | return size() == 0; |
| 19 | } |
| 20 | |
| 21 | public boolean containsValue(Object value) |
| 22 | { |
| 23 | Iterator it = entrySet().iterator(); |
| 24 | while (it.hasNext()) |
| 25 | { |
| 26 | Map.Entry v = (Map.Entry)it.next(); |
| 27 | if (value == null) |
| 28 | { |
| 29 | if (v.getValue() == null) |
| 30 | { |
| 31 | return true; |
| 32 | } |
| 33 | } |
| 34 | else |
| 35 | { |
| 36 | if (value.equals(v.getValue())) |
| 37 | { |
| 38 | return true; |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | public boolean containsKey(Object key) |
| 46 | throws ClassCastException, NullPointerException |
| 47 | { |
| 48 | Iterator it = entrySet().iterator(); |
| 49 | while (it.hasNext()) |
| 50 | { |
| 51 | Map.Entry v = (Map.Entry)it.next(); |
| 52 | if (key == null) |
| 53 | { |
| 54 | if (v.getKey() == null) |
| 55 | { |
| 56 | return true; |
| 57 | } |
| 58 | } |
| 59 | else |
| 60 | { |
nothing calls this directly
no outgoing calls
no test coverage detected