de.topicmapslab.majortom.cache
Class ConstructCache

java.lang.Object
  extended by de.topicmapslab.majortom.cache.ConstructCache
All Implemented Interfaces:
de.topicmapslab.majortom.model.event.ITopicMapListener

public class ConstructCache
extends java.lang.Object
implements de.topicmapslab.majortom.model.event.ITopicMapListener


Nested Class Summary
(package private)  class ConstructCache.CacheKey
           
(package private) static class ConstructCache.Key
           
 
Field Summary
private  AssociationCache associationCache
           
private  java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IAssociation>> associations
           
private  CharacteristicsCache characteristicsCache
           
private  IdentityCache identityCache
           
private  java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IName>> names
           
private  java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> occurrences
           
private  ReificationCache reificationCache
           
private  java.util.Map<java.lang.Object,java.util.Set<ConstructCache.CacheKey>> relevantCacheKeys
           
private  RevisionCache revisionCache
           
private  java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> roles
           
private  ScopeCache scopeCache
           
private  java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> topics
           
private  TopicTypeCache topicTypeCache
           
private  TypedCache typedCache
           
private  java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> variants
           
 
Constructor Summary
ConstructCache()
           
 
Method Summary
 void cacheAssociation(de.topicmapslab.majortom.model.core.IConstruct context, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope, java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> set)
          Cache the associations of the given parent, the given type and the given scope in the internal store
 void cacheNames(de.topicmapslab.majortom.model.core.ITopic parent, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope, java.util.Set<de.topicmapslab.majortom.model.core.IName> set)
          Cache the names of the given parent, the given type and the given scope in the internal store
 void cacheOccurrences(de.topicmapslab.majortom.model.core.ITopic parent, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope, java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> set)
          Cache the occurrences of the given parent, the given type and the given scope in the internal store
 void cacheRoles(de.topicmapslab.majortom.model.core.IConstruct context, de.topicmapslab.majortom.model.core.ITopic type, java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> set)
          Cache the roles of the given parent, the given type in the internal store
 void cacheTopics(de.topicmapslab.majortom.model.core.ITopic type, java.util.Set<de.topicmapslab.majortom.model.core.ITopic> set)
          Cache the topics of the given type to the internal topic map store
 void cacheVariants(de.topicmapslab.majortom.model.core.IName parent, de.topicmapslab.majortom.model.core.IScope scope, java.util.Set<de.topicmapslab.majortom.model.core.IVariant> set)
          Cache the variants of the given parent and the given scope in the internal store
 void clear()
          closing the cache instance
private  ConstructCache.CacheKey generateCacheKey(de.topicmapslab.majortom.model.core.IConstruct context, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope)
          Generates a cache key for the given properties
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getAssociation(de.topicmapslab.majortom.model.core.IConstruct context, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope)
          Returns the internal stored associations of the given parent, the given type and the given scope
 AssociationCache getAssociationCache()
          Returns the internal cache reference handling the role-player mappings
 CharacteristicsCache getCharacteristicsCache()
          Returns the internal reference of the sub cache handling datatypes and values
private
<T extends de.topicmapslab.majortom.model.core.IConstruct>
java.util.Set<T>
getConstructs(de.topicmapslab.majortom.model.core.IConstruct parent, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope, java.util.Map<ConstructCache.CacheKey,java.util.Set<T>> map)
          Internal method to access the given map in a secure way.
 IdentityCache getIdentityCache()
          Returns the internal reference of the sub cache handling identities of a construct
 java.util.Set<de.topicmapslab.majortom.model.core.IName> getNames(de.topicmapslab.majortom.model.core.ITopic parent, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope)
          Returns the internal stored names of the given parent, the given type and the given scope
 java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrences(de.topicmapslab.majortom.model.core.ITopic parent, de.topicmapslab.majortom.model.core.ITopic type, de.topicmapslab.majortom.model.core.IScope scope)
          Returns the internal stored occurrences of the given parent, the given type and the given scope
 ReificationCache getReificationCache()
          Returns the internal reference of the cache handling the reification between a topic and a reified construct
private  java.util.Set<ConstructCache.CacheKey> getRelevantCacheKeys(java.lang.Object obj)
          Returns all relevant cache keys for the given filter
 RevisionCache getRevisionCache()
          Returns the internal cache reference handling the history
 java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getRoles(de.topicmapslab.majortom.model.core.IConstruct context, de.topicmapslab.majortom.model.core.ITopic type)
          Returns the internal stored roles of the given parent, the given type
 ScopeCache getScopeCache()
          Returns the internal reference of the cache handling the scopes of a construct
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTopics(de.topicmapslab.majortom.model.core.ITopic type)
          Returns the internal stored topics the given type
 TopicTypeCache getTopicTypeCache()
          Returns the internal reference of the cache handling the topic-type hierarchy
 TypedCache getTypedCache()
          Returns the internal reference of the cache handling the types of a construct
 java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariants(de.topicmapslab.majortom.model.core.IName parent, de.topicmapslab.majortom.model.core.IScope scope)
          Returns the internal stored variants of the given parent and the given scope
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

characteristicsCache

private CharacteristicsCache characteristicsCache

identityCache

private IdentityCache identityCache

reificationCache

private ReificationCache reificationCache

scopeCache

private ScopeCache scopeCache

typedCache

private TypedCache typedCache

topicTypeCache

private TopicTypeCache topicTypeCache

associationCache

private AssociationCache associationCache

revisionCache

private RevisionCache revisionCache

names

private java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IName>> names

occurrences

private java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> occurrences

associations

private java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IAssociation>> associations

roles

private java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole>> roles

variants

private java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> variants

topics

private java.util.Map<ConstructCache.CacheKey,java.util.Set<de.topicmapslab.majortom.model.core.ITopic>> topics

relevantCacheKeys

private java.util.Map<java.lang.Object,java.util.Set<ConstructCache.CacheKey>> relevantCacheKeys
Constructor Detail

ConstructCache

public ConstructCache()
Method Detail

generateCacheKey

private ConstructCache.CacheKey generateCacheKey(de.topicmapslab.majortom.model.core.IConstruct context,
                                                 de.topicmapslab.majortom.model.core.ITopic type,
                                                 de.topicmapslab.majortom.model.core.IScope scope)
Generates a cache key for the given properties

Parameters:
context - the context or parent of stored values
type - the type of stored values
scope - the scope of stored values
Returns:
the generated cache key

getRelevantCacheKeys

private java.util.Set<ConstructCache.CacheKey> getRelevantCacheKeys(java.lang.Object obj)
Returns all relevant cache keys for the given filter

Parameters:
obj - the filter
Returns:
a set of all relevant cache keys

getConstructs

private <T extends de.topicmapslab.majortom.model.core.IConstruct> java.util.Set<T> getConstructs(de.topicmapslab.majortom.model.core.IConstruct parent,
                                                                                                  de.topicmapslab.majortom.model.core.ITopic type,
                                                                                                  de.topicmapslab.majortom.model.core.IScope scope,
                                                                                                  java.util.Map<ConstructCache.CacheKey,java.util.Set<T>> map)
Internal method to access the given map in a secure way. The method extracts the requested constructs from the given map by a unique key generated by the other arguments.

Type Parameters:
T - the generic type of requested constructs
Parameters:
parent - the parent or null
type - the type or null
scope - the scope or null
map - the map to extract the constructs
Returns:
a set of constructs or null if the given map is null or does not contain the given key

getNames

public java.util.Set<de.topicmapslab.majortom.model.core.IName> getNames(de.topicmapslab.majortom.model.core.ITopic parent,
                                                                         de.topicmapslab.majortom.model.core.ITopic type,
                                                                         de.topicmapslab.majortom.model.core.IScope scope)
Returns the internal stored names of the given parent, the given type and the given scope

Parameters:
parent - the parent or null
type - the type or null
scope - the scope or null
Returns:
all cached names

getOccurrences

public java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrences(de.topicmapslab.majortom.model.core.ITopic parent,
                                                                                     de.topicmapslab.majortom.model.core.ITopic type,
                                                                                     de.topicmapslab.majortom.model.core.IScope scope)
Returns the internal stored occurrences of the given parent, the given type and the given scope

Parameters:
parent - the parent or null
type - the type or null
scope - the scope or null
Returns:
all cached occurrences

getVariants

public java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariants(de.topicmapslab.majortom.model.core.IName parent,
                                                                               de.topicmapslab.majortom.model.core.IScope scope)
Returns the internal stored variants of the given parent and the given scope

Parameters:
parent - the parent or null
scope - the scope or null
Returns:
all cached variants

getAssociation

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> getAssociation(de.topicmapslab.majortom.model.core.IConstruct context,
                                                                                      de.topicmapslab.majortom.model.core.ITopic type,
                                                                                      de.topicmapslab.majortom.model.core.IScope scope)
Returns the internal stored associations of the given parent, the given type and the given scope

Parameters:
context - the topic map or the playing topic or null
type - the type or null
scope - the scope or null
Returns:
all cached associations

getRoles

public java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> getRoles(de.topicmapslab.majortom.model.core.IConstruct context,
                                                                                    de.topicmapslab.majortom.model.core.ITopic type)
Returns the internal stored roles of the given parent, the given type

Parameters:
context - the association or the playing topic or null
type - the type or null
Returns:
all cached roles

getTopics

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTopics(de.topicmapslab.majortom.model.core.ITopic type)
Returns the internal stored topics the given type

Parameters:
type - the type or null
Returns:
all cached roles

cacheNames

public void cacheNames(de.topicmapslab.majortom.model.core.ITopic parent,
                       de.topicmapslab.majortom.model.core.ITopic type,
                       de.topicmapslab.majortom.model.core.IScope scope,
                       java.util.Set<de.topicmapslab.majortom.model.core.IName> set)
Cache the names of the given parent, the given type and the given scope in the internal store

Parameters:
parent - the parent or null
type - the type or null
scope - the scope or null
set - the values to cache

cacheOccurrences

public void cacheOccurrences(de.topicmapslab.majortom.model.core.ITopic parent,
                             de.topicmapslab.majortom.model.core.ITopic type,
                             de.topicmapslab.majortom.model.core.IScope scope,
                             java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> set)
Cache the occurrences of the given parent, the given type and the given scope in the internal store

Parameters:
parent - the parent or null
type - the type or null
scope - the scope or null
set - the values to cache

cacheVariants

public void cacheVariants(de.topicmapslab.majortom.model.core.IName parent,
                          de.topicmapslab.majortom.model.core.IScope scope,
                          java.util.Set<de.topicmapslab.majortom.model.core.IVariant> set)
Cache the variants of the given parent and the given scope in the internal store

Parameters:
parent - the parent or null
scope - the scope or null
set - the values to cache

cacheAssociation

public void cacheAssociation(de.topicmapslab.majortom.model.core.IConstruct context,
                             de.topicmapslab.majortom.model.core.ITopic type,
                             de.topicmapslab.majortom.model.core.IScope scope,
                             java.util.Set<de.topicmapslab.majortom.model.core.IAssociation> set)
Cache the associations of the given parent, the given type and the given scope in the internal store

Parameters:
context - the topic map or the playing topic or null
type - the type or null
scope - the scope or null
set - the values to cache

cacheRoles

public void cacheRoles(de.topicmapslab.majortom.model.core.IConstruct context,
                       de.topicmapslab.majortom.model.core.ITopic type,
                       java.util.Set<de.topicmapslab.majortom.model.core.IAssociationRole> set)
Cache the roles of the given parent, the given type in the internal store

Parameters:
context - the association or the playing topic or null
type - the type or null
set - the values to cache

cacheTopics

public void cacheTopics(de.topicmapslab.majortom.model.core.ITopic type,
                        java.util.Set<de.topicmapslab.majortom.model.core.ITopic> set)
Cache the topics of the given type to the internal topic map store

Parameters:
type - the type or null
set - the values to cache

getCharacteristicsCache

public CharacteristicsCache getCharacteristicsCache()
Returns the internal reference of the sub cache handling datatypes and values

Returns:
the reference

getIdentityCache

public IdentityCache getIdentityCache()
Returns the internal reference of the sub cache handling identities of a construct

Returns:
the identityCache

getReificationCache

public ReificationCache getReificationCache()
Returns the internal reference of the cache handling the reification between a topic and a reified construct

Returns:
the reificationCache

getScopeCache

public ScopeCache getScopeCache()
Returns the internal reference of the cache handling the scopes of a construct

Returns:
the scopeCache

getTypedCache

public TypedCache getTypedCache()
Returns the internal reference of the cache handling the types of a construct

Returns:
the typedCache

getTopicTypeCache

public TopicTypeCache getTopicTypeCache()
Returns the internal reference of the cache handling the topic-type hierarchy

Returns:
the topicTypeCache

getAssociationCache

public AssociationCache getAssociationCache()
Returns the internal cache reference handling the role-player mappings

Returns:
the associationCache

getRevisionCache

public RevisionCache getRevisionCache()
Returns the internal cache reference handling the history

Returns:
the revisionCache

clear

public void clear()
closing the cache instance


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