Title: Description: Copyright: Copyright (c) 2001 Company: @version 1.0
| 9 | */ |
| 10 | |
| 11 | public abstract class AbstractMap implements Map{ |
| 12 | |
| 13 | protected AbstractMap() |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | public int size() |
| 18 | { |
| 19 | return entrySet().size(); |
| 20 | } |
| 21 | |
| 22 | public boolean isEmpty() |
| 23 | { |
| 24 | return size()==0; |
| 25 | } |
| 26 | |
| 27 | public boolean containsValue(Object value) |
| 28 | { |
| 29 | Iterator it=entrySet().iterator(); |
| 30 | while(it.hasNext()) |
| 31 | { |
| 32 | Map.Entry v=(Map.Entry)it.next(); |
| 33 | if(value==null) |
| 34 | { |
| 35 | if(v.getValue()==null) |
| 36 | return true; |
| 37 | } |
| 38 | else |
| 39 | { |
| 40 | if(value.equals(v.getValue())) |
| 41 | return true; |
| 42 | } |
| 43 | } |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | public boolean containsKey(Object key) throws ClassCastException,NullPointerException |
| 48 | { |
| 49 | Iterator it=entrySet().iterator(); |
| 50 | while(it.hasNext()) |
| 51 | { |
| 52 | Map.Entry v=(Map.Entry)it.next(); |
| 53 | if(key==null) |
| 54 | { |
| 55 | if(v.getKey()==null) |
| 56 | return true; |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | if(key.equals(v.getKey())) |
| 61 | return true; |
| 62 | } |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | public Object get(Object key)throws ClassCastException,NullPointerException |
| 68 | { |
nothing calls this directly
no outgoing calls
no test coverage detected