org.ceryle.tm
Class TopicMapBuilderFactoryImpl

java.lang.Object
  extended by org.ceryle.tm.TopicMapBuilderFactoryImpl
All Implemented Interfaces:
TopicMapBuilderFactory

public class TopicMapBuilderFactoryImpl
extends Object
implements TopicMapBuilderFactory

A singleton factory class implementing TopicMapBuilderFactory for creating a TopicMapBuilder instances, delegating builder/managers for TMAPI, native TM4J (or theoretically other) TopicMap objects.

Supplied with a URI as the Locator address, it provides a builder that, like an event listener/handler, then receives simplified "events" (whose parameters are entirely text strings) that creates Topics, Associations and other TopicMap objects for the TopicMap associated with that builder. This is designed to simplify creation of a TopicMap from the parsing of external source material; not all TopicMap features are supported.

API Implementations

The implementing class is set by the System property TopicMapBuilderFactory.PROPERTY_BUILDER_CLASS (whose String value is "org.ceryle.tm.topicmapbuilder"). The property value should contain the full class name of the implementing class. There are currently two available implementations:

  1. TM4J (native) implementation:
    System.setProperty(TopicMapBuilderFactory.PROPERTY_BUILDER_CLASS,
                        "org.ceryle.tm.TM4JTopicMapBuilderImpl"); 
  2. TMAPI implementation:
    System.setProperty(TopicMapBuilderFactory.PROPERTY_BUILDER_CLASS,
                        "org.ceryle.tm.TMAPITopicMapBuilderImpl"); 

Topic Map Management

The factory provides a TopicMapBuilder object used to create and manage object creation for a single TopicMap, referenced by its base URI. The builder manages the creation and access to the objects of that TopicMap. The getTopicMapBuilder(Object) method is guaranteed to return the same TopicMapBuilder object when provided with a Locator, File, URL, String, or Object.toString() reference that resolves to the same String (as a URI).

Obtaining a TopicMapBuilderFactory

To obtain the instance of this class using its default properties:

      TopicMapBuilderFactory factory = TopicMapBuilderFactoryImpl.getInstance(); 
or, if you want to preset any of the TMAPI TopicMapSystem properties:
      Properties props = new Properties();
      // set properties...
      TopicMapBuilderFactory factory = TopicMapBuilderFactoryImpl.getInstance(props); 

Obtaining a TopicMapBuilder

To obtain the instance of a TopicMapBuilder once you have a factory:

      Object o = ...;
      TopicMapBuilder builder = factory.getTopicMapBuilder(o); 

The Object can be a File, URL, String (in the form of a URI), or any Object whose toString() method returns a String in the form of a URI. You can also use the factory to do a reverse lookup, where providing it with a TopicMap as the parameter returns the existing TopicMapBuilder for that TopicMap, null if one doesn't already exist.

Version:
$Id: TopicMapBuilderFactoryImpl.java,v 3.2 2007-06-15 12:09:33 altheim Exp $
Author:
Murray Altheim
See Also:
TopicMapBuilder

Field Summary
static Object ALL_TOPICMAPS
           
 
Fields inherited from interface org.ceryle.tm.TopicMapBuilderFactory
PROPERTY_BUILDER_CLASS
 
Method Summary
static TopicMapBuilderFactory getInstance()
          As this is a singleton class, this returns the single instance of this class.
 TopicMapBuilder getTopicMapBuilder(Object identifier)
          Returns either a new or existing TopicMapBuilder for a TopicMap whose base URI is provided by the Object identifier, which can be a File, a URL, TMAPI Locator, String, or any Object whose toString() method returns a String that conforms to the specification of a URI.
 boolean removeTopicMapBuilder(Object identifier)
          Using the same identification approach as getTopicMapBuilder(Object), removes the identified TopicMapBuilder from the internal builder cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_TOPICMAPS

public static final Object ALL_TOPICMAPS
Method Detail

getInstance

public static TopicMapBuilderFactory getInstance()
                                          throws TopicMapException
As this is a singleton class, this returns the single instance of this class.

Throws:
TopicMapException - if the factory cannot be created.

getTopicMapBuilder

public TopicMapBuilder getTopicMapBuilder(Object identifier)
                                   throws TopicMapException
Returns either a new or existing TopicMapBuilder for a TopicMap whose base URI is provided by the Object identifier, which can be a File, a URL, TMAPI Locator, String, or any Object whose toString() method returns a String that conforms to the specification of a URI.

Reverse Lookup

This can also perform a reverse lookup: if the parameter is a TopicMap, this returns the TopicMapBuilder for it, null if it doesn't already exist. This does not create a TopicMapBuilder for an existing TopicMap.

Specified by:
getTopicMapBuilder in interface TopicMapBuilderFactory
Parameters:
identifier - the base URI of the TopicMap as a File, URL, Locator, String, or Object; or, for a reverse lookup, a TopicMap.
Returns:
the TopicMapBuilder used to manage the TopicMap.
Throws:
TopicMapException

removeTopicMapBuilder

public boolean removeTopicMapBuilder(Object identifier)
                              throws TopicMapException
Using the same identification approach as getTopicMapBuilder(Object), removes the identified TopicMapBuilder from the internal builder cache. If the supplied Object is the special case of ALL_TOPICMAPS, this will clear the entire cache.

Specified by:
removeTopicMapBuilder in interface TopicMapBuilderFactory
Parameters:
identifier - the base URI of the TopicMap as a File, URL, Locator, String, or Object; or the TopicMap itself.
Returns:
true if the TopicMapBuilder was located and removed.
Throws:
TopicMapException


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.