de.topicmapslab.majortom.inmemory.store.internal
Class IdentityStore

java.lang.Object
  extended by de.topicmapslab.majortom.inmemory.store.internal.IdentityStore
All Implemented Interfaces:
IDataStore
Direct Known Subclasses:
VirtualIdentityStore

public class IdentityStore
extends java.lang.Object
implements IDataStore

Base implementation of a store object containing all identity informations

Author:
Sven Krosse

Field Summary
 int capacity
          the capacity of internal maps
private  java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> constructItemIdentitiers
          construct to item-identifiers mapping
private  java.util.Map<java.lang.String,de.topicmapslab.majortom.model.core.IConstruct> ids
          storage map of id-construct relation of the topic map engine
private  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.IConstruct> itemIdentifiers
          item-identifier mapping of the topic map engine
private  InMemoryTopicMapStore store
          the parent store
private  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> subjectIdentifiers
          subject-identifier mapping of the topic map engine
private  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> subjectLocators
          subject-locator mapping of the topic map engine
private  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> topics
          a set containing all topics
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> topicSubjectIdentifiers
          topic to subject-identifiers mapping
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> topicSubjectLocators
          topic to subject-locators mapping
 
Constructor Summary
IdentityStore(InMemoryTopicMapStore store, int capacity)
          constructor
 
Method Summary
 void addItemIdentifer(de.topicmapslab.majortom.model.core.IConstruct c, de.topicmapslab.majortom.model.core.ILocator identifier)
          Register a item-identifier for the given construct
 void addSubjectIdentifier(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ILocator identifier)
          Register a subject-identifier for the given topic
 void addSubjectLocator(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ILocator locator)
          Register a subject-locator for the given topic
 de.topicmapslab.majortom.model.core.IConstruct byId(java.lang.String id)
          Return the construct identified by the given id.
 de.topicmapslab.majortom.model.core.IConstruct byItemIdentifier(de.topicmapslab.majortom.model.core.ILocator l)
          Return the construct identified by the given item-identifier.
 de.topicmapslab.majortom.model.core.ITopic bySubjectIdentifier(de.topicmapslab.majortom.model.core.ILocator l)
          Return the topic identified by the given subject-identifier.
 de.topicmapslab.majortom.model.core.ITopic bySubjectLocator(de.topicmapslab.majortom.model.core.ILocator l)
          Return the topic identified by the given subject-locator.
 void close()
          Remove all items from the internal store.
protected  boolean containsConstruct(de.topicmapslab.majortom.model.core.IConstruct construct)
          Checks if the given construct is stored by the identity store.
 boolean containsIdentifier(de.topicmapslab.majortom.model.core.ILocator locator)
          Checks if the given locator is used as identifier.
 boolean containsItemIdentifier(de.topicmapslab.majortom.model.core.ILocator locator)
          Checks if the given locator is used as item-identifier.
protected  boolean containsItemIdentifiers(de.topicmapslab.majortom.model.core.IConstruct construct)
          Checks if the store know at least one item identifier for the given construct
 boolean containsSubjectIdentifier(de.topicmapslab.majortom.model.core.ILocator locator)
          Checks if the given locator is used as subject-identifier.
protected  boolean containsSubjectIdentifiers(de.topicmapslab.majortom.model.core.ITopic topic)
          Checks if the store know at least one subject identifier for the given topic
 boolean containsSubjectLocator(de.topicmapslab.majortom.model.core.ILocator locator)
          Checks if the given locator is used as subject-locator.
protected  boolean containsSubjectLocators(de.topicmapslab.majortom.model.core.ITopic topic)
          Checks if the store know at least one subject locator for the given topic
 de.topicmapslab.majortom.model.core.ILocator createLocator(java.lang.String reference)
          Creates a new locator instance of the reference is unknown or return the stored instance
 java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> getConstructItemIdentitiersMap()
           
 java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getIdentifiers()
          Return all internal stored identifiers.
protected  java.util.Map<java.lang.String,de.topicmapslab.majortom.model.core.IConstruct> getIdsMap()
           
 java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getItemIdentifiers()
          Return all internal stored item-identifiers.
 java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getItemIdentifiers(de.topicmapslab.majortom.model.core.IConstruct c)
          Return all item-identifiers of the given construct.
protected  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.IConstruct> getItemIdentifiersMap()
           
protected  InMemoryTopicMapStore getStore()
          Return the internal stored store instance.
 java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectIdentifiers()
          Return all internal stored subject-identifiers.
 java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectIdentifiers(de.topicmapslab.majortom.model.core.ITopic t)
          Return all subject-identifiers of the given topic.
protected  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> getSubjectIdentitifersMap()
           
 java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectLocators()
          Return all internal stored subject-locators.
 java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectLocators(de.topicmapslab.majortom.model.core.ITopic t)
          Return all subject-locator of the given topic.
protected  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> getSubjectLocatorsMap()
           
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTopics()
          Returns all topics of the internal store
protected  java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTopicsSet()
           
 java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> getTopicSubjectIdentifiersMap()
           
protected  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> getTopicSubjectLocatorsMap()
           
 void removeConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
          Remove the construct from the internal store
 void removeId(de.topicmapslab.majortom.model.core.IConstruct c, java.lang.String id)
          Unregister the id of the construct.
 void removeItemIdentifer(de.topicmapslab.majortom.model.core.IConstruct c, de.topicmapslab.majortom.model.core.ILocator identifier)
          Unregister a item-identifier for the given construct
 void removeSubjectIdentifier(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ILocator identifier)
          Unregister a subject-identifier for the given topic
 void removeSubjectLocator(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.ILocator identifier)
          Unregister a subject-locator for the given topic
 void removeTopic(de.topicmapslab.majortom.model.core.ITopic t)
          Removing the given topic from internal store
 void replace(de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic replacement, de.topicmapslab.majortom.model.revision.IRevision revision)
          Replace each reference of the given topic by the given replacement.
<T extends de.topicmapslab.majortom.model.core.IConstruct>
void
replace(T construct, T replacement)
           
 void setId(de.topicmapslab.majortom.model.core.IConstruct c, java.lang.String id)
          Register the id for the given construct
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

capacity

public final int capacity
the capacity of internal maps


ids

private java.util.Map<java.lang.String,de.topicmapslab.majortom.model.core.IConstruct> ids
storage map of id-construct relation of the topic map engine


itemIdentifiers

private java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.IConstruct> itemIdentifiers
item-identifier mapping of the topic map engine


constructItemIdentitiers

private java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> constructItemIdentitiers
construct to item-identifiers mapping


subjectIdentifiers

private java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> subjectIdentifiers
subject-identifier mapping of the topic map engine


topicSubjectIdentifiers

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> topicSubjectIdentifiers
topic to subject-identifiers mapping


subjectLocators

private java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> subjectLocators
subject-locator mapping of the topic map engine


topicSubjectLocators

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> topicSubjectLocators
topic to subject-locators mapping


topics

private java.util.Set<de.topicmapslab.majortom.model.core.ITopic> topics
a set containing all topics


store

private final InMemoryTopicMapStore store
the parent store

Constructor Detail

IdentityStore

public IdentityStore(InMemoryTopicMapStore store,
                     int capacity)
constructor

Parameters:
store - the parent store
capacity - the capacity of internal sets
Method Detail

close

public void close()
Remove all items from the internal store.

Specified by:
close in interface IDataStore

byId

public de.topicmapslab.majortom.model.core.IConstruct byId(java.lang.String id)
Return the construct identified by the given id.

Parameters:
id - the id
Returns:
the construct or null

byItemIdentifier

public de.topicmapslab.majortom.model.core.IConstruct byItemIdentifier(de.topicmapslab.majortom.model.core.ILocator l)
Return the construct identified by the given item-identifier.

Parameters:
l - the item-identifier
Returns:
the construct or null

bySubjectIdentifier

public de.topicmapslab.majortom.model.core.ITopic bySubjectIdentifier(de.topicmapslab.majortom.model.core.ILocator l)
Return the topic identified by the given subject-identifier.

Parameters:
l - the subject-identifier
Returns:
the topic or null

bySubjectLocator

public de.topicmapslab.majortom.model.core.ITopic bySubjectLocator(de.topicmapslab.majortom.model.core.ILocator l)
Return the topic identified by the given subject-locator.

Parameters:
l - the subject-locator
Returns:
the topic or null

getItemIdentifiers

public java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getItemIdentifiers(de.topicmapslab.majortom.model.core.IConstruct c)
Return all item-identifiers of the given construct.

Parameters:
c - the construct
Returns:
the identifiers

getSubjectIdentifiers

public java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectIdentifiers(de.topicmapslab.majortom.model.core.ITopic t)
Return all subject-identifiers of the given topic.

Parameters:
t - the topic
Returns:
the identifiers

getSubjectLocators

public java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectLocators(de.topicmapslab.majortom.model.core.ITopic t)
Return all subject-locator of the given topic.

Parameters:
t - the topic
Returns:
the locators

setId

public void setId(de.topicmapslab.majortom.model.core.IConstruct c,
                  java.lang.String id)
Register the id for the given construct

Parameters:
c - the construct
id - the id

addItemIdentifer

public void addItemIdentifer(de.topicmapslab.majortom.model.core.IConstruct c,
                             de.topicmapslab.majortom.model.core.ILocator identifier)
Register a item-identifier for the given construct

Parameters:
c - the construct
identifier - the item-identifier

addSubjectIdentifier

public void addSubjectIdentifier(de.topicmapslab.majortom.model.core.ITopic t,
                                 de.topicmapslab.majortom.model.core.ILocator identifier)
Register a subject-identifier for the given topic

Parameters:
t - the topic
identifier - the subject-identifier

addSubjectLocator

public void addSubjectLocator(de.topicmapslab.majortom.model.core.ITopic t,
                              de.topicmapslab.majortom.model.core.ILocator locator)
Register a subject-locator for the given topic

Parameters:
t - the topic
locator - the subject-locator

removeId

public void removeId(de.topicmapslab.majortom.model.core.IConstruct c,
                     java.lang.String id)
Unregister the id of the construct.

Parameters:
c - the construct
id - the id

removeItemIdentifer

public void removeItemIdentifer(de.topicmapslab.majortom.model.core.IConstruct c,
                                de.topicmapslab.majortom.model.core.ILocator identifier)
Unregister a item-identifier for the given construct

Parameters:
c - the construct
identifier - the item-identifier

removeSubjectIdentifier

public void removeSubjectIdentifier(de.topicmapslab.majortom.model.core.ITopic t,
                                    de.topicmapslab.majortom.model.core.ILocator identifier)
Unregister a subject-identifier for the given topic

Parameters:
t - the topic
identifier - the subject-identifier

removeSubjectLocator

public void removeSubjectLocator(de.topicmapslab.majortom.model.core.ITopic t,
                                 de.topicmapslab.majortom.model.core.ILocator identifier)
Unregister a subject-locator for the given topic

Parameters:
t - the topic
locator - the subject-locator

removeConstruct

public void removeConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
Remove the construct from the internal store

Parameters:
c - the construct

removeTopic

public void removeTopic(de.topicmapslab.majortom.model.core.ITopic t)
Removing the given topic from internal store

Parameters:
t - the topic

createLocator

public de.topicmapslab.majortom.model.core.ILocator createLocator(java.lang.String reference)
Creates a new locator instance of the reference is unknown or return the stored instance

Parameters:
reference - the reference
Returns:
the locator

getTopics

public java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTopics()
Returns all topics of the internal store

Returns:
all topics

replace

public <T extends de.topicmapslab.majortom.model.core.IConstruct> void replace(T construct,
                                                                               T replacement)

replace

public void replace(de.topicmapslab.majortom.model.core.ITopic topic,
                    de.topicmapslab.majortom.model.core.ITopic replacement,
                    de.topicmapslab.majortom.model.revision.IRevision revision)
Replace each reference of the given topic by the given replacement.

Specified by:
replace in interface IDataStore
Parameters:
topic - the topic
replacement - the replacement
revision - the revision

getIdentifiers

public java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getIdentifiers()
Return all internal stored identifiers.

Returns:
all identifiers

getItemIdentifiers

public java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getItemIdentifiers()
Return all internal stored item-identifiers.

Returns:
all item-identifiers

getSubjectIdentifiers

public java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectIdentifiers()
Return all internal stored subject-identifiers.

Returns:
all subject-identifiers

getSubjectLocators

public java.util.Set<de.topicmapslab.majortom.model.core.ILocator> getSubjectLocators()
Return all internal stored subject-locators.

Returns:
all subject-locators

containsIdentifier

public boolean containsIdentifier(de.topicmapslab.majortom.model.core.ILocator locator)
Checks if the given locator is used as identifier.

Parameters:
locator - the identifier
Returns:
true if the locator is used as identifier, false otherwise.

containsItemIdentifier

public boolean containsItemIdentifier(de.topicmapslab.majortom.model.core.ILocator locator)
Checks if the given locator is used as item-identifier.

Parameters:
locator - the item-identifier
Returns:
true if the locator is used as item-identifier, false otherwise.

containsSubjectIdentifier

public boolean containsSubjectIdentifier(de.topicmapslab.majortom.model.core.ILocator locator)
Checks if the given locator is used as subject-identifier.

Parameters:
locator - the subject-identifier
Returns:
true if the locator is used as subject-identifier, false otherwise.

containsSubjectLocator

public boolean containsSubjectLocator(de.topicmapslab.majortom.model.core.ILocator locator)
Checks if the given locator is used as subject-locator.

Parameters:
locator - the subject-locator
Returns:
true if the locator is used as subject-locator, false otherwise.

getStore

protected InMemoryTopicMapStore getStore()
Return the internal stored store instance.

Returns:
the store the store instance

containsSubjectLocators

protected boolean containsSubjectLocators(de.topicmapslab.majortom.model.core.ITopic topic)
Checks if the store know at least one subject locator for the given topic

Parameters:
topic - the topic
Returns:
true if at least one subject locator is store for the given topic, false otherwise.

containsSubjectIdentifiers

protected boolean containsSubjectIdentifiers(de.topicmapslab.majortom.model.core.ITopic topic)
Checks if the store know at least one subject identifier for the given topic

Parameters:
topic - the topic
Returns:
true if at least one subject identifier is store for the given topic, false otherwise.

containsItemIdentifiers

protected boolean containsItemIdentifiers(de.topicmapslab.majortom.model.core.IConstruct construct)
Checks if the store know at least one item identifier for the given construct

Parameters:
construct - the construct
Returns:
true if at least one item identifier is store for the given construct, false otherwise.

containsConstruct

protected final boolean containsConstruct(de.topicmapslab.majortom.model.core.IConstruct construct)
Checks if the given construct is stored by the identity store.

Parameters:
construct - the construct
Returns:
true if the id is known by the store, false otherwise.

getConstructItemIdentitiersMap

public java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> getConstructItemIdentitiersMap()
Returns:
the constructItemIdentitiers

getTopicSubjectIdentifiersMap

public java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> getTopicSubjectIdentifiersMap()
Returns:
the topicSubjectIdentifiers

getTopicSubjectLocatorsMap

protected java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> getTopicSubjectLocatorsMap()
Returns:
the topicSubjectLocators

getSubjectIdentitifersMap

protected java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> getSubjectIdentitifersMap()

getSubjectLocatorsMap

protected java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.ITopic> getSubjectLocatorsMap()

getItemIdentifiersMap

protected java.util.Map<de.topicmapslab.majortom.model.core.ILocator,de.topicmapslab.majortom.model.core.IConstruct> getItemIdentifiersMap()

getTopicsSet

protected java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTopicsSet()

getIdsMap

protected java.util.Map<java.lang.String,de.topicmapslab.majortom.model.core.IConstruct> getIdsMap()
Returns:
the ids