Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.greenstone.gatherer.msm.parsers
Class GreenstoneMetadataParser.CollectCFGCache  view GreenstoneMetadataParser.CollectCFGCache download GreenstoneMetadataParser.CollectCFGCache.java

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byjava.util.LinkedHashMap
              extended byorg.greenstone.gatherer.msm.parsers.GreenstoneMetadataParser.CollectCFGCache
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Enclosing class:
GreenstoneMetadataParser

private class GreenstoneMetadataParser.CollectCFGCache
extends java.util.LinkedHashMap

This class provides a cache for the instances of parsed collect.cfg files and their associated data. Assures that the most recently cached CollectCFG will remain available. Older objects are maintained as soft references and are freed at the JVM implementations descretion, but are gareunteed to be garbage collected before an OutOfMemory exception is thrown.


Nested Class Summary
 
Nested classes inherited from class java.util.LinkedHashMap
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
 
Fields inherited from class java.util.LinkedHashMap
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
private GreenstoneMetadataParser.CollectCFGCache()
           
 
Method Summary
 GreenstoneMetadataParser.CollectCFG get(java.io.File collect_cfg_file)
          Retrieve the CollectCFG object that matches the given collection file path.
protected  boolean removeEldestEntry(java.util.Map.Entry entry)
          Returns true if this map should remove the eldest entry.
 
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
equals, hashCode
 

Constructor Detail

GreenstoneMetadataParser.CollectCFGCache

private GreenstoneMetadataParser.CollectCFGCache()
Method Detail

get

public GreenstoneMetadataParser.CollectCFG get(java.io.File collect_cfg_file)
Retrieve the CollectCFG object that matches the given collection file path.


removeEldestEntry

protected boolean removeEldestEntry(java.util.Map.Entry entry)
Description copied from class: java.util.LinkedHashMap
Returns true if this map should remove the eldest entry. This method is invoked by all calls to put and putAll which place a new entry in the map, providing the implementer an opportunity to remove the eldest entry any time a new one is added. This can be used to save memory usage of the hashtable, as well as emulating a cache, by deleting stale entries.

For example, to keep the Map limited to 100 entries, override as follows:

 private static final int MAX_ENTRIES = 100;
 protected boolean removeEldestEntry(Map.Entry eldest)
 {
   return size() > MAX_ENTRIES;
 }
 

Typically, this method does not modify the map, but just uses the return value as an indication to put whether to proceed. However, if you override it to modify the map, you must return false (indicating that put should leave the modified map alone), or you face unspecified behavior. Remember that in access-order mode, even calling get is a structural modification, but using the collections views (such as keySet) is not.

This method is called after the eldest entry has been inserted, so if put was called on a previously empty map, the eldest entry is the one you just put in! The default implementation just returns false, so that this map always behaves like a normal one with unbounded growth.