de.topicmapslab.majortom.index.core
Class BaseCachedLiteralIndexImpl<X extends de.topicmapslab.majortom.model.store.ITopicMapStore>

java.lang.Object
  extended by de.topicmapslab.majortom.index.IndexImpl<T>
      extended by de.topicmapslab.majortom.index.core.BaseCachedIndexImpl<X>
          extended by de.topicmapslab.majortom.index.core.BaseCachedLiteralIndexImpl<X>
All Implemented Interfaces:
de.topicmapslab.majortom.model.event.ITopicMapListener, org.tmapi.index.Index
Direct Known Subclasses:
CachedLiteralIndexImpl, PagedLiteralIndexImpl

public abstract class BaseCachedLiteralIndexImpl<X extends de.topicmapslab.majortom.model.store.ITopicMapStore>
extends BaseCachedIndexImpl<X>
implements de.topicmapslab.majortom.model.event.ITopicMapListener

Author:
Sven Krosse

Field Summary
private  java.util.Map<LiteralCacheKey,java.util.Collection<? extends org.tmapi.core.Construct>> cachedConstructs
           
private  java.util.Map<LiteralCacheKey,java.util.Collection<? extends org.tmapi.core.Construct>> cachedLiterals
           
 
Constructor Summary
BaseCachedLiteralIndexImpl(X store)
           
 
Method Summary
protected  void cache(java.lang.Class<?> clazz, java.lang.Object filter, java.lang.Object deviance, java.util.Collection<? extends org.tmapi.core.Construct> values)
          Internal method to add constructs of the given type to internal store.
protected  void cache(java.lang.Class<?> clazz, java.lang.Object filter, java.lang.Object deviance, java.lang.Integer offset, java.lang.Integer limit, java.util.Comparator<?> comparator, java.util.Collection<? extends org.tmapi.core.Construct> values)
          Internal method to add constructs of the given type to internal store.
protected
<T extends org.tmapi.core.Construct>
void
cacheConstructs(java.lang.Class<T> clazz, java.util.Collection<T> values)
          Internal method to add constructs of the given type to internal store.
protected
<T extends org.tmapi.core.Construct>
void
cacheConstructs(java.lang.Class<T> clazz, java.lang.Integer offset, java.lang.Integer limit, java.util.Comparator<T> comparator, java.util.Collection<T> values)
          Internal method to add constructs of the given type to internal store
protected
<T extends org.tmapi.core.Construct>
void
cacheConstructs(java.lang.Class<T> clazz, java.lang.Object filter, java.lang.Object datatype, java.util.Collection<T> values)
          Internal method to add constructs of the given type to internal store.
protected
<T extends org.tmapi.core.Construct>
void
cacheConstructs(java.lang.Class<T> clazz, java.lang.Object filter, java.lang.Object datatype, java.lang.Integer offset, java.lang.Integer limit, java.util.Comparator<T> comparator, java.util.Collection<T> values)
          Internal method to add constructs of the given type to internal store
 void clear()
          Removed any cached content from internal cache
protected  void clearCache()
          Internal method to clear all caches
 void close()
          
private  LiteralCacheKey generateCacheKey(java.lang.Class<?> clazz, java.lang.Object filter, java.lang.Object deviance, java.lang.Integer offset, java.lang.Integer limit, java.util.Comparator<?> comparator)
          Generates a key for internal caching
 void open()
          
protected
<T extends de.topicmapslab.majortom.model.core.IConstruct>
java.util.Collection<T>
read(java.lang.Class<?> clazz, java.lang.Object filter, java.lang.Object deviance)
          Internal method to read constructs
protected
<T extends de.topicmapslab.majortom.model.core.IConstruct>
java.util.Collection<T>
read(java.lang.Class<?> clazz, java.lang.Object filter, java.lang.Object deviance, java.lang.Integer offset, java.lang.Integer limit, java.util.Comparator<?> comparator)
          Internal method to read constructs
protected
<T extends org.tmapi.core.Construct>
java.util.Collection<T>
readConstructs(java.lang.Class<T> clazz)
          Internal method to read constructs
protected
<T extends org.tmapi.core.Construct>
java.util.Collection<T>
readConstructs(java.lang.Class<T> clazz, java.lang.Integer offset, java.lang.Integer limit, java.util.Comparator<T> comparator)
          Internal method to read constructs
protected
<T extends org.tmapi.core.Construct>
java.util.Collection<T>
readConstructs(java.lang.Class<T> clazz, java.lang.Object filter, java.lang.Object datatype)
          Internal method to read constructs
protected
<T extends org.tmapi.core.Construct>
java.util.Collection<T>
readConstructs(java.lang.Class<T> clazz, java.lang.Object filter, java.lang.Object datatype, java.lang.Integer offset, java.lang.Integer limit, java.util.Comparator<T> comparator)
          Internal method to read constructs
 void topicMapChanged(java.lang.String id, de.topicmapslab.majortom.model.event.TopicMapEventType event, org.tmapi.core.Construct notifier, java.lang.Object newValue, java.lang.Object oldValue)
          
 
Methods inherited from class de.topicmapslab.majortom.index.core.BaseCachedIndexImpl
isCachingEnabled, isOnTransactionContext, isOnTransactionContext, isOnTransactionContext, isOnTransactionContext, isOnTransactionContext
 
Methods inherited from class de.topicmapslab.majortom.index.IndexImpl
getTopicMapStore, isAutoUpdated, isOpen, reindex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cachedConstructs

private java.util.Map<LiteralCacheKey,java.util.Collection<? extends org.tmapi.core.Construct>> cachedConstructs

cachedLiterals

private java.util.Map<LiteralCacheKey,java.util.Collection<? extends org.tmapi.core.Construct>> cachedLiterals
Constructor Detail

BaseCachedLiteralIndexImpl

public BaseCachedLiteralIndexImpl(X store)
Parameters:
store -
parentIndex -
Method Detail

topicMapChanged

public void topicMapChanged(java.lang.String id,
                            de.topicmapslab.majortom.model.event.TopicMapEventType event,
                            org.tmapi.core.Construct notifier,
                            java.lang.Object newValue,
                            java.lang.Object oldValue)

Specified by:
topicMapChanged in interface de.topicmapslab.majortom.model.event.ITopicMapListener

readConstructs

protected final <T extends org.tmapi.core.Construct> java.util.Collection<T> readConstructs(java.lang.Class<T> clazz)
Internal method to read constructs

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
Returns:
the list or null if the key-pair is unknown

readConstructs

protected final <T extends org.tmapi.core.Construct> java.util.Collection<T> readConstructs(java.lang.Class<T> clazz,
                                                                                            java.lang.Object filter,
                                                                                            java.lang.Object datatype)
Internal method to read constructs

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
filter - a filter criteria - the datatype or null
datatype - the datatype
Returns:
the list or null if the key-pair is unknown

readConstructs

protected final <T extends org.tmapi.core.Construct> java.util.Collection<T> readConstructs(java.lang.Class<T> clazz,
                                                                                            java.lang.Integer offset,
                                                                                            java.lang.Integer limit,
                                                                                            java.util.Comparator<T> comparator)
Internal method to read constructs

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
Returns:
the list or null if the key-pair is unknown

readConstructs

protected final <T extends org.tmapi.core.Construct> java.util.Collection<T> readConstructs(java.lang.Class<T> clazz,
                                                                                            java.lang.Object filter,
                                                                                            java.lang.Object datatype,
                                                                                            java.lang.Integer offset,
                                                                                            java.lang.Integer limit,
                                                                                            java.util.Comparator<T> comparator)
Internal method to read constructs

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
filter - a filter criteria - the datatype or null
datatype - the datatype
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
Returns:
the list or null if the key-pair is unknown

cacheConstructs

protected final <T extends org.tmapi.core.Construct> void cacheConstructs(java.lang.Class<T> clazz,
                                                                          java.util.Collection<T> values)
Internal method to add constructs of the given type to internal store.

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
values - the values to store

cacheConstructs

protected final <T extends org.tmapi.core.Construct> void cacheConstructs(java.lang.Class<T> clazz,
                                                                          java.lang.Object filter,
                                                                          java.lang.Object datatype,
                                                                          java.util.Collection<T> values)
Internal method to add constructs of the given type to internal store.

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
filter - a filter criteria - the datatype or null
datatype - the datatype
values - the values to store

cacheConstructs

protected final <T extends org.tmapi.core.Construct> void cacheConstructs(java.lang.Class<T> clazz,
                                                                          java.lang.Integer offset,
                                                                          java.lang.Integer limit,
                                                                          java.util.Comparator<T> comparator,
                                                                          java.util.Collection<T> values)
Internal method to add constructs of the given type to internal store. *

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
values - the values to store

cacheConstructs

protected final <T extends org.tmapi.core.Construct> void cacheConstructs(java.lang.Class<T> clazz,
                                                                          java.lang.Object filter,
                                                                          java.lang.Object datatype,
                                                                          java.lang.Integer offset,
                                                                          java.lang.Integer limit,
                                                                          java.util.Comparator<T> comparator,
                                                                          java.util.Collection<T> values)
Internal method to add constructs of the given type to internal store. *

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
filter - a filter criteria - the datatype or null
datatype - the datatype
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
values - the values to store

read

protected final <T extends de.topicmapslab.majortom.model.core.IConstruct> java.util.Collection<T> read(java.lang.Class<?> clazz,
                                                                                                        java.lang.Object filter,
                                                                                                        java.lang.Object deviance)
Internal method to read constructs

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
filter - a filter criteria (e.g. regular expression)
deviance - a deviance criteria (e.g. numeric value)
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
Returns:
the list or null if the key-pair is unknown

read

protected final <T extends de.topicmapslab.majortom.model.core.IConstruct> java.util.Collection<T> read(java.lang.Class<?> clazz,
                                                                                                        java.lang.Object filter,
                                                                                                        java.lang.Object deviance,
                                                                                                        java.lang.Integer offset,
                                                                                                        java.lang.Integer limit,
                                                                                                        java.util.Comparator<?> comparator)
Internal method to read constructs

Type Parameters:
T - the literals type to return
Parameters:
clazz - the type of construct
filter - a filter criteria (e.g. regular expression)
deviance - a deviance criteria (e.g. numeric value)
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
Returns:
the list or null if the key-pair is unknown

cache

protected final void cache(java.lang.Class<?> clazz,
                           java.lang.Object filter,
                           java.lang.Object deviance,
                           java.util.Collection<? extends org.tmapi.core.Construct> values)
Internal method to add constructs of the given type to internal store.

Parameters:
clazz - the type of construct
filter - a filter criteria (e.g. regular expression)
deviance - a deviance criteria (e.g. numeric value)
values - the values to store

cache

protected final void cache(java.lang.Class<?> clazz,
                           java.lang.Object filter,
                           java.lang.Object deviance,
                           java.lang.Integer offset,
                           java.lang.Integer limit,
                           java.util.Comparator<?> comparator,
                           java.util.Collection<? extends org.tmapi.core.Construct> values)
Internal method to add constructs of the given type to internal store.

Parameters:
clazz - the type of construct
filter - a filter criteria (e.g. regular expression)
deviance - a deviance criteria (e.g. numeric value)
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
values - the values to store

clearCache

protected final void clearCache()
Internal method to clear all caches

Specified by:
clearCache in class BaseCachedIndexImpl<X extends de.topicmapslab.majortom.model.store.ITopicMapStore>

generateCacheKey

private LiteralCacheKey generateCacheKey(java.lang.Class<?> clazz,
                                         java.lang.Object filter,
                                         java.lang.Object deviance,
                                         java.lang.Integer offset,
                                         java.lang.Integer limit,
                                         java.util.Comparator<?> comparator)
Generates a key for internal caching

Parameters:
clazz - the class
filter - the filter criteria or null
deviance - a deviance criteria (e.g. numeric value)
offset - the offset or null
limit - the limit or null
comparator - the comparator or null
Returns:
the generated cache key;

open

public void open()

Specified by:
open in interface org.tmapi.index.Index
Overrides:
open in class BaseCachedIndexImpl<X extends de.topicmapslab.majortom.model.store.ITopicMapStore>

close

public void close()

Specified by:
close in interface org.tmapi.index.Index
Overrides:
close in class BaseCachedIndexImpl<X extends de.topicmapslab.majortom.model.store.ITopicMapStore>

clear

public void clear()
Removed any cached content from internal cache

Overrides:
clear in class BaseCachedIndexImpl<X extends de.topicmapslab.majortom.model.store.ITopicMapStore>