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.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) {
27 * Constructs a new buffer cache of the given size.
29 public BufferCache(int size, int overflow) {
30 super(size, overflow);
33 * Returns true if the buffer is successfully closed and
34 * removed from the cache, otherwise false.
36 * <p>NOTE: this triggers an external removal of this buffer
37 * by closing the buffer.
39 protected boolean close(LRUCacheEntry entry) {
40 IBuffer buffer= (IBuffer) entry._fValue;
41 if (buffer.hasUnsavedChanges()) {
49 * Returns a new instance of the reciever.
51 protected LRUCache newInstance(int size, int overflow) {
52 return new BufferCache(size, overflow);