|
|||||||||
| Home >> All >> org >> apache >> axis >> [ collections overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.axis.collections
Class LRUMap

java.lang.Objectorg.apache.axis.collections.SequencedHashMap
org.apache.axis.collections.LRUMap
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Externalizable, java.util.Map, java.io.Serializable
- public class LRUMap
- extends SequencedHashMap
- implements java.io.Externalizable
- extends SequencedHashMap
An implementation of a Map which has a maximum size and uses a Least Recently Used algorithm to remove items from the Map when the maximum size is reached and new items are added.
A synchronized version can be obtained with:
Collections.synchronizedMap( theMapToSynchronize )
If it will be accessed by multiple threads, you _must_ synchronize access
to this Map. Even concurrent get(Object) operations produce indeterminate
behaviour.
Unlike the Collections 1.0 version, this version of LRUMap does use a true LRU algorithm. The keys for all gets and puts are moved to the front of the list. LRUMap is now a subclass of SequencedHashMap, and the "LRU" key is now equivalent to LRUMap.getFirst().
- Since:
- Commons Collections 1.0
| Nested Class Summary |
| Nested classes inherited from class org.apache.axis.collections.SequencedHashMap |
|
| Field Summary | |
private int |
maximumSize
|
private static long |
serialVersionUID
|
| Fields inherited from class org.apache.axis.collections.SequencedHashMap |
|
| Constructor Summary | |
LRUMap()
Default constructor, primarily for the purpose of de-externalization. |
|
LRUMap(int i)
Create a new LRUMap with a maximum capacity of i. |
|
| Method Summary | |
java.lang.Object |
get(java.lang.Object key)
Get the value for a key from the Map. |
int |
getMaximumSize()
Getter for property maximumSize. |
protected void |
processRemovedLRU(java.lang.Object key,
java.lang.Object value)
Subclasses of LRUMap may hook into this method to provide specialized actions whenever an Object is automatically removed from the cache. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Removes the key and its Object from the Map. |
void |
readExternal(java.io.ObjectInput in)
This method restores an object's state by reading in the instance data for the object from the passed in stream. |
protected void |
removeLRU()
This method is used internally by the class for finding and removing the LRU Object. |
void |
setMaximumSize(int maximumSize)
Setter for property maximumSize. |
void |
writeExternal(java.io.ObjectOutput out)
This method is responsible for writing the instance data of an object to the passed in stream. |
| Methods inherited from class org.apache.axis.collections.SequencedHashMap |
clear, clone, containsKey, containsValue, entrySet, equals, get, getFirst, getFirstKey, getFirstValue, getLast, getLastKey, getLastValue, getValue, hashCode, indexOf, isEmpty, iterator, keySet, lastIndexOf, putAll, remove, remove, sequence, size, toString, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
maximumSize
private int maximumSize
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
| Constructor Detail |
LRUMap
public LRUMap()
- Default constructor, primarily for the purpose of
de-externalization. This constructors sets a default
LRU limit of 100 keys, but this value may be overridden
internally as a result of de-externalization.
LRUMap
public LRUMap(int i)
- Create a new LRUMap with a maximum capacity of i.
Once i capacity is achieved, subsequent gets
and puts will push keys out of the map. See .
| Method Detail |
get
public java.lang.Object get(java.lang.Object key)
Get the value for a key from the Map. The key will be promoted to the Most Recently Used position. Note that get(Object) operations will modify the underlying Collection. Calling get(Object) inside of an iteration over keys, values, etc. is currently unsupported.
- Specified by:
getin interfacejava.util.Map- Overrides:
getin classSequencedHashMap
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
Removes the key and its Object from the Map.
(Note: this may result in the "Least Recently Used" object being removed from the Map. In that case, the removeLRU() method is called. See javadoc for removeLRU() for more details.)
- Specified by:
putin interfacejava.util.Map- Overrides:
putin classSequencedHashMap
removeLRU
protected void removeLRU()
- This method is used internally by the class for
finding and removing the LRU Object.
processRemovedLRU
protected void processRemovedLRU(java.lang.Object key, java.lang.Object value)
- Subclasses of LRUMap may hook into this method to
provide specialized actions whenever an Object is
automatically removed from the cache. By default,
this method does nothing.
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Description copied from interface:
java.io.Externalizable - This method restores an object's state by reading in the instance data
for the object from the passed in stream. Note that this stream is not
a subclass of
InputStream, but rather is a class that implements theObjectInputinterface. That interface provides a mechanism for reading in Java data types from a stream.Note that this method must be compatible with
writeExternal. It must read back the exact same types that were written by that method in the exact order they were written.If this method needs to read back an object instance, then the class for that object must be found and loaded. If that operation fails, then this method throws a
ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classSequencedHashMap
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Description copied from interface:
java.io.Externalizable - This method is responsible for writing the instance data of an object
to the passed in stream. Note that this stream is not a subclass of
OutputStream, but rather is a class that implements theObjectOutputinterface. That interface provides a number of methods for writing Java data values to a stream.Not that the implementation of this method must be coordinated with the implementation of
readExternal.- Specified by:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classSequencedHashMap
getMaximumSize
public int getMaximumSize()
- Getter for property maximumSize.
setMaximumSize
public void setMaximumSize(int maximumSize)
- Setter for property maximumSize.
|
|||||||||
| Home >> All >> org >> apache >> axis >> [ collections overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC