|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.tm.TMAPITopicMapBuilderImpl
public class TMAPITopicMapBuilderImpl
Implements the TopicMapBuilder interface as a
delegating builder/manager for TopicMap objects. To obtain an instance
of this class, see TopicMapBuilderFactory.
Supplied with the TopicMap to be built/populated, it provides a builder that, like an event listener/handler, then receives simplified "events" (whose parameters are entirely text strings) that create Topics, Associations and other TopicMap objects for the TopicMap associated with the builder. This is designed to simplify creation of a TopicMap from the parsing of external source material, so not all TopicMap features are supported.
The public TopicMapBuilder methods are either externally or internally synchronized, as they're designed for thread safety when used in a multiuser (i.e., online) system.
This uses the TMAPI interface within TM4J rather than TM4J's native interface, and also takes advantage of TMAPI-utils to fill in the XML-related holes in the TMAPI interface. The rest of this documentation deals with the methods of the TopicMapBuilder interface.
Because the associations created by this builder require both an association and role types, we must assume a base ontology. This is supplied by the import of an external TopicMap from an LTM file. If the file is not available for import, stub topics are created as necessary.
Note that because this builder is expected to repeatedly receive the same set of events (since the source may be multiple users triggering the same event listeners), the builder takes responsibility for duplicate suppression of Topics, TopicNames, Associations, Occurrences, etc.
TopicMapBuilder| Field Summary | |
|---|---|
static String |
label_IsA
|
static String |
label_KindOf
|
static String |
thesaurus_publicId
|
static String |
thesaurus_systemId
|
| Constructor Summary | |
|---|---|
protected |
TMAPITopicMapBuilderImpl()
Constructor for a TMAPITopicMapBuilderImpl. |
| Method Summary | |
|---|---|
void |
clearCaches()
Clears any existing indices and the Association Template cache. |
Object |
getAssociation(String subject,
String predicate,
String object)
Creates a new Association or returns an existing one matching the provided triple. |
Set |
getAssociations(Collection associations,
String type,
String scope)
Return Associations in the TopicMap whose type is type and whose scope contains Topic scope. |
static Properties |
getDefaultProperties()
Returns a property set to set the TMAPI TopicMapSystem to use the TM4J in-memory backend. |
Object |
getObjectTopic()
Returns the object typing Topic. |
Object |
getOccurrence(String topic,
String ref)
Creates a new occurrence as a contained object in the Topic topic using the String ref as a resource Locator. |
Object |
getOccurrence(String topic,
String type,
String data)
Creates a new occurrence as a contained object in the Topic topic using the String type as the Occurrence type and data as the occurrence data. |
Object |
getPredicateTopic()
Returns the predicate typing Topic. |
Collection |
getScope(Object topic)
Returns a Collection of Topics acting as a Scope, provided a scoping Topic. |
Collection |
getScope(String label)
Returns a Collection of Topics acting as a Scope, provided with a single String, creating or retrieving a Topic (as necessary) based on that String as a Topic label. |
org.tmapi.index.core.ScopedObjectsIndex |
getScopedObjectsIndex()
Returns an index over ScopedObjects for this builder's TopicMap. |
Object |
getSubjectTopic()
Returns the subject typing Topic. |
int |
getTemplateCount()
Returns the number of Association templates for this builder's TopicMap, from the cache. |
org.tmapi.core.Association |
getTemplateForType(org.tmapi.core.Topic type)
Returns the Association used as the template for the provided Topic if it matches any of the available Association Template typing Topics. |
Set |
getTemplates()
Returns any "association templates" for this builder's TopicMap. |
Locator |
getTM4JLocator(org.tmapi.core.Locator locator)
Returns a TM4J Locator provided a TMAPI Locator. |
Topic |
getTM4JTopic(org.tmapi.core.Topic topic)
Returns a TM4J Topic provided a TMAPI Topic. |
TopicMap |
getTM4JTopicMap(org.tmapi.core.TopicMap topicmap)
Returns a TM4J TopicMap provided a TMAPI TopicMap. |
Object |
getTopicByName(String label)
Returns either a new or existing Topic object with a Topic label, creating the Topic as necessary. |
Object |
getTopicByName(String label,
Collection scope)
Returns either a new or existing Topic object with a Topic label, creating the Topic as necessary. |
Object |
getTopicMap()
Return the TopicMap associated with this builder. |
org.tmapi.index.core.TopicNamesIndex |
getTopicNamesIndex()
Returns an index over the TopicNames for this builder's TopicMap. |
org.tmapi.index.core.TopicsIndex |
getTopicsIndex()
Returns an index over the Topics for this builder's TopicMap. |
Object |
getTopicWithSubject(String uri)
Returns a new or existing Topic object having a subject indicator uri, a URI indicating the Topic subject. |
void |
makeConsistent()
Calls the static XTMUtils method of the same name to process this builder's TM4J TopicMap into a consistent Topic Map as according to the XTM 1.0 Specification. |
void |
mergeTopicMap(Object topicmap)
Merge the TopicMap topicmap with the existing Topicmap associated with this builder. |
void |
postProcess()
Performs any post-processing (such as consistency checking) on this builder's TopicMap. |
void |
setLocator(String uri)
This causes creation of the initial TopicMap, setting its base Locator to uri. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String thesaurus_publicId
public static String thesaurus_systemId
public static String label_IsA
public static String label_KindOf
| Constructor Detail |
|---|
protected TMAPITopicMapBuilderImpl()
throws TopicMapException
TopicMapException| Method Detail |
|---|
public void setLocator(String uri)
throws IllegalStateException,
TopicMapException
setLocator in interface TopicMapBuilderuri - the URI identifier of the TopicMap.
IllegalStateException - if this method is called after
the value has already been set.
TopicMapExceptionpublic Object getTopicMap()
getTopicMap in interface TopicMapBuilder
public void postProcess()
throws TopicMapException
This is not a TopicMapBuilder API method.
TopicMapExceptionpublic void mergeTopicMap(Object topicmap)
mergeTopicMap in interface TopicMapBuilder
public Locator getTM4JLocator(org.tmapi.core.Locator locator)
throws TopicMapException
locator - the TMAPI Locator.
TopicMapException
public Topic getTM4JTopic(org.tmapi.core.Topic topic)
throws TopicMapException
topic - the TMAPI Topic.
TopicMapException
public TopicMap getTM4JTopicMap(org.tmapi.core.TopicMap topicmap)
throws TopicMapException
topicmap - the TMAPI TopicMap.
TopicMapException
public Object getSubjectTopic()
throws TopicMapException
getSubjectTopic in interface TopicMapBuilderTopicMapExceptionPSIUtils.psiSubject(TopicMap)
public Object getPredicateTopic()
throws TopicMapException
getPredicateTopic in interface TopicMapBuilderTopicMapExceptionPSIUtils.psiPredicate(TopicMap)
public Object getObjectTopic()
throws TopicMapException
getObjectTopic in interface TopicMapBuilderTopicMapExceptionPSIUtils.psiObject(TopicMap)
public Object getTopicByName(String label)
throws TopicMapException
getTopicByName in interface TopicMapBuilderlabel - the Topic label (its primary identifier).
TopicMapException
public Object getTopicByName(String label,
Collection scope)
throws TopicMapException
label - the Topic label (its primary identifier).scope - the optional Scope on the label.
TopicMapExceptionpublic Object getTopicWithSubject(String uri)
getTopicWithSubject in interface TopicMapBuilder
public Collection getScope(String label)
throws TopicMapException
getScope in interface TopicMapBuilderlabel - the label of the Topic used for the Scope.
TopicMapException
public Collection getScope(Object topic)
throws TopicMapException
topic - the Topic used for the Scope.
TopicMapExceptionpublic int getTemplateCount()
public void clearCaches()
public org.tmapi.core.Association getTemplateForType(org.tmapi.core.Topic type)
public Set getTemplates()
Since this method is often called repeatedly (e.g., during visualization), the TopicMaps used as parameters for this method are kept in a cache. The cache lookup only occurs if the parameter is null; if non-null, the provided HashSet is used as the container and forces a rebuild of the list of templates.
The template cache (as well as any existing indices) is
cleared with clearCaches().
public org.tmapi.index.core.ScopedObjectsIndex getScopedObjectsIndex()
public org.tmapi.index.core.TopicsIndex getTopicsIndex()
public org.tmapi.index.core.TopicNamesIndex getTopicNamesIndex()
public Object getAssociation(String subject,
String predicate,
String object)
throws TopicMapException
getAssociation in interface TopicMapBuildersubject - The name of the subject of the assertion.predicate - The name of the predicate of the assertion.object - The name of the object of the assertion.
TopicMapException
public Set getAssociations(Collection associations,
String type,
String scope)
throws TopicMapException
getAssociations in interface TopicMapBuilderassociations - the optional original collection of Associations;
when null all in the TopicMap are used.type - the label of the optional typing Topicscope - the label of the optional scoping Topic
TopicMapException
public Object getOccurrence(String topic,
String type,
String data)
throws TopicMapException
getOccurrence in interface TopicMapBuilderTopicMapException
public Object getOccurrence(String topic,
String ref)
throws TopicMapException
getOccurrence in interface TopicMapBuilderTopicMapException
public void makeConsistent()
throws TopicMapException
TopicMapExceptionXTMUtilspublic static Properties getDefaultProperties()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||