Package net.ontopia.topicmaps.entry
Class TopicMapSourceManager
- java.lang.Object
-
- net.ontopia.topicmaps.entry.TopicMapSourceManager
-
- All Implemented Interfaces:
TopicMapRepositoryIF
public class TopicMapSourceManager extends Object implements TopicMapRepositoryIF
INTERNAL: This is the primary implementation of the TopicMapRepositoryIF interface. This class also implements the TopicMapSourceIF interface making it a topic map source that behaves as a facade for the results of multiple topic map sources.The reference keys used are the reference ids retrieved from
reference.getId(). An exception will be thrown if there are duplicate reference keys.The sources that are added to the repository must have unique ids. If the source id is not specified, the source cannot be looked up by id.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,TopicMapReferenceIF>keyrefsprotected Map<TopicMapReferenceIF,String>refkeysprotected booleanrefreshedprotected Map<String,TopicMapSourceIF>smapprotected Set<TopicMapSourceIF>sources
-
Constructor Summary
Constructors Constructor Description TopicMapSourceManager()TopicMapSourceManager(Collection<TopicMapSourceIF> sources)TopicMapSourceManager(TopicMapSourceIF source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSource(TopicMapSourceIF source)PUBLIC: Adds the source to the repository.voidclose()PUBLIC: Closes the repository and releases all resources bound by the repository.protected StringcreateReferenceKey(TopicMapReferenceIF ref)INTERNAL: Creates a unique id.TopicMapStoreIFcreateStore(String refkey, boolean readonly)PUBLIC: Creates a new topic map store for the given topic map id.TopicMapReferenceIFgetReferenceByKey(String key)PUBLIC: Gets a topic map reference by its reference key.StringgetReferenceKey(TopicMapReferenceIF ref)PUBLIC: Gets the key used to identify the reference in the repository.Collection<String>getReferenceKeys()PUBLIC: Returns a collection containing the keys of all references.Collection<TopicMapReferenceIF>getReferences()PUBLIC: Returns a collection containing all references.TopicMapSourceIFgetSourceById(String source_id)PUBLIC: Returns the topic map source that has the given source id.Collection<TopicMapSourceIF>getSources()PUBLIC: Returns an immutable collection containing the TopicMapSourceIFs registered with the topic map repository.voidrefresh()PUBLIC: Refreshes all sources and recreates the reference map.voidremoveSource(TopicMapSourceIF source)PUBLIC: Removes the source from the repository.
-
-
-
Field Detail
-
sources
protected Set<TopicMapSourceIF> sources
-
smap
protected Map<String,TopicMapSourceIF> smap
-
refreshed
protected boolean refreshed
-
keyrefs
protected Map<String,TopicMapReferenceIF> keyrefs
-
refkeys
protected Map<TopicMapReferenceIF,String> refkeys
-
-
Constructor Detail
-
TopicMapSourceManager
public TopicMapSourceManager()
-
TopicMapSourceManager
public TopicMapSourceManager(TopicMapSourceIF source)
-
TopicMapSourceManager
public TopicMapSourceManager(Collection<TopicMapSourceIF> sources)
-
-
Method Detail
-
getReferences
public Collection<TopicMapReferenceIF> getReferences()
Description copied from interface:TopicMapRepositoryIFPUBLIC: Returns a collection containing all references.- Specified by:
getReferencesin interfaceTopicMapRepositoryIF
-
getReferenceKeys
public Collection<String> getReferenceKeys()
Description copied from interface:TopicMapRepositoryIFPUBLIC: Returns a collection containing the keys of all references.- Specified by:
getReferenceKeysin interfaceTopicMapRepositoryIF
-
getReferenceByKey
public TopicMapReferenceIF getReferenceByKey(String key)
Description copied from interface:TopicMapRepositoryIFPUBLIC: Gets a topic map reference by its reference key. Returns null if not found.- Specified by:
getReferenceByKeyin interfaceTopicMapRepositoryIF
-
getReferenceKey
public String getReferenceKey(TopicMapReferenceIF ref)
Description copied from interface:TopicMapRepositoryIFPUBLIC: Gets the key used to identify the reference in the repository.- Specified by:
getReferenceKeyin interfaceTopicMapRepositoryIF
-
createStore
public TopicMapStoreIF createStore(String refkey, boolean readonly)
Description copied from interface:TopicMapRepositoryIFPUBLIC: Creates a new topic map store for the given topic map id. This method effectively delegates the call to the underlying topic map reference. An exception is thrown if the topic map reference cannot be found or any errors occurs while loading it.- Specified by:
createStorein interfaceTopicMapRepositoryIF
-
getSourceById
public TopicMapSourceIF getSourceById(String source_id)
Description copied from interface:TopicMapRepositoryIFPUBLIC: Returns the topic map source that has the given source id.- Specified by:
getSourceByIdin interfaceTopicMapRepositoryIF
-
getSources
public Collection<TopicMapSourceIF> getSources()
Description copied from interface:TopicMapRepositoryIFPUBLIC: Returns an immutable collection containing the TopicMapSourceIFs registered with the topic map repository.- Specified by:
getSourcesin interfaceTopicMapRepositoryIF
-
addSource
public void addSource(TopicMapSourceIF source)
Description copied from interface:TopicMapRepositoryIFPUBLIC: Adds the source to the repository.- Specified by:
addSourcein interfaceTopicMapRepositoryIF
-
removeSource
public void removeSource(TopicMapSourceIF source)
Description copied from interface:TopicMapRepositoryIFPUBLIC: Removes the source from the repository.- Specified by:
removeSourcein interfaceTopicMapRepositoryIF
-
refresh
public void refresh()
Description copied from interface:TopicMapRepositoryIFPUBLIC: Refreshes all sources and recreates the reference map.- Specified by:
refreshin interfaceTopicMapRepositoryIF
-
createReferenceKey
protected String createReferenceKey(TopicMapReferenceIF ref)
INTERNAL: Creates a unique id. This method is used by the refresh method to generate unique ids for topic map references.
-
close
public void close()
Description copied from interface:TopicMapRepositoryIFPUBLIC: Closes the repository and releases all resources bound by the repository. Closing the repository will also close any open topic map references held by the topic map repository as well as the topic map sources added to it.- Specified by:
closein interfaceTopicMapRepositoryIF
-
-