1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
13 import net.sourceforge.phpdt.core.IBuffer;
14 import net.sourceforge.phpdt.internal.core.util.LRUCache;
17 * An LRU cache of <code>IBuffers</code>.
19 public class BufferCache extends OverflowingLRUCache {
21 * Constructs a new buffer cache of the given size.
23 public BufferCache(int size) {
28 * Constructs a new buffer cache of the given size.
30 public BufferCache(int size, int overflow) {
31 super(size, overflow);
35 * Returns true if the buffer is successfully closed and removed from the
36 * cache, otherwise false.
39 * NOTE: this triggers an external removal of this buffer by closing the
42 protected boolean close(LRUCacheEntry entry) {
43 IBuffer buffer = (IBuffer) entry._fValue;
44 if (buffer.hasUnsavedChanges()) {
53 * Returns a new instance of the reciever.
55 protected LRUCache newInstance(int size, int overflow) {
56 return new BufferCache(size, overflow);