KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > keyvalue > UnmodifiableMapEntry


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.collections.keyvalue;
17
18 import java.util.Map JavaDoc;
19
20 import org.apache.commons.collections.KeyValue;
21 import org.apache.commons.collections.Unmodifiable;
22
23 /**
24  * A {@link java.util.Map.Entry} that throws UnsupportedOperationException
25  * when <code>setValue</code> is called.
26  *
27  * @since Commons Collections 3.0
28  * @version $Revision: 1.3 $ $Date: 2004/02/18 01:00:08 $
29  *
30  * @author Stephen Colebourne
31  */

32 public final class UnmodifiableMapEntry extends AbstractMapEntry implements Unmodifiable {
33     
34     /**
35      * Constructs a new entry with the specified key and given value.
36      *
37      * @param key the key for the entry, may be null
38      * @param value the value for the entry, may be null
39      */

40     public UnmodifiableMapEntry(final Object JavaDoc key, final Object JavaDoc value) {
41         super(key, value);
42     }
43
44     /**
45      * Constructs a new entry from the specified KeyValue.
46      *
47      * @param pair the pair to copy, must not be null
48      * @throws NullPointerException if the entry is null
49      */

50     public UnmodifiableMapEntry(final KeyValue pair) {
51         super(pair.getKey(), pair.getValue());
52     }
53
54     /**
55      * Constructs a new entry from the specified MapEntry.
56      *
57      * @param entry the entry to copy, must not be null
58      * @throws NullPointerException if the entry is null
59      */

60     public UnmodifiableMapEntry(final Map.Entry JavaDoc entry) {
61         super(entry.getKey(), entry.getValue());
62     }
63     
64     /**
65      * Throws UnsupportedOperationException.
66      *
67      * @param value the new value
68      * @return the previous value
69      * @throws UnsupportedOperationException always
70      */

71     public Object JavaDoc setValue(Object JavaDoc value) {
72         throw new UnsupportedOperationException JavaDoc("setValue() is not supported");
73     }
74
75 }
76
Popular Tags