uk.ac.ebi.jmzidml.xml.jaxb.unmarshaller.cache
Class AdapterObjectCache

java.lang.Object
  extended by uk.ac.ebi.jmzidml.xml.jaxb.unmarshaller.cache.AdapterObjectCache
All Implemented Interfaces:
MzIdentMLObjectCache

public class AdapterObjectCache
extends Object
implements MzIdentMLObjectCache

Java in memory HashMap based Object cache implementation of the MzIdentMLObjectCache. Note that this implementation makes use of the MzIdentMLElement types to control which Objects are cached and which are ignored.


Constructor Summary
AdapterObjectCache()
           
 
Method Summary
<T extends MzIdentMLObject>
T
getCachedObject(String id, Class<T> cls)
          Retrieve a MzIdentMLObject from the object cache.
<T extends MzIdentMLObject>
List<T>
getEntries(Class<T> clazz)
           
<T extends MzIdentMLObject>
boolean
hasEntry(Class<T> clazz)
           
 void putInCache(IdentifiableMzIdentMLObject element)
          Convenience method to store Objects that implement the Identifiable interface.
 void putInCache(String id, MzIdentMLObject object)
          Stores the Object in a in-memory Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdapterObjectCache

public AdapterObjectCache()
Method Detail

putInCache

public void putInCache(String id,
                       MzIdentMLObject object)
Stores the Object in a in-memory Map. Note: if a Object is really stored or not is controlled by the settings of its corresponding MzIdentMLElement.

Specified by:
putInCache in interface MzIdentMLObjectCache
Parameters:
id - the ID under which to store the Object.
object - the MzIdentMLObject to store.
See Also:
MzIdentMLElement

putInCache

public void putInCache(IdentifiableMzIdentMLObject element)
Convenience method to store Objects that implement the Identifiable interface.

Specified by:
putInCache in interface MzIdentMLObjectCache
Parameters:
element - the Identifiable to store in the cache.

getCachedObject

public <T extends MzIdentMLObject> T getCachedObject(String id,
                                                     Class<T> cls)
Retrieve a MzIdentMLObject from the object cache.

Specified by:
getCachedObject in interface MzIdentMLObjectCache
Parameters:
id - the ID of the object to retrieve.
cls - the class of the object to retrieve.
Returns:
the retrieved object or null if no entry was found in the cache.

hasEntry

public <T extends MzIdentMLObject> boolean hasEntry(Class<T> clazz)
Specified by:
hasEntry in interface MzIdentMLObjectCache

getEntries

public <T extends MzIdentMLObject> List<T> getEntries(Class<T> clazz)
Specified by:
getEntries in interface MzIdentMLObjectCache


Copyright © 2012. All Rights Reserved.