aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractMap.java
blob: d5b2e02e17e7c5e1c41d787e20008bd3b7aa7be4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package java.util;

/*************
 * Title:
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:
 * @version 1.0
 */

public abstract class AbstractMap implements Map{

  protected AbstractMap()
        {
    }

    public int size()
        {
            return entrySet().size();
        }

    public boolean isEmpty()
        {
            return size()==0;
        }

    public boolean containsValue(Object value)
        {
            Iterator it=entrySet().iterator();
            while(it.hasNext())
                {
                    Map.Entry v=(Map.Entry)it.next();
                    if(value==null)
                        {
                            if(v.getValue()==null)
                                return true;
                        }
                    else
                        {
                            if(value.equals(v.getValue()))
                                return true;
                        }
                }
            return false;
        }

    public boolean containsKey(Object key) throws ClassCastException,NullPointerException
        {
            Iterator it=entrySet().iterator();
            while(it.hasNext())
                {
                    Map.Entry v=(Map.Entry)it.next();
                    if(key==null)
                        {
                            if(v.getKey()==null)
                                return true;
                        }
                    else
                        {
                            if(key.equals(v.getKey()))
                                return true;
                        }
                }
            return false;
        }

    public Object get(Object key)throws ClassCastException,NullPointerException
        {
            Iterator it=entrySet().iterator();
            while(it.hasNext())
                {
                    Map.Entry v=(Map.Entry)it.next();
                    if(key==null)
                        {
                            if(v.getKey()==null)
                                return v.getValue();
                        }
                    else
                        {
                            if(key.equals(v.getKey()))
                                return v.getValue();
                        }
                }
            return null;
        }

    public Object put(Object key,Object value) throws UnsupportedOperationException
        {
            throw new UnsupportedOperationException();
        }

    public Object remove(Object key)
        {
            Iterator it=entrySet().iterator();
            Object o=null;
            while(it.hasNext())
                    {
                        Map.Entry v=(Map.Entry)it.next();
                        if(key==null)
                            {
                                if(v.getKey()==null)
                                    {
                                        o=v.getValue();
                                        it.remove();
                                        return o;
                                    }
                            }
                        else
                            {
                                if(key.equals(v.getKey()))
                                    {
                                        o=v.getValue();
                                        it.remove();
                                        return o;
                                    }
                            }
                    }
          return null;
        }

    public void putAll(Map t)
        {
            Iterator it=t.entrySet().iterator();
            while(it.hasNext())
                    {
                        Map.Entry v=(Map.Entry)it.next();
                        put(v.getKey(),v.getValue());
                    }
        }

    public void clear()
        {
            entrySet().clear();
        }

    public Set keySet()
        {
            throw new UnsupportedOperationException("no keySet in AbstractMap()");
        }

    public Collection values()
        {
            throw new UnsupportedOperationException("no values in AbstractMap()");
        }

    public abstract Set entrySet();

    public boolean equals(Object o)
        {
            throw new UnsupportedOperationException("no equals in AbstractMap()");
        }

    public int hashCode()
        {
            throw new UnsupportedOperationException("no hashCode in AbstractMap()");
        }

    public String toString()
        {
            throw new UnsupportedOperationException("no toString in AbstractMap()");
        }


}