de.topicmapslab.majortom.inmemory.virtual.internal
Class VirtualIdentityStore<T extends VirtualTopicMapStore>

java.lang.Object
  extended by de.topicmapslab.majortom.inmemory.store.internal.IdentityStore
      extended by de.topicmapslab.majortom.inmemory.virtual.internal.VirtualIdentityStore<T>
All Implemented Interfaces:
IDataStore, IVirtualStore
Direct Known Subclasses:
LazyIdentityStore

public class VirtualIdentityStore<T extends VirtualTopicMapStore>
extends IdentityStore
implements IVirtualStore

Author:
Sven Krosse

Field Summary
private  java.util.Set<java.lang.String> removedIds
           
private  java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> removedItemIdentifiers
           
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> removedSubjectIdentifiers
           
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> removedSubjectLocators
           
private  java.util.Set<java.lang.String> virtualConstructs
           
 
Fields inherited from class de.topicmapslab.majortom.inmemory.store.internal.IdentityStore
capacity
 
Constructor Summary
VirtualIdentityStore(T 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
<X extends de.topicmapslab.majortom.model.core.IConstruct>
X
asVirtualConstruct(X c)
          Creates a virtual stub of the given construct
 de.topicmapslab.majortom.model.core.IScope asVirtualScope(de.topicmapslab.majortom.model.core.IScope scope)
          Creates a virtual stub of the given scope
 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.
 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  T getStore()
          Return the internal stored store instance.
 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.
 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.
 java.util.Set<de.topicmapslab.majortom.model.core.ITopic> getTopics()
          Returns all topics of the internal store
 boolean isRemovedConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
          Checks if the given construct was deleted by the virtual layer.
 boolean isRemovedScope(de.topicmapslab.majortom.model.core.IScope scope)
          Checks if at least one theme of the given scope was deleted by the virtual layer.
 boolean isVirtual(org.tmapi.core.Construct c)
          Checks if the construct is only a part of the virtual memory layer
 boolean isVirtual(de.topicmapslab.majortom.model.core.IScope scope)
          Checks if the scope is only a part of the virtual memory layer
 void removeConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
          Remove the construct from the internal store
 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 removeVirtualConstruct(de.topicmapslab.majortom.model.core.IConstruct construct, de.topicmapslab.majortom.model.core.IConstruct newConstruct)
          Removes the virtual construct from the internal memory layer.
 void setId(de.topicmapslab.majortom.model.core.IConstruct c, java.lang.String id)
          Register the id for the given construct
 void setVirtual(de.topicmapslab.majortom.model.core.IScope scope)
          Specify the given scope as virtual
 
Methods inherited from class de.topicmapslab.majortom.inmemory.store.internal.IdentityStore
containsConstruct, containsIdentifier, containsItemIdentifier, containsItemIdentifiers, containsSubjectIdentifier, containsSubjectIdentifiers, containsSubjectLocator, containsSubjectLocators, createLocator, getConstructItemIdentitiersMap, getIdentifiers, getIdsMap, getItemIdentifiers, getItemIdentifiersMap, getSubjectIdentifiers, getSubjectIdentitifersMap, getSubjectLocators, getSubjectLocatorsMap, getTopicsSet, getTopicSubjectIdentifiersMap, getTopicSubjectLocatorsMap, removeId, replace, replace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.topicmapslab.majortom.inmemory.store.model.IDataStore
replace
 

Field Detail

removedIds

private java.util.Set<java.lang.String> removedIds

virtualConstructs

private java.util.Set<java.lang.String> virtualConstructs

removedItemIdentifiers

private java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> removedItemIdentifiers

removedSubjectIdentifiers

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> removedSubjectIdentifiers

removedSubjectLocators

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.ILocator>> removedSubjectLocators
Constructor Detail

VirtualIdentityStore

public VirtualIdentityStore(T store,
                            int capacity)
constructor

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

getStore

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

Overrides:
getStore in class IdentityStore
Returns:
the store the store instance

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

Overrides:
addSubjectLocator in class IdentityStore
Parameters:
t - the topic
locator - the subject-locator

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

Overrides:
removeSubjectLocator in class IdentityStore
Parameters:
t - the topic

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.

Overrides:
getSubjectLocators in class IdentityStore
Parameters:
t - the topic
Returns:
the locators

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.

Overrides:
bySubjectLocator in class IdentityStore
Parameters:
l - the subject-locator
Returns:
the topic or null

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

Overrides:
addSubjectIdentifier in class IdentityStore
Parameters:
t - the topic
identifier - the subject-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

Overrides:
removeSubjectIdentifier in class IdentityStore
Parameters:
t - the topic
identifier - the subject-identifier

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.

Overrides:
getSubjectIdentifiers in class IdentityStore
Parameters:
t - the topic
Returns:
the identifiers

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.

Overrides:
bySubjectIdentifier in class IdentityStore
Parameters:
l - the subject-identifier
Returns:
the topic or null

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

Overrides:
addItemIdentifer in class IdentityStore
Parameters:
c - the construct
identifier - the item-identifier

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

Overrides:
removeItemIdentifer in class IdentityStore
Parameters:
c - the construct
identifier - the item-identifier

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.

Overrides:
getItemIdentifiers in class IdentityStore
Parameters:
c - the construct
Returns:
the identifiers

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.

Overrides:
byItemIdentifier in class IdentityStore
Parameters:
l - the item-identifier
Returns:
the construct or null

removeTopic

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

Overrides:
removeTopic in class IdentityStore
Parameters:
t - the topic

removeConstruct

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

Overrides:
removeConstruct in class IdentityStore
Parameters:
c - the construct

byId

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

Overrides:
byId in class IdentityStore
Parameters:
id - the id
Returns:
the construct or null

asVirtualConstruct

public <X extends de.topicmapslab.majortom.model.core.IConstruct> X asVirtualConstruct(X c)
                                                                            throws de.topicmapslab.majortom.model.exception.ConstructRemovedException
Creates a virtual stub of the given construct

Parameters:
c - the construct
Returns:
the virtual stub
Throws:
de.topicmapslab.majortom.model.exception.ConstructRemovedException - thrown if the id of the given construct is marked as removed

asVirtualScope

public de.topicmapslab.majortom.model.core.IScope asVirtualScope(de.topicmapslab.majortom.model.core.IScope scope)
                                                          throws de.topicmapslab.majortom.model.exception.ConstructRemovedException
Creates a virtual stub of the given scope

Parameters:
scope - the scope
Returns:
the virtual stub
Throws:
de.topicmapslab.majortom.model.exception.ConstructRemovedException - thrown if at least one contained theme is marked as removed

close

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

Specified by:
close in interface IDataStore
Overrides:
close in class IdentityStore

getTopics

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

Overrides:
getTopics in class IdentityStore
Returns:
all topics

isRemovedConstruct

public boolean isRemovedConstruct(de.topicmapslab.majortom.model.core.IConstruct c)
Checks if the given construct was deleted by the virtual layer.

Parameters:
c - the construct
Returns:
true if the construct was deleted by the virtual layer, false otherwise.

isRemovedScope

public boolean isRemovedScope(de.topicmapslab.majortom.model.core.IScope scope)
Checks if at least one theme of the given scope was deleted by the virtual layer.

Parameters:
scope - the scope
Returns:
true if at least one theme of the given scope was deleted by the virtual layer, false otherwise.

setId

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

Overrides:
setId in class IdentityStore
Parameters:
c - the construct
id - the id

isVirtual

public boolean isVirtual(org.tmapi.core.Construct c)
Checks if the construct is only a part of the virtual memory layer

Parameters:
c - the construct
Returns:
true if the construct is virtual, false otherwise

isVirtual

public boolean isVirtual(de.topicmapslab.majortom.model.core.IScope scope)
Checks if the scope is only a part of the virtual memory layer

Parameters:
scope - the scope
Returns:
true if the scope is virtual, false otherwise

setVirtual

public void setVirtual(de.topicmapslab.majortom.model.core.IScope scope)
Specify the given scope as virtual

Parameters:
scope - the virtual scope

removeVirtualConstruct

public void removeVirtualConstruct(de.topicmapslab.majortom.model.core.IConstruct construct,
                                   de.topicmapslab.majortom.model.core.IConstruct newConstruct)
Removes the virtual construct from the internal memory layer. But does not delete the construct in underlying data store.

Specified by:
removeVirtualConstruct in interface IVirtualStore
Parameters:
construct - the construct to remove
newConstruct - the new construct