1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2000,2008 Oracle. All rights reserved. 5 * 6 * $Id: StoredMapEntry.java,v 12.7 2008/01/08 20:58:36 bostic Exp $ 7 */ 8 9package com.sleepycat.collections; 10 11/** 12 * @author Mark Hayes 13 */ 14final class StoredMapEntry extends MapEntryParameter { 15 16 private BaseIterator iter; 17 private StoredCollection coll; 18 19 StoredMapEntry(Object key, 20 Object 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 setValue(Object newValue) { 30 31 Object 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("May not insert duplicates"); 38 } 39 oldValue = coll.put(getKey(), newValue); 40 } 41 setValueInternal(newValue); 42 return oldValue; 43 } 44} 45