org.tm4j.topicmap.source
Class SerializedTopicMapSource

java.lang.Object
  extended byorg.tm4j.topicmap.source.SerializedTopicMapSource
All Implemented Interfaces:
TopicMapSource

public class SerializedTopicMapSource
extends java.lang.Object
implements TopicMapSource

This is a implementation of the TopicMapSource Interface representing serialized TopicMaps. It uses a TopicMapBuilder to build the TopicMap.
Usage:

TopicMapProviderFactory factory = TopicMapProviderFactory.newInstance();
TopicMapProvider provider = factory.newTopicMapProvider();
TopicMapSource source = new SerializedTopicMapSource("c:\\temp\\opera.xtm");
TopicMap map = provider.addTopicMap(source);

Author:
Harald Kuhn

Constructor Summary
SerializedTopicMapSource(java.io.File file)
          Creates a SerializedTopicMapSource representing a file specified by the given File Object
SerializedTopicMapSource(java.io.File file, Locator base)
          Creates a SerializedTopicMapSource representing a file specified by the given File Object
SerializedTopicMapSource(java.io.File file, Locator base, TopicMapBuilder builder)
          Creates a SerializedTopicMapSource representing a file specified by the given File Object.
SerializedTopicMapSource(java.io.File file, TopicMapBuilder builder)
          Creates a SerializedTopicMapSource representing a file specified by the given File Object.
SerializedTopicMapSource(java.io.InputStream stream, Locator base)
          Creates a SerializedTopicMapSource representing a stream
SerializedTopicMapSource(java.io.InputStream stream, Locator base, TopicMapBuilder builder)
          Creates a SerializedTopicMapSource representing the given InputStream
SerializedTopicMapSource(java.io.Reader reader, Locator base)
          Creates a SerializedTopicMapSource connected to a Reader
SerializedTopicMapSource(java.io.Reader reader, Locator base, TopicMapBuilder builder)
          Creates a SerializedTopicMapSource representing the given Reader
SerializedTopicMapSource(java.lang.String fileName)
          Creates a SerializedTopicMapSource representing a file specified by its name
SerializedTopicMapSource(java.lang.String fileName, Locator base)
          Creates a SerializedTopicMapSource representing a file specified by its name
SerializedTopicMapSource(java.lang.String fileName, Locator base, TopicMapBuilder builder)
          Creates a SerializedTopicMapSource representing a file identified by the given fileName
SerializedTopicMapSource(java.lang.String fileName, TopicMapBuilder builder)
          Creates a SerializedTopicMapSource representing a file specified by its name.
 
Method Summary
 java.lang.String getBaseAddress()
          Returns the base address of this source.
 Locator getBaseLocator()
          Returns the base locator for this source.
 void populateTopicMap(TopicMap map)
          a callback method called by the TopicMapProvider implementation to populate the topic map
 void populateTopicMap(TopicMap map, Topic[] addedThemes)
           
 void populateTopicMap(TopicMap map, TopicMapProvider provider)
          A callback method called by the TopicMapProvider implementation to populate the topic map.
 void populateTopicMap(TopicMap map, TopicMapProvider provider, Topic[] addedThemes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializedTopicMapSource

public SerializedTopicMapSource(java.lang.String fileName)
                         throws java.io.FileNotFoundException,
                                java.net.MalformedURLException
Creates a SerializedTopicMapSource representing a file specified by its name

Parameters:
fileName - the name of the file
Throws:
java.io.FileNotFoundException - thrown if no file can be found for fileName
java.net.MalformedURLException

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.File file)
                         throws java.io.FileNotFoundException,
                                java.net.MalformedURLException
Creates a SerializedTopicMapSource representing a file specified by the given File Object

Parameters:
file - a File containing the serialized topic map data to be parsed
Throws:
java.io.FileNotFoundException - thrown if file does not exist
java.net.MalformedURLException

SerializedTopicMapSource

public SerializedTopicMapSource(java.lang.String fileName,
                                Locator base)
                         throws java.io.FileNotFoundException,
                                java.net.MalformedURLException
Creates a SerializedTopicMapSource representing a file specified by its name

Parameters:
fileName - the name of the file
base - a Locator for the Source
Throws:
java.io.FileNotFoundException - thrown if no file can be found for fileName
java.net.MalformedURLException

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.InputStream stream,
                                Locator base)
Creates a SerializedTopicMapSource representing a stream

Parameters:
stream - the InputStream used as source for the tm
base - a Locator for the Source

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.Reader reader,
                                Locator base)
Creates a SerializedTopicMapSource connected to a Reader

Parameters:
reader - the Reader used as source for the tm
base - a Locator for the Source

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.File file,
                                Locator base)
                         throws java.io.FileNotFoundException
Creates a SerializedTopicMapSource representing a file specified by the given File Object

Parameters:
file - a File containing the serialized topic map data to be parsed
base - a Locator for the Source
Throws:
java.io.FileNotFoundException - thrown if file does not exist

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.File file,
                                TopicMapBuilder builder)
                         throws java.io.FileNotFoundException,
                                java.net.MalformedURLException
Creates a SerializedTopicMapSource representing a file specified by the given File Object. The given TopicMapBuilder is used to build the tm from this object.

Parameters:
file - a File containing the serialized topic map data to be parsed
builder - the TopicMapBuilder implementation
Throws:
java.io.FileNotFoundException - thrown if file does not exist
java.net.MalformedURLException

SerializedTopicMapSource

public SerializedTopicMapSource(java.lang.String fileName,
                                TopicMapBuilder builder)
                         throws java.io.FileNotFoundException,
                                java.net.MalformedURLException
Creates a SerializedTopicMapSource representing a file specified by its name. The given TopicMapBuilder is used to build the tm.

Parameters:
fileName - the name of the file
builder - the TopicMapBuilder implementation
Throws:
java.io.FileNotFoundException - thrown if file does not exist
java.net.MalformedURLException

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.File file,
                                Locator base,
                                TopicMapBuilder builder)
                         throws java.io.FileNotFoundException
Creates a SerializedTopicMapSource representing a file specified by the given File Object. The given TopicMapBuilder is used to build the tm from this object.

Parameters:
file - a File containing the serialized topic map data to be parsed
builder - the TopicMapBuilder implementation
base - a Locator for the Source
Throws:
java.io.FileNotFoundException - thrown if file does not exist

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.Reader reader,
                                Locator base,
                                TopicMapBuilder builder)
Creates a SerializedTopicMapSource representing the given Reader

Parameters:
reader - the Reader used as source for the tm
base - a Locator for the Source
builder - the TopicMapBuilder implementation

SerializedTopicMapSource

public SerializedTopicMapSource(java.lang.String fileName,
                                Locator base,
                                TopicMapBuilder builder)
                         throws java.io.FileNotFoundException
Creates a SerializedTopicMapSource representing a file identified by the given fileName

Parameters:
fileName - the name of the file
base - a Locator for the Source
builder - the TopicMapBuilder implementation
Throws:
java.io.FileNotFoundException - thrown if there is no file with the given name

SerializedTopicMapSource

public SerializedTopicMapSource(java.io.InputStream stream,
                                Locator base,
                                TopicMapBuilder builder)
Creates a SerializedTopicMapSource representing the given InputStream

Parameters:
stream - the InputStream which is connected to a serialized TopicMap
base - a Locator for the Source
builder - the TopicMapBuilder implementation
Method Detail

getBaseAddress

public java.lang.String getBaseAddress()
Description copied from interface: TopicMapSource
Returns the base address of this source.

Specified by:
getBaseAddress in interface TopicMapSource
Returns:
the base address of the source, as a String

getBaseLocator

public Locator getBaseLocator()
Description copied from interface: TopicMapSource
Returns the base locator for this source.

Specified by:
getBaseLocator in interface TopicMapSource
Returns:
the base locator specified for this source as a Locator object, or null if no explicit base locator was provided in the source constructor.

populateTopicMap

public void populateTopicMap(TopicMap map)
                      throws TopicMapProcessingException
Description copied from interface: TopicMapSource
a callback method called by the TopicMapProvider implementation to populate the topic map

Specified by:
populateTopicMap in interface TopicMapSource
Parameters:
map - the TopicMap instance to be populated
Throws:
TopicMapProcessingException - if the parsing of the topic map source fails or if during population of the topic map some consistency constraints or XTM rules are violated.

populateTopicMap

public void populateTopicMap(TopicMap map,
                             Topic[] addedThemes)
                      throws TopicMapProcessingException
Specified by:
populateTopicMap in interface TopicMapSource
Throws:
TopicMapProcessingException

populateTopicMap

public void populateTopicMap(TopicMap map,
                             TopicMapProvider provider)
                      throws TopicMapProcessingException
Description copied from interface: TopicMapSource
A callback method called by the TopicMapProvider implementation to populate the topic map. This method allows the provider to give a reference to itself to the callback method and is provided because the TopicMap.getProvider() method cannot be easily implemented on the Ozone backend.

Specified by:
populateTopicMap in interface TopicMapSource
Parameters:
map - the TopicMap instance to be populated
provider - the TopicMapProvider instance that manages map
Throws:
TopicMapProcessingException

populateTopicMap

public void populateTopicMap(TopicMap map,
                             TopicMapProvider provider,
                             Topic[] addedThemes)
                      throws TopicMapProcessingException
Specified by:
populateTopicMap in interface TopicMapSource
Throws:
TopicMapProcessingException