net.ontopia.topicmaps.xml
Class XTMTopicMapReader

java.lang.Object
  extended by net.ontopia.xml.AbstractXMLFormatReader
      extended by net.ontopia.topicmaps.xml.XTMTopicMapReader
All Implemented Interfaces:
TopicMapImporterIF, TopicMapReaderIF

public class XTMTopicMapReader
extends AbstractXMLFormatReader
implements TopicMapReaderIF, TopicMapImporterIF

PUBLIC: A topic map reader that reads the XTM 1.0 interchange syntax. A topic map is built as part of the import process. A variety of possible input sources are accommodated, by overloading the constructor.


Field Summary
protected  ExternalReferenceHandlerIF ref_handler
           
protected  TopicMapStoreFactoryIF store_factory
           
protected  java.util.Iterator topicmaps
           
protected  boolean validate
           
 
Fields inherited from class net.ontopia.xml.AbstractXMLFormatReader
base_address, source, xrfactory
 
Constructor Summary
XTMTopicMapReader(java.io.File file)
          PUBLIC: Creates a topic map reader bound to the file given in the arguments.
XTMTopicMapReader(org.xml.sax.InputSource source, LocatorIF base_address)
          PUBLIC: Creates a topic map reader bound to the input source given in the arguments.
XTMTopicMapReader(java.io.InputStream stream, LocatorIF base_address)
          PUBLIC: Creates a topic map reader bound to the input stream given in the arguments.
XTMTopicMapReader(LocatorIF url)
          PUBLIC: Creates a topic map reader bound to the URL given in the arguments.
XTMTopicMapReader(java.io.Reader reader, LocatorIF base_address)
          PUBLIC: Creates a topic map reader bound to the reader given in the arguments.
XTMTopicMapReader(java.lang.String url)
          PUBLIC: Creates a topic map reader bound to the URL given in the arguments.
 
Method Summary
protected  void configureXMLReaderFactory(ConfiguredXMLReaderFactory cxrfactory)
           
 ExternalReferenceHandlerIF getExternalReferenceHandler()
          PUBLIC: Gets the external reference handler.
 TopicMapStoreFactoryIF getStoreFactory()
          PUBLIC: Gets the store factory which will be used to create stores.
 boolean getValidation()
          PUBLIC: Returns true if validation is on, false otherwise.
 void importInto(TopicMapIF topicmap)
          PUBLIC: Imports an implicitly designated topic map into the given topic map.
 TopicMapIF read()
          PUBLIC: Reads the next topic map available from some implicit, implementation dependent source.
protected  TopicMapIF read(TopicMapStoreFactoryIF store_factory)
           
 java.util.Collection readAll()
          PUBLIC: Reads all the topic map available from some implicit, implementation dependent source.
protected  java.util.Collection readAll(TopicMapStoreFactoryIF store_factory)
           
 void setExternalReferenceHandler(ExternalReferenceHandlerIF ref_handler)
          PUBLIC: Sets the external reference handler.
 void setFollowTopicRefs(boolean followTopicRefs)
          PUBLIC: If set to false topicRef elements pointing to external documents will not be traversed.
 void setStoreFactory(TopicMapStoreFactoryIF store_factory)
          PUBLIC: Sets the store factory which will be used to create stores.
 void setValidation(boolean validate)
          PUBLIC: Turn validation of XTM documents according to DTD on or off.
 
Methods inherited from class net.ontopia.xml.AbstractXMLFormatReader
getBaseAddress, getInputSource, getXMLReaderFactory, setBaseAddress, setInputSource, setXMLReaderFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topicmaps

protected java.util.Iterator topicmaps

store_factory

protected TopicMapStoreFactoryIF store_factory

ref_handler

protected ExternalReferenceHandlerIF ref_handler

validate

protected boolean validate
Constructor Detail

XTMTopicMapReader

public XTMTopicMapReader(java.lang.String url)
                  throws java.net.MalformedURLException
PUBLIC: Creates a topic map reader bound to the URL given in the arguments.

Parameters:
url - The URL of the topic map document.
Throws:
java.net.MalformedURLException

XTMTopicMapReader

public XTMTopicMapReader(LocatorIF url)
PUBLIC: Creates a topic map reader bound to the URL given in the arguments.

Parameters:
url - The URL of the topic map document.
Since:
2.0

XTMTopicMapReader

public XTMTopicMapReader(java.io.Reader reader,
                         LocatorIF base_address)
PUBLIC: Creates a topic map reader bound to the reader given in the arguments.

Parameters:
reader - The reader from which the topic map is to be read.
base_address - The base address to be used for resolving relative references.

XTMTopicMapReader

public XTMTopicMapReader(java.io.InputStream stream,
                         LocatorIF base_address)
PUBLIC: Creates a topic map reader bound to the input stream given in the arguments.

Parameters:
stream - The input stream from which the topic map is to be read.
base_address - The base address to be used for resolving relative references.

XTMTopicMapReader

public XTMTopicMapReader(java.io.File file)
                  throws java.io.IOException
PUBLIC: Creates a topic map reader bound to the file given in the arguments.

Parameters:
file - The file object from which to read the topic map.
Throws:
java.io.IOException

XTMTopicMapReader

public XTMTopicMapReader(org.xml.sax.InputSource source,
                         LocatorIF base_address)
PUBLIC: Creates a topic map reader bound to the input source given in the arguments.

Parameters:
source - The SAX input source from which the topic map is to be read.
base_address - The base address to be used for resolving relative references.
Method Detail

getStoreFactory

public TopicMapStoreFactoryIF getStoreFactory()
PUBLIC: Gets the store factory which will be used to create stores.


setStoreFactory

public void setStoreFactory(TopicMapStoreFactoryIF store_factory)
PUBLIC: Sets the store factory which will be used to create stores.

Default: InMemoryStoreFactory

Parameters:
store_factory - The store factory to use. If the parameter is null the default store factory will be used.

getExternalReferenceHandler

public ExternalReferenceHandlerIF getExternalReferenceHandler()
PUBLIC: Gets the external reference handler. The reference handler will receive notifications on references to external topics and topic maps.


setExternalReferenceHandler

public void setExternalReferenceHandler(ExternalReferenceHandlerIF ref_handler)
PUBLIC: Sets the external reference handler.


setFollowTopicRefs

public void setFollowTopicRefs(boolean followTopicRefs)
PUBLIC: If set to false topicRef elements pointing to external documents will not be traversed. The default is that those the documents pointed to by those elements will be loaded (as per the XTM specification).

Since:
3.0

setValidation

public void setValidation(boolean validate)
PUBLIC: Turn validation of XTM documents according to DTD on or off. The validation checks if the documents read follow the DTD, and will abort import if they do not.

Parameters:
validate - Will validate if true, will not if false.
Since:
2.0

getValidation

public boolean getValidation()
PUBLIC: Returns true if validation is on, false otherwise.

Since:
2.0

read

public TopicMapIF read()
                throws java.io.IOException
Description copied from interface: TopicMapReaderIF
PUBLIC: Reads the next topic map available from some implicit, implementation dependent source.

A topic map source may contain multiple topic maps. The read method returns the next topic map that is available from that source. null is returned when there are no more topic maps available. In a sense this is iterator-like behaviour.

Specified by:
read in interface TopicMapReaderIF
Returns:
The next topic map read from the source; an object implementing TopicMapIF. null is returned when there are no more topic maps available from the source.
Throws:
java.io.IOException - Thrown if reading the source fails.

read

protected TopicMapIF read(TopicMapStoreFactoryIF store_factory)
                   throws java.io.IOException
Throws:
java.io.IOException

readAll

public java.util.Collection readAll()
                             throws java.io.IOException
Description copied from interface: TopicMapReaderIF
PUBLIC: Reads all the topic map available from some implicit, implementation dependent source.

A topic map source may contain multiple topic maps. The readAll method returns a collection contain all the topic maps available from the source.

Specified by:
readAll in interface TopicMapReaderIF
Returns:
A collection containing all the topic maps read from the source; objects implementing TopicMapIF.
Throws:
java.io.IOException - Thrown if reading the source fails.

readAll

protected java.util.Collection readAll(TopicMapStoreFactoryIF store_factory)
                                throws java.io.IOException
Throws:
java.io.IOException

importInto

public void importInto(TopicMapIF topicmap)
                throws java.io.IOException
Description copied from interface: TopicMapImporterIF
PUBLIC: Imports an implicitly designated topic map into the given topic map.

Specified by:
importInto in interface TopicMapImporterIF
Parameters:
topicmap - The topic map into which the import will be done; an object implementing TopicMapIF.
Throws:
java.io.IOException

configureXMLReaderFactory

protected void configureXMLReaderFactory(ConfiguredXMLReaderFactory cxrfactory)
Specified by:
configureXMLReaderFactory in class AbstractXMLFormatReader


Copyright © 2000-2012 Ontopia.