01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2000,2008 Oracle. All rights reserved.
05: *
06: * $Id: StoredMapEntry.java,v 1.16.2.2 2008/01/07 15:14:06 cwl Exp $
07: */
08:
09: 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 key, Object value, StoredCollection coll,
20: BaseIterator iter) {
21:
22: super (key, value);
23: this .coll = coll;
24: this .iter = iter;
25: }
26:
27: public Object setValue(Object newValue) {
28:
29: Object oldValue;
30: if (iter != null && iter.isCurrentData(this )) {
31: oldValue = getValue();
32: iter.set(newValue);
33: } else {
34: if (coll.view.dupsAllowed) {
35: throw new IllegalStateException(
36: "May not insert duplicates");
37: }
38: oldValue = coll.put(getKey(), newValue);
39: }
40: setValueInternal(newValue);
41: return oldValue;
42: }
43: }
|