|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.tm.TM4JTopicMapBuilderImpl
public class TM4JTopicMapBuilderImpl
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 native interface within TM4J. 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_AT
|
static String |
label_Description
|
static String |
label_Display
|
static String |
label_IsA
|
static String |
label_KindOf
|
static String |
label_Object
|
static String |
label_Predicate
|
static String |
label_Subject
|
static String |
LABEL_UNKNOWN
The label assigned unlabeled Topics. |
static String |
PROPERTY_BUILDER_PROVIDER
The property name of the TopicMapBuilder provider backend. |
static int |
PROVIDER_HIBERNATE
Indicator constant for Hibernate DB provider implementation. |
static int |
PROVIDER_MEMORY
Indicator constant for in-memory provider implementation. |
static int |
PROVIDER_OZONE
Indicator constant for Ozone DB provider implementation. |
static String |
thesaurus_publicId
|
static String |
thesaurus_systemId
|
| Constructor Summary | |
|---|---|
protected |
TM4JTopicMapBuilderImpl()
Default constructor. |
| Method Summary | |
|---|---|
void |
clearTemplates()
Clears any existing Association templates from the cache. |
static Topic[] |
convertScopeToArray(Set scope)
Converts a Set of Topics into an array used as a Scope. |
static Set |
convertScopeToSet(Topic[] scope)
Converts an array of Topics (comprising a Scope) into a Set used as a Scope. |
String |
generateID()
Uses the existing IDGenerator to return a unique ID within this builder's TopicMap. |
Object |
getAssociation(String subject,
String predicate,
String object)
Return an Association provided by the String identifiers (as Topic names) for the subject, predicate, and object of the assertion. |
Set |
getAssociations(Collection associations,
String type,
String scope)
Return Associations in the TopicMap whose type is type and whose scope contains Topic scope. |
String |
getDisplayName(Topic topic,
Topic[] scope)
Returns a String which may be used as a display name in the specified scope. |
String |
getLabel(Topic topic)
A convenience method that calls getLabel(Topic,Topic[])
with a null Scope parameter. |
String |
getLabel(Topic topic,
Topic[] scope)
Returns a label for the provided Topic topic in the optional Topic[] scope, in order of availability. |
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. |
Topic[] |
getOrderedRolesForTemplate(Topic type)
Returns the two player Topics of the Association template matching the Topic type, based on the directedness of the Association. |
Object |
getPredicateTopic()
Returns the predicate typing Topic. |
TopicMapProvider |
getProvider(int backend)
Returns the supporting TopicMapProvider. |
Collection |
getScope(String label)
Returns a Collection of Topics acting as a Scope, provided the label of the single scoping Topic. |
Topic[] |
getScopeTemplate()
Returns a Scope (an array of Topics) whose theme is the Ceryle "template" PSI. |
String |
getSortName(Topic topic,
Topic[] scope)
Returns a String which may be used as a sort name in the specified scope. |
Object |
getSubjectTopic()
Returns the subject typing Topic. |
int |
getTemplateCount()
Returns the number of Association templates for the given TopicMap, from the cache. |
Association |
getTemplateForType(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(boolean update)
Returns any "association templates" for the builder's TopicMap. |
Object |
getTopicByName(String label)
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. |
Object |
getTopicWithSubject(String uri)
Returns a new or existing Topic object having a subject indicator uri, a URI indicating the Topic subject. |
BaseName |
hasLabel(Topic topic,
String label,
Set scope)
A check to see if the Topic already has the label. |
boolean |
hasSubject(Topic topic,
Locator subject)
Returns true if the supplied Topic topic has as one of its subject indicators the Locator subject. |
boolean |
hasSubject(Topic topic,
String uri)
Returns true if the supplied Topic topic has as one of its subject indicators a Locator whose address is the URI uri. |
void |
mergeTopicMap(Object topicmap)
Merge the TopicMap topicmap with the existing Topicmap associated with this builder. |
Locator |
returnLocator(String uri)
Returns a Locator whose address is uri. |
BaseName |
setDisplayName(Topic topic,
String name,
Set scope)
A convenience method that sets a variant name String name on the provided Topic topic. |
BaseName |
setLabel(Topic topic,
String label)
A convenience method that calls setLabel(Topic,String,Set)
with a null Scope parameter. |
BaseName |
setLabel(Topic topic,
String label,
Set scope)
Sets a label for this Topic to the string label, as a Variant whose parameter (scope) is XTM 1.0's "display". |
void |
setLocator(String uri)
Sets the Locator of the builder's TopicMap to uri. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PROPERTY_BUILDER_PROVIDER
PROVIDER_MEMORY,
PROVIDER_OZONE, or PROVIDER_HIBERNATE.
public static final int PROVIDER_MEMORY
public static final int PROVIDER_OZONE
public static final int PROVIDER_HIBERNATE
public static String LABEL_UNKNOWN
public static String label_AT
public static String label_IsA
public static String label_KindOf
public static String label_Display
public static String label_Description
public static String label_Subject
public static String label_Predicate
public static String label_Object
public static String thesaurus_publicId
public static String thesaurus_systemId
| Constructor Detail |
|---|
protected TM4JTopicMapBuilderImpl()
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.
TopicMapException - if an error occurs establishing
services or the Topic Mappublic Object getTopicMap()
getTopicMap in interface TopicMapBuilder
public void mergeTopicMap(Object topicmap)
throws TopicMapException
mergeTopicMap in interface TopicMapBuilderTopicMapException
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 getTopicWithSubject(String uri)
throws TopicMapException
getTopicWithSubject in interface TopicMapBuilderTopicMapException
public Locator returnLocator(String uri)
throws TopicMapException
uri - the String used as the locator address
TopicMapException
public boolean hasSubject(Topic topic,
String uri)
throws TopicMapException
TopicMapException
public boolean hasSubject(Topic topic,
Locator subject)
public BaseName setLabel(Topic topic,
String label)
throws TopicMapException
setLabel(Topic,String,Set)
with a null Scope parameter.
TopicMapException
public BaseName setLabel(Topic topic,
String label,
Set scope)
throws TopicMapException
NOTE: This first locates any existing base names having a "display" variant name, eliminates those base names, and sets this as the only one. This is necessarily ignoring scoping on the base name itself, and is a bit dangerous if the base name itself if valuable. The problem with only removing the variant is we end up with a bunch of basenames whose only purpose was to provide a display name.
If the Scope is specified, it will be added to the resulting basename. This also allows for multiple display names on the same Topic.
topic - the Topic on which to set the name/labellabel - the String used as the labelscope - an optional scope (as a Set of Topics) on the name/label
TopicMapException
public BaseName hasLabel(Topic topic,
String label,
Set scope)
throws TopicMapException
topic - the Topic to checklabel - the label to check forscope - the optional Scope of the BaseName; if present, it must match
TopicMapException - if anything goes wrong
public BaseName setDisplayName(Topic topic,
String name,
Set scope)
throws TopicMapException
TopicMapException
public String getDisplayName(Topic topic,
Topic[] scope)
public String getSortName(Topic topic,
Topic[] scope)
public String getLabel(Topic topic)
getLabel(Topic,Topic[])
with a null Scope parameter.
public String getLabel(Topic topic,
Topic[] scope)
getDisplayName(Topic,Topic[])
public Collection getScope(String label)
throws TopicMapException
getScope in interface TopicMapBuilderlabel - the label of the Topic used for the Scope.
TopicMapExceptionpublic static Set convertScopeToSet(Topic[] scope)
public static Topic[] convertScopeToArray(Set scope)
public Association getTemplateForType(Topic type)
throws TopicMapException
TopicMapException
public Set getTemplates(boolean update)
throws TopicMapException
Since this method is often called repeatedly (e.g., during visualization), the TopicMaps used as parameters for this method are kept in a cache (a Hashtable) and returned using the TopicMap as a key.
The cache is cleared with clearTemplates().
update - if true, regenerates the Set of templates
TopicMapException
public Topic[] getScopeTemplate()
throws TopicMapException
TopicMapExceptionpublic int getTemplateCount()
public void clearTemplates()
public Object getAssociation(String subject,
String predicate,
String object)
throws TopicMapException
The predicate is used as the Association's typing topic, with the subject
and object assigned subject and object roles. These three typing Topics can
be retrieved using getSubjectTopic(), getPredicateTopic(),
and getObjectTopic().
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 Topic[] getOrderedRolesForTemplate(Topic type)
throws TopicMapException
If there isn't an Association template for the provided Topic, null is returned. For example, getOrderedRolesForTemplate(SuperclassSubclass) ("KindOf") would return { Subclass, Superclass } in (subject,object) sentence order.
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 TopicMapProvider getProvider(int backend)
throws TopicMapException
The int backend indicates which backend the processor should use to store topic map information. An unrecognized value will default to the in-memory backend.
Allowed values include:
TopicMapManager interface.
TopicMapExceptionpublic String generateID()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||