org.apache.derby.client.am.stmtcache
Class JDBCStatementCache.BoundedLinkedHashMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap
              extended by org.apache.derby.client.am.stmtcache.JDBCStatementCache.BoundedLinkedHashMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map
Enclosing class:
JDBCStatementCache

private static class JDBCStatementCache.BoundedLinkedHashMap
extends java.util.LinkedHashMap

A LinkedHashMap with an upper bound on the number of entries.

If the maximum size is exceeded, the oldest entry is automatically removed after the new entry has been inserted.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
private  int maxSize
          Maximum number of entries.
 
Constructor Summary
JDBCStatementCache.BoundedLinkedHashMap(int maxCapacity)
          Creates a bounded LinkedHashMap with the specified maximum size.
 
Method Summary
protected  boolean removeEldestEntry(java.util.Map.Entry eldest)
          Tells if an entry should be removed from the map.
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Field Detail

maxSize

private final int maxSize
Maximum number of entries.

Constructor Detail

JDBCStatementCache.BoundedLinkedHashMap

public JDBCStatementCache.BoundedLinkedHashMap(int maxCapacity)
Creates a bounded LinkedHashMap with the specified maximum size.

Iteration is by insertion-order.

Parameters:
maxCapacity - maximum size of the map
Method Detail

removeEldestEntry

protected boolean removeEldestEntry(java.util.Map.Entry eldest)
Tells if an entry should be removed from the map.

If the cache has exceeded its maximum size, the oldest element will be marked for removal. The oldest element will be removed after the new element has been inserted.

Overrides:
removeEldestEntry in class java.util.LinkedHashMap
Parameters:
eldest - the element picked out for removal
Returns:
true if the element is to be removed, false if not.

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.