KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > collections > StoredMapEntry


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2000,2006 Oracle. All rights reserved.
5  *
6  * $Id: StoredMapEntry.java,v 1.16 2006/10/30 21:14:10 bostic Exp $
7  */

8
9 package com.sleepycat.collections;
10
11 /**
12  * @author Mark Hayes
13  */

14 final class StoredMapEntry extends MapEntryParameter {
15
16     private BaseIterator iter;
17     private StoredCollection coll;
18
19     StoredMapEntry(Object JavaDoc key,
20                    Object JavaDoc value,
21                    StoredCollection coll,
22                    BaseIterator iter) {
23
24         super(key, value);
25         this.coll = coll;
26         this.iter = iter;
27     }
28
29     public Object JavaDoc setValue(Object JavaDoc newValue) {
30
31         Object JavaDoc oldValue;
32         if (iter != null && iter.isCurrentData(this)) {
33             oldValue = getValue();
34             iter.set(newValue);
35         } else {
36             if (coll.view.dupsAllowed) {
37                 throw new IllegalStateException JavaDoc("May not insert duplicates");
38             }
39             oldValue = coll.put(getKey(), newValue);
40         }
41         setValueInternal(newValue);
42         return oldValue;
43     }
44 }
45
Popular Tags