net.ontopia.topicmaps.xml
Class TMXMLWriter

java.lang.Object
  extended by net.ontopia.topicmaps.xml.AbstractTopicMapExporter
      extended by net.ontopia.topicmaps.xml.TMXMLWriter
All Implemented Interfaces:
TopicMapWriterIF

public class TMXMLWriter
extends AbstractTopicMapExporter
implements TopicMapWriterIF

PUBLIC: A writer exporting topic maps (or fragments) to the TM/XML syntax.

Since:
3.1

Field Summary
protected static org.xml.sax.helpers.AttributeListImpl EMPTY_ATTR_LIST
           
static java.lang.String NS_ISO
           
static java.lang.String NS_TM
           
static java.lang.String NS_XTM
           
static java.lang.String XSD_ANYURI
           
static java.lang.String XSD_STRING
           
 
Fields inherited from class net.ontopia.topicmaps.xml.AbstractTopicMapExporter
add_ids, filter
 
Constructor Summary
TMXMLWriter(org.xml.sax.DocumentHandler out)
          INTERNAL: Creates a writer writing to the given DocumentHandler.
TMXMLWriter(java.io.File out)
          PUBLIC: Creates a writer writing to the given file in UTF-8.
TMXMLWriter(java.lang.String filename)
          PUBLIC: Creates a writer writing to the given file in the utf-8 character encoding.
TMXMLWriter(java.lang.String filename, java.lang.String encoding)
          PUBLIC: Creates a writer writing to the given file in the given character encoding.
TMXMLWriter(java.io.Writer out)
          PUBLIC: Creates a writer writing to the given writer in the utf-8 character encoding.
TMXMLWriter(java.io.Writer out, java.lang.String encoding)
          PUBLIC: Creates a writer writing to the given writer in the given character encoding.
 
Method Summary
 void close()
          PUBLIC: Closes the Writer created for internal use.
 void endTopicMap()
          PUBLIC: Write the end tag of the document element (fragment mode only).
 void gatherPrefixes(java.util.Collection topics)
          PUBLIC: Gets the namespace prefixes to be used (to be used in fragment exporting mode only).
 void gatherPrefixes(TopicIF topic)
          PUBLIC: Gets the namespace prefixes to be used (to be used in fragment exporting mode only).
 java.lang.String getDocumentElement()
          PUBLIC: Returns the element type name of the document element.
 java.util.Map getNamespaceURIMapping()
          PRIVATE: Returns the namespace URI to prefix mapping maintained internally by the writer.
protected  java.lang.String getSubjectIndicatorRef(TopicIF topic, LocatorIF indicator)
           
 void setDocumentElement(java.lang.String docelem)
          PUBLIC: Sets the document element type name to use.
 void startTopicMap(TopicMapIF topicmap)
          PUBLIC: Writes the start tag of the document element (to be used in fragment exporting only).
 void write(TopicMapIF topicmap)
          PUBLIC: Writes the given topic map to the underlying writer.
 void writeTopic(TopicIF topic)
          PUBLIC: Writes a single topic (fragment exporting mode only).
 void writeTopics(java.util.Collection topics)
          PUBLIC: Writes a set of topics (fragment exporting mode only).
 
Methods inherited from class net.ontopia.topicmaps.xml.AbstractTopicMapExporter
addId, filterCollection, filterOk, getElementId, isValidXMLId, mayCollide, setFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ATTR_LIST

protected static final org.xml.sax.helpers.AttributeListImpl EMPTY_ATTR_LIST

NS_ISO

public static final java.lang.String NS_ISO
See Also:
Constant Field Values

NS_XTM

public static final java.lang.String NS_XTM
See Also:
Constant Field Values

NS_TM

public static final java.lang.String NS_TM
See Also:
Constant Field Values

XSD_ANYURI

public static final java.lang.String XSD_ANYURI
See Also:
Constant Field Values

XSD_STRING

public static final java.lang.String XSD_STRING
See Also:
Constant Field Values
Constructor Detail

TMXMLWriter

public TMXMLWriter(java.lang.String filename)
            throws java.io.IOException
PUBLIC: Creates a writer writing to the given file in the utf-8 character encoding.

Throws:
java.io.IOException

TMXMLWriter

public TMXMLWriter(java.lang.String filename,
                   java.lang.String encoding)
            throws java.io.IOException
PUBLIC: Creates a writer writing to the given file in the given character encoding.

Throws:
java.io.IOException

TMXMLWriter

public TMXMLWriter(java.io.Writer out)
            throws java.io.IOException
PUBLIC: Creates a writer writing to the given writer in the utf-8 character encoding.

Throws:
java.io.IOException

TMXMLWriter

public TMXMLWriter(java.io.Writer out,
                   java.lang.String encoding)
            throws java.io.IOException
PUBLIC: Creates a writer writing to the given writer in the given character encoding.

Throws:
java.io.IOException
Since:
3.2

TMXMLWriter

public TMXMLWriter(java.io.File out)
            throws java.io.IOException
PUBLIC: Creates a writer writing to the given file in UTF-8.

Throws:
java.io.IOException
Since:
3.2

TMXMLWriter

public TMXMLWriter(org.xml.sax.DocumentHandler out)
INTERNAL: Creates a writer writing to the given DocumentHandler.

Method Detail

close

public void close()
           throws java.io.IOException
PUBLIC: Closes the Writer created for internal use. Call this method when you have finished using the fragment exporter interface on the topic map writer. Don't call this method if using the TopicMapWriterIF interface.

Throws:
java.io.IOException

getDocumentElement

public java.lang.String getDocumentElement()
PUBLIC: Returns the element type name of the document element.


setDocumentElement

public void setDocumentElement(java.lang.String docelem)
PUBLIC: Sets the document element type name to use.


write

public void write(TopicMapIF topicmap)
           throws java.io.IOException
PUBLIC: Writes the given topic map to the underlying writer.

Specified by:
write in interface TopicMapWriterIF
Parameters:
topicmap - The topic map to be exported.
Throws:
java.io.IOException - Thrown if writing the topic map fails.

startTopicMap

public void startTopicMap(TopicMapIF topicmap)
                   throws org.xml.sax.SAXException
PUBLIC: Writes the start tag of the document element (to be used in fragment exporting only).

Throws:
org.xml.sax.SAXException

gatherPrefixes

public void gatherPrefixes(java.util.Collection topics)
PUBLIC: Gets the namespace prefixes to be used (to be used in fragment exporting mode only). Must be called before startTopicMap.


writeTopics

public void writeTopics(java.util.Collection topics)
                 throws org.xml.sax.SAXException
PUBLIC: Writes a set of topics (fragment exporting mode only).

Throws:
org.xml.sax.SAXException

writeTopic

public void writeTopic(TopicIF topic)
                throws org.xml.sax.SAXException
PUBLIC: Writes a single topic (fragment exporting mode only).

Throws:
org.xml.sax.SAXException

endTopicMap

public void endTopicMap()
                 throws org.xml.sax.SAXException
PUBLIC: Write the end tag of the document element (fragment mode only).

Throws:
org.xml.sax.SAXException

gatherPrefixes

public void gatherPrefixes(TopicIF topic)
PUBLIC: Gets the namespace prefixes to be used (to be used in fragment exporting mode only). Must be called before startTopicMap.


getNamespaceURIMapping

public java.util.Map getNamespaceURIMapping()
PRIVATE: Returns the namespace URI to prefix mapping maintained internally by the writer. Never, ever call this method. It exists only for testing purposes.


getSubjectIndicatorRef

protected java.lang.String getSubjectIndicatorRef(TopicIF topic,
                                                  LocatorIF indicator)


Copyright © 2000-2012 Ontopia.