aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/core/src/main/j2me/java/util/AbstractMap.java
blob: 13c61ecfa69d80a133171679f06483786f5b9ea7 (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
165
166
167
168
169
170
171
172
173
package java.util;

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 RuntimeException
    {
        throw new RuntimeException();
    }

    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 RuntimeException("no keySet in AbstractMap()");
    }

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

    public abstract Set entrySet();

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

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

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


}