|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.tm.TopicMapProcessor
public class TopicMapProcessor
Defines a processor for topic map events generated by a parser (i.e., a topic map engine), providing access to a consistent TopicMap object and individual objects within. This also makes available a number of static and non-static utility methods for querying and modifying the TopicMap. The latter makes this a rather large class, but for convenience' sake this seems a better approach than breaking off a utility class that would exist in memory anyway.
Speaking of which, there are several utility interfaces and classes that
will generally be included with a TopicMapProcessor:
Inferencer, PSIUtils,
TopicLocatorPool, TopicMapBuilder,
TopicNameIndex, plus all the utility classes that
are part of TM4J.
TopicMapManager interface.
It currently does not fully implement the API at this time. Some of the
existing notes in the class still pertain to the API and these are not
being altered because the plan is to eventually re-implement it.
TopicMap,
TopicMapFactory,
TopicMapProvider| Field Summary | |
|---|---|
static boolean |
exportImpliedIDs
When true, exported topic maps include implied IDs. |
static boolean |
exportResourceIDs
When true, exported topic maps include resource IDs. |
static String |
idPrefix
IDGenerator prefix for all auto-created IDs. |
static String |
PROP_REFLEXIVE_TO
The base URI for the property determining if reflexive relations are represented as two "To" (value="true") or two "From" (value="false", or unset) roles. |
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. |
protected boolean |
useCeryleLTMProcessor
When true, uses Ceryle's LTM processor rather than TM4J's. |
| Constructor Summary | |
|---|---|
protected |
TopicMapProcessor(int backend)
Constructor with an int backend indicating which backend the processor should use to store topic map information. |
| Method Summary | |
|---|---|
boolean |
addType(Topic topic,
Topic type)
Add the typing Topic to the Topic, returning true if successful. |
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. |
Association |
createBinaryAssociation(Topic type,
Topic[] scope,
Topic role1,
Topic player1,
Topic role2,
Topic player2)
Creates a binary association between the two players having two roles, a type and optional scope. |
Topic |
createFacet(Topic faceted,
Topic[] facetScope,
Topic facetType,
Topic facetConstraint,
String facetValue)
Creates a new facet for the Topic faceted. |
TopicMap |
createTopicMap(Locator locator)
Creates a new, empty TopicMap provided a base Locator. |
TopicMap |
createTopicMap(TypedInputSource source)
Parses a topic map document (in XTM, LTM, or AsTMa= notation), specified by the system identifier (URI) systemId, returning the TopicMap object. |
void |
deregisterProvider(String id)
Deregisters the provider whose ID is id. |
String |
generateID()
Uses the existing IDGenerator to return a unique ID. |
String |
generateID(TopicMap topicmap)
Uses the existing IDGenerator to return a unique ID within the provided TopicMap topicmap. |
String |
generateID(TopicMap topicmap,
String prefix)
Uses the existing IDGenerator to return a unique ID within the provided TopicMap topicmap, prefixed with the String prefix. |
String |
generateIDFromName(TopicMap topicmap,
String name)
Uses the existing IDGenerator to return a unique ID within the provided TopicMap topicmap based on the String name. |
Topic |
getAboutTopic(TopicMap topicmap,
boolean create)
Returns the 'about' Topic of TopicMap topicmap, creating it if it does not yet exist, if the boolean create is true. |
Association |
getBinaryAssociation(Topic type,
Topic topic1,
Topic topic2)
Returns the first found (existing) Association having type between Topic topic1 and topic2 (paying no attention to which role each plays). |
String |
getDescription(Topic topic)
Returns a textual description of the supplied Topic topic, considered the first encountered Occurrence of a type matching the Ceryle 'description' PSI http://purl.org/ceryle/psi/ceryle/#Description. |
String |
getDisplayName(Topic topic,
Topic[] scope)
Returns a String which may be used as a display name in the specified scope. |
String |
getID()
Returns a unique identifying String for this TopicMapProcessor, based on a timestamp. |
static String |
getIdentifier(TopicMap topicmap)
Returns a String identifier for the provided TopicMap topicmap, its name if available, otherwise, its base locator address. |
IDFactory |
getIDFactory()
Returns the existing IDFactory. |
String |
getIDofTopicType(TopicMap tm,
Topic type)
Returns the ID of the first-encounted Topic having the given type. |
Inferencer |
getInferencer()
Return a lazily-created Inferencer. |
String |
getLabel(Association assoc)
Returns a label for the provided Association assoc by using its typing topic's display name, one of its base names, or its ID. |
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. |
int |
getOccurrenceCount(Topic topic,
boolean ignoreUtility)
Returns the number of Occurrences. |
Occurrence |
getOccurrenceOfType(Topic topic,
Topic type)
Returns the first encountered occurrence in the supplied Topic topic, of an occurrence whose type matches type. |
Collection |
getOccurrences(Topic topic,
boolean ignoreDescription)
Returns the Occurrences of Topic topic as a Set. |
Topic[] |
getOrderedRolesForTemplate(Topic type)
Returns the two player Topics of the Association template matching the Topic type, based on the directedness of the Association. |
Set |
getPlayersOfRoleInTypedAssociation(Topic topic,
Topic topicType,
Topic assocType,
Topic role,
Set set)
Returns all Topics playing role in associations with the Topic topic. |
TopicLocatorPool |
getPool()
Returns the TopicLocatorPool used by this TopicMapProcessor. |
TopicMapProvider |
getProvider()
A functional synonym for getTopicMapProvider(TopicMap). |
TopicMapProvider |
getProvider(TopicMap topicmap)
Returns the TopicMapProvider for the TopicMap topicmap. |
Map |
getProviders()
Returns a map containing the TopicMapProviders with their IDs as keys. |
PSIUtils |
getPSI()
Returns the PSIUtils used by this TopicMapProcessor. |
Vector |
getPublicationMetadata(TopicMap topicmap)
Returns the publication metadata as a Vector of sorted Occurrences, an empty Vector if none are available. |
String |
getScopedBaseName(Topic topic,
Topic[] scope)
Returns a base name String from the Topic topic, giving preference to one in the optional Topic[] scope. |
Occurrence |
getSelectedOccurrence(Topic topic,
boolean acceptAny)
Returns the selected occurrence of the provided Topic using the PSI Selected as indicator. |
String |
getSortName(Topic topic,
Topic[] scope)
Returns a String which may be used as a sort name in the specified scope. |
int |
getTemplateCount(TopicMap topicmap)
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. |
String |
getTemplateLabel(Topic topic)
Returns an appropriate label (display name) for a Topic used as an association template. |
Set |
getTemplates(TopicMap topicmap)
Returns any "association templates" for TopicMap topicmap. |
Topic |
getTopicByID(TopicMap topicmap,
String id)
Return the Topic matching the ID id, null if it does not exist. |
Topic |
getTopicByName(TopicMap tm,
String label,
boolean create)
Returns a Topic with a base name in the XTM 'Display' scope of label, throwing a TopicMapException if unable to locate and/or create the Topic. |
TopicMap |
getTopicMap(Locator locator)
Returns the TopicMap specified by the Locator loc, null if no match is found. |
Collection |
getTopicMapBaseLocators()
Returns a Collection of the base locators of all TopicMap objects currently available from this TopicMapProcessor. |
Topic |
getTopicMapIdentifier(TopicMap topicmap)
Returns a Topic whose subject is its parent TopicMap. |
Collection |
getTopicMapProviders()
Returns the TopicMapProvider for the TopicMap topicmap as a Collection. |
Collection |
getTopicMaps()
Returns a Collection view of the TopicMap objects created by this TopicMapProcessor, an empty set (not null) if none exist. |
Set |
getTopicProperties(Topic topic,
String baseURI)
Returns all properties (i.e., Occurrences in the scope of the 'facet' PSI) of the supplied Topic topic having a type whose subject domain starts with the String baseURI. |
String |
getTopicProperty(Topic topic,
Topic type)
Returns a property of the supplied Topic topic as an Occurrence having a type. |
Collection |
getTopicsOfType(TopicMap tm,
Topic type)
Returns a Collection containing all Topics having the given type. |
BaseName |
hasLabel(Topic topic,
String label,
Set scope)
A check to see if the Topic already has the label. |
Occurrence |
hasOccurrence(Topic topic,
Topic type,
Locator locator)
Provided with a Topic topic, returns the Occurrence containing the Locator locator as a data locator (not inline). |
Occurrence |
hasOccurrence(Topic topic,
Topic type,
String data)
Provided with a Topic topic, returns the Occurrence containing the String data as a data locator (inline). |
static boolean |
hasSubject(Topic topic,
Locator subject)
Returns true if the supplied Topic topic has as one of its subject indicators the Locator subject. |
static 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. |
boolean |
hasTemplateForType(Topic type)
Returns true if the provided Topic matches any of the available Association Template typing Topics. |
boolean |
hasTopicMap(Locator locator)
Returns true if the provider contains a TopicMap with the base Locator locator. |
boolean |
isEditableType(Topic type)
Returns true if either the type is null, or it is not one of the standard, non-editable typing Topics. |
boolean |
isInSubjectDomain(Topic topic,
String baseURI)
Similar to hasSubject(), returns true if the Topic has a subject matching the base URI part of the supplied Locator. |
Locator |
isProvidedAs(TopicMap topicmap)
Checks to see if the TopicMap topicmap is provided by the provider, returning the Locator by which it is identified. |
boolean |
isProvidedTopicMap(Locator locator)
Returns true if the TopicMap having Locator locator is provided by the TopicMapProvider. |
boolean |
isProvidedTopicMap(TopicMap topicmap)
Returns true if the TopicMap topicmap is provided by the TopicMapProvider (comparing using object equality). |
boolean |
isSelected(Occurrence occur)
Returns true if the provided Occurrence is the selected occurrence of its parent Topic. |
boolean |
isTemplate(Association assoc)
Returns true if the provided Association assoc is an association template, that is, has a scope matching the PSI Template. |
boolean |
isUtilityOccurrence(Occurrence occur)
For lack of a better term, "utility" occurrences are those whose purpose is not meant to be seen (to the user) as an occurrence, such as the Topic color, location, or description. |
void |
listTemplates(TopicMap topicmap)
Prints the list of association templates for the TopicMap topicmap to System.err. |
void |
listTopicMaps()
Prints the current list of stored TopicMaps to the MessageHandler. |
void |
listTopics(String desc,
Collection c)
Prints the current list of Topics in the provided Collection to System.err, including the description String. |
TopicMap |
makeConsistent(TopicMap topicmap)
Calls the static XTMUtils method of the same name to process the provided TopicMap topicmap into a consistent topic map as according to the XTM 1.0 Specification. |
boolean |
matchesSubject(Topic topic,
Set topics)
Returns true if any of the subject identifiers of topic match any of the subject identifiers of any of the Topics in Set topics. |
boolean |
matchesTemplate(Topic type,
Topic fromRole,
Topic toRole)
Returns true if the provided parameters match an existing Association template (which must be in the scope of the PSI Template). |
void |
mergeTopicMap(TopicMap baseTM,
Locator mergeLocator)
Merges the Topic Map document located at Locator mergeLoc with the base Topic Map baseTM. |
Topic |
mergeTopics(Set topics)
Manually merges the Set of Topics, eliminating duplicate names, occurrences, and subject indicators, returning the merged Topic. |
TopicMapProvider |
registerProvider(String providerFactoryClassName,
Properties props)
Registers a new TopicMapProvider with the manager (unimplemented). |
TopicMapProvider |
registerProvider(String id,
String providerFactoryClassName,
Properties props)
Registers a new provider with the manager. |
boolean |
removeAssociation(Association assoc)
Removes Association assoc, returning true if successful. |
Set |
removeAssociationsOfType(TopicMap tm,
Topic type)
Remove all Associations having a type matching the Topic type, as well as the TG ANode and connected GraphEdges. |
boolean |
removeFacets(Topic faceted,
Topic type)
Removes any facets of the Topic faceted having typing Topic type. |
boolean |
removeName(Topic topic,
BaseName basename)
Remove the BaseName from the Topic, returning true if successful. |
boolean |
removeOccurrence(Topic topic,
Occurrence occur)
Removes Occurrence occur from Topic topic, returning true if successful. |
boolean |
removeTopic(Topic topic)
Removes Topic topic, returning true if successful. |
boolean |
removeTopicMap(Locator locator)
Permanently removes the TopicMap having the base locator locator from the provider. |
boolean |
removeType(Topic topic,
Topic type)
Remove the typing Topic from the Topic, returning true if successful. |
void |
reset()
Resets the TopicMapProcessor, removing any previously-processed TopicMap objects. |
Locator |
resolveEntity(Locator source)
Attempts to resolve the system identifier in the provided Locator source using the catalog resolver. |
void |
resolveMergeMaps(TopicMap baseTM)
Resolves any mergeMap directives in the provided TopicMap baseTM. |
Association |
returnAssociationWithID(TopicMap topicmap,
String id)
Returns either the existing Association whose ID is id, or a new Association if a matching one is not already available. |
Locator |
returnLocator(String uriref)
Returns a Locator whose address is uri. |
Locator |
returnLocator(TopicMap topicmap,
String uriref)
Returns a Locator whose address is uri. |
Topic |
returnTopicByID(TopicMap topicmap,
String id)
Returns either the existing Topic whose ID is id, or a new Topic if a matching one is not already available. |
Topic |
returnTopicByLocator(TopicMap topicmap,
String id,
Locator locator)
Returns a Topic having a subject defined by a PSI (a URI, in this case as a Locator), returning null if for some reason the Topic cannot be created. |
Topic |
returnTopicByURI(TopicMap topicmap,
String uri)
Returns a Topic having a subject defined by an ID or PSI (a URI), returning null if for some reason the Topic cannot be created. |
Topic |
returnTopicWithPSI(TopicMap topicmap,
String id,
String uri)
If a Topic having a subject matching the PSI exists, it is returned (note that the supplied ID is ignored in this case). |
Set |
searchOnLabel(TopicMap topicmap,
String searchString,
boolean strict,
boolean caseSensitive)
Search the TopicMap by label (display name), either as a strict or contains match. |
Occurrence |
setDescription(Topic topic,
String id,
String text)
Sets the textual description of the supplied Topic topic as an Occurrence whose type is the PSI http://purl.org/ceryle/psi/ceryle/#Description, with a required ID value id. |
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". |
Occurrence |
setOccurrence(Topic topic,
String id,
Object value,
Topic type,
Topic[] scope)
Sets an occurrence of the supplied Topic topic with an optional typing Topic type and optional Topic[] scope, with a required ID value id. |
void |
setSelected(Occurrence occur,
boolean selected)
When selected is true, sets the provided Occurrence as the selected Occurrence of its parent Topic, removing the "Selected PSI" theme from all other Occurrences of the Topic. |
Occurrence |
setTopicProperty(Topic topic,
Topic type,
String value)
Sets a property of the supplied Topic topic as an Occurrence having a type. |
boolean |
topicExists(TopicMap topicmap,
String id)
A convenience method that returns true if a Topic whose ID is id exists. |
Set |
traverse(Topic topic,
int direction,
int depth,
boolean taxonomic)
Traverses the parent TopicMap beginning with Topic topic, in the direction set by the int direction to a depth of depth. |
void |
writeTopicMap(TopicMap topicmap,
File file)
A convenience method that serializes the provided TopicMap object to the File file. |
void |
writeTopicMap(TopicMap topicmap,
OutputStream outputstream)
Serializes the provided TopicMap object to the OutputStream os. |
void |
writeTopicMap(TopicMap topicmap,
Writer writer)
Deprecated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PROP_REFLEXIVE_TO
public static final int PROVIDER_MEMORY
public static final int PROVIDER_OZONE
public static final int PROVIDER_HIBERNATE
public static boolean exportResourceIDs
public static boolean exportImpliedIDs
public static String idPrefix
protected boolean useCeryleLTMProcessor
| Constructor Detail |
|---|
protected TopicMapProcessor(int backend)
throws TopicMapException
Allowed values include:
TopicMapServices.
TopicMapException - if unable to create the provider| Method Detail |
|---|
public String getID()
public Map getProviders()
public TopicMapProvider getProvider()
public TopicMapProvider getProvider(TopicMap topicmap)
This method is part of an implementation of the
TopicMapManager interface.
public boolean hasTopicMap(Locator locator)
throws TopicMapException
TopicMapExceptionpublic TopicMap getTopicMap(Locator locator)
This method is part of an implementation of the
TopicMapManager interface.
public TopicMap createTopicMap(Locator locator)
throws TopicMapException
TopicMapException - if the TopicMap already exists or can't be created.
public TopicMap createTopicMap(TypedInputSource source)
throws TopicMapException
NOTE: support for AsTMa= notation is not available in post 1.0alpha11 versions.
TopicMapException
public boolean removeTopicMap(Locator locator)
throws TopicMapException
TopicMapException
public Topic mergeTopics(Set topics)
throws TopicMapException
TopicMapExceptionpublic Locator resolveEntity(Locator source)
public void resolveMergeMaps(TopicMap baseTM)
throws TopicMapProviderException
TopicMapProviderException
public void mergeTopicMap(TopicMap baseTM,
Locator mergeLocator)
throws TopicMapProviderException
TopicMapProviderExceptionpublic Locator isProvidedAs(TopicMap topicmap)
public Topic getTopicByName(TopicMap tm,
String label,
boolean create)
throws TopicMapException
Note that this is not optimized as it does not use an index.
tm - the parent TopicMaplabel - the label of the returned Topiccreate - if true, the Topic will be created if it does not exist
TopicMapException - if unable to locate and/or create the Topic
IllegalStateException - if this method is called prior to creation of the TopicMap
public boolean removeTopic(Topic topic)
throws TopicMapException
TopicMapExceptionpublic Inferencer getInferencer()
Inferencer,
InferencerImplpublic static Topic[] convertScopeToArray(Set scope)
public static Set convertScopeToSet(Topic[] scope)
public static String getIdentifier(TopicMap topicmap)
public IDFactory getIDFactory()
public String generateID(TopicMap topicmap)
public String generateIDFromName(TopicMap topicmap,
String name)
public String generateID(TopicMap topicmap,
String prefix)
public String generateID()
public void reset()
public TopicLocatorPool getPool()
TopicLocatorPoolpublic PSIUtils getPSI()
TopicLocatorPoolpublic Collection getTopicMapBaseLocators()
This method is part of an implementation of the
TopicMapManager interface.
public Collection getTopicMapProviders()
This method is part of an implementation of the
TopicMapManager interface.
public Collection getTopicMaps()
This method is part of an implementation of the
TopicMapManager interface.
public