org.tm4j.topicmap.utils .TopicMapMerger

Description

A "beanish" helper class for merging topic maps. This class is a bean-like utility to merge multiple SourceAddressPairs into one result TopicMap. A common usage pattern for instances of this class is this:

  • Construct an instance of TopicMapMerger.
  • (optional) Register event listeners so you can deal with property changes. See below for a list of bound properties supported by this class. Changes to most of the properties supported by this class are vetoable, so you are able to register a java.beans.VetoableChangeListener and provide for consistency or sanity checks.
  • (optional) Register a jakarta-commons Log to receive log messages.
  • (optional) Set properties using their setter methods. You can skip this step if you prefer to use the default property values.
  • (optional) Add sources to the merger. For this purpose, you can either invoke #addSource(InputStream, Locator) or one of the other addSource() methods, or you can set all the sources at once, providing #setSources(List) with a List of TopicMapSources. If you omit this step, the application must pipe a topic map to stdin.
  • Invoke #merge() to perform the actual merging operation.
  • Retrieve the merged result topic map using #getResult().
This class supports the following "bound" properties. You can retrieve these using getPropertyName and set them using setPropertyName. Changes to these bound properties are vetoable and may be rolled back by a registered java.beans.VetoableChangeListener.
  • "defaultBaseUri" (String, read/write). The URI to serve as the default base Locator in case none has been specified on a SourceAddressPair being processed. The default for this value is a file: URI pointing to the user's current working directory.
  • "makeConsistent" (boolean, read/write). If true, the result topic map will be post-processed to make sure it is consistent. If false, that step is skipped. The default is true.
  • "mergeExternalTopicMaps" (boolean, read/write). If false, <mergeMap> elements in the source topic maps will be ignored. If true, they will be processed and merged into the result topic map. The default is false as this may be a costly and time-consuming operation.
  • "mergeMapsForExternallyReferencedTopics" (boolean, read/write). If true, the topic maps of externally referenced (via <topicRef>) topics are merged into the result. If false, they will not be merged in. The default is false as this may be a costly and time-consuming operation.
  • "sources" (List, read/write). The list of TopicMapSources to be processed while merging. The default is an empty List.
  • "logger" (org.apache.commons.logging.Log, read/write). The jakarta-commons log to receive logging messages. The default is null, which will cause any debugging output, except "fatal" messages, to be suppressed. This property is inherited from the superclass.
In addition, this class also supports the following non-vetoable bound properties. Changes to these properties cannot be rolled back, but an application may still register a java.beans.PropertyChangeListener to deal with such changes in an appropriate manner.
  • "initialized" (boolean, read-only). true if the instance has been properly initialized, false otherwise. The default (prior to initialization) is false.
  • "merged" (boolean, read-only). true if the topic map merge has been completed, false otherwise. The default (prior to the merging operation) is false.
  • "result" (TopicMap, read-only). The topic map created as the result of the merge. The default (prior to the merging operation) is null.

Note: As for now, this class is capable of processing SourceAddressPairs in addition to TopicMapSources. Don't count on this being available in future versions; SourceAddressPair is now deprecated and will go away in future releases.

Inheritance Hierarchy

Field Summary
DEFAULT_MAKE_CONSISTENT The default value to be used for the "makeConsistent" property.
DEFAULT_MERGE_MAPS_FOR_EXTREF_TOPICS The default value to be used for the "mergeMapsForExternallyReferencedTopics" property.
DEFAULT_PROCESS_MERGEMAP The default value to be used for the "processMergeMap" property.
Method Summary
void addSource(java.io.File in)
Constructs a TopicMapSource from the given File and a corresponding Locator, and adds it to the list of sources.
void addSource(java.io.File in,org.tm4j.net.Locator baseLocator)
Constructs a TopicMapSource from the given File and locator, and adds it to the list of sources.
void addSource(java.io.InputStream in)
Constructs a SourceAddressPair from the given InputStream and the default base locator, and adds it to the list of sources.
void addSource(java.io.InputStream in,org.tm4j.net.Locator baseLocator)
Constructs a TopicMapSource from the given InputStream and locator, and adds it to the list of sources.
void addSource(java.net.URL in)
Constructs a TopicMapSource from the given URL and a corresponding Locator, and adds it to the list of sources.
void addSource(java.net.URL in,org.tm4j.net.Locator baseLocator)
Constructs a TopicMapSource from the given URL and locator, and adds it to the list of sources.
void addSource(org.tm4j.topicmap.source.TopicMapSource source)
Adds a configured TopicMapSource to the list of sources to be processed.
org.tm4j.net.Locator getDefaultBaseLocator()
Returns the default base locator.
java.lang.String getDefaultBaseUri()
Returns the default base URI.
org.tm4j.topicmap.TopicMapProvider getProvider()
Returns the topic map provider used during merging.
org.tm4j.topicmap.TopicMap getResult()
Retrieves the TopicMap that results from the merge operation.
java.util.List getSources()
Retrieves the list of sources to be merged.
void init()
Initializes the object.
void isInitialized()
Determines whether the instance has been properly initialized.
void isMakingConsistent()
Determines whether the instance has been set to post-process merged topic maps to ensure consistency.
void isMerged()
Determines whether the instance has completed the merging process.
void isMergingMapsForExternallyReferencedTopics()
Determines whether the instance is configured to merge in the topic maps associated with any externally referenced topics present in one of the source topic maps.
void isProcessingMergeMap()
Determines whether the instance has been set to include externally referenced topic maps in the merge by processing <mergeMap> elements.
org.tm4j.net.Locator makeDefaultBaseLocator()
Creates the default base locator from the configured default base URI.
org.tm4j.topicmap.TopicMapProvider makeProvider()
Sets up a new TopicMapProvider.
void makeRawMergedTopicMap()
Creates a "raw" merged topic map from the configured sources.
void makeResultConsistent()
Creates a consistent topic map from the "raw" result.
void merge()
Performs the actual merge.
void mergeExternallyReferencedTopicMaps()
Merges in the topic maps of any externally referenced (via <topicRef>) topics present in the source topic maps.
void mergeMergedMaps()
Merges externally referenced topic maps, by processing <mergeMap> elements.
void setDefaultBaseLocator(org.tm4j.net.Locator newLocator)
Sets the default base locator.
void setDefaultBaseUri(java.lang.String newVal)
Sets the default base URI.
void setInitialized(boolean newVal)
Sets the initialization state of the instance.
void setMakeConsistent(boolean newVal)
Instructs the instance to post-process merged topic maps to ensure consistency.
void setMergeMapsForExternallyReferencedTopics(boolean newVal)
Configures the instance to load the topic maps associated with any externally referenced topics (via <topicRef> elements) in the merge result.
void setMerged(boolean newVal)
Sets the state of completion for the merging process.
void setProcessMergeMap(boolean newVal)
Configures the instance to include externally referenced topic maps in the merge by processing <mergeMap> elements.
void setProvider(org.tm4j.topicmap.TopicMapProvider newProvider)
Sets the topic map provider to be used during merging.
void setResult(org.tm4j.topicmap.TopicMap newResult)
Sets the result of the topic map merge.
void setSources(java.util.List newList)
Sets the list of sources to be processed during merging.