Package net.ontopia.topicmaps.xml
Class TMXMLWriter
- java.lang.Object
-
- net.ontopia.topicmaps.xml.AbstractTopicMapExporter
-
- 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
Fields Modifier and Type Field Description protected static AttributesImpl
EMPTY_ATTR_LIST
protected static String
EMPTY_LOCALNAME
protected static String
EMPTY_NAMESPACE
static String
NS_ISO
static String
NS_TM
static String
NS_XTM
static String
PROPERTY_DOCUMENT_ELEMENT
static String
PROPERTY_PREFIXES
static String
XSD_ANYURI
static String
XSD_STRING
-
Fields inherited from class net.ontopia.topicmaps.xml.AbstractTopicMapExporter
add_ids, filter
-
-
Constructor Summary
Constructors Constructor Description TMXMLWriter(File out)
PUBLIC: Creates a writer writing to the given file in UTF-8.TMXMLWriter(File out, String encoding)
PUBLIC: Creates a writer writing to the given file in given encoding.TMXMLWriter(OutputStream out, String encoding)
TMXMLWriter(Writer out)
PUBLIC: Creates a writer writing to the given writer in the utf-8 character encoding.TMXMLWriter(Writer out, String encoding)
PUBLIC: Creates a writer writing to the given writer in the given character encoding.TMXMLWriter(ContentHandler out)
INTERNAL: Creates a writer writing to the given ContentHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPrefix(String prefix, String nsuri)
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(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).String
getDocumentElement()
PUBLIC: Returns the element type name of the document element.Map
getNamespaceURIMapping()
PRIVATE: Returns the namespace URI to prefix mapping maintained internally by the writer.protected String
getSubjectIndicatorRef(TopicIF topic, LocatorIF indicator)
void
setAdditionalProperties(Map<String,Object> properties)
Sets additional properties for the TMXMLWriter.void
setDocumentElement(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(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
-
-
-
-
Field Detail
-
PROPERTY_PREFIXES
public static final String PROPERTY_PREFIXES
- See Also:
- Constant Field Values
-
PROPERTY_DOCUMENT_ELEMENT
public static final String PROPERTY_DOCUMENT_ELEMENT
- See Also:
- Constant Field Values
-
EMPTY_ATTR_LIST
protected static final AttributesImpl EMPTY_ATTR_LIST
-
EMPTY_NAMESPACE
protected static final String EMPTY_NAMESPACE
- See Also:
- Constant Field Values
-
EMPTY_LOCALNAME
protected static final String EMPTY_LOCALNAME
- See Also:
- Constant Field Values
-
NS_ISO
public static final String NS_ISO
- See Also:
- Constant Field Values
-
NS_XTM
public static final String NS_XTM
- See Also:
- Constant Field Values
-
NS_TM
public static final String NS_TM
- See Also:
- Constant Field Values
-
XSD_ANYURI
public static final String XSD_ANYURI
- See Also:
- Constant Field Values
-
XSD_STRING
public static final String XSD_STRING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TMXMLWriter
public TMXMLWriter(Writer out) throws IOException
PUBLIC: Creates a writer writing to the given writer in the utf-8 character encoding.- Throws:
IOException
-
TMXMLWriter
public TMXMLWriter(Writer out, String encoding) throws IOException, IOException, IOException
PUBLIC: Creates a writer writing to the given writer in the given character encoding.- Throws:
IOException
- Since:
- 3.2
-
TMXMLWriter
public TMXMLWriter(File out) throws IOException
PUBLIC: Creates a writer writing to the given file in UTF-8.- Throws:
IOException
- Since:
- 3.2
-
TMXMLWriter
public TMXMLWriter(File out, String encoding) throws IOException
PUBLIC: Creates a writer writing to the given file in given encoding.- Throws:
IOException
-
TMXMLWriter
public TMXMLWriter(OutputStream out, String encoding) throws IOException
- Throws:
IOException
-
TMXMLWriter
public TMXMLWriter(ContentHandler out)
INTERNAL: Creates a writer writing to the given ContentHandler.
-
-
Method Detail
-
close
public void close() throws 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:
IOException
-
getDocumentElement
public String getDocumentElement()
PUBLIC: Returns the element type name of the document element.
-
setDocumentElement
public void setDocumentElement(String docelem)
PUBLIC: Sets the document element type name to use.
-
write
public void write(TopicMapIF topicmap) throws IOException
PUBLIC: Writes the given topic map to the underlying writer.- Specified by:
write
in interfaceTopicMapWriterIF
- Parameters:
topicmap
- The topic map to be exported.- Throws:
IOException
- Thrown if writing the topic map fails.
-
startTopicMap
public void startTopicMap(TopicMapIF topicmap) throws SAXException
PUBLIC: Writes the start tag of the document element (to be used in fragment exporting only).- Throws:
SAXException
-
gatherPrefixes
public void gatherPrefixes(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(Collection topics) throws SAXException
PUBLIC: Writes a set of topics (fragment exporting mode only).- Throws:
SAXException
-
writeTopic
public void writeTopic(TopicIF topic) throws SAXException
PUBLIC: Writes a single topic (fragment exporting mode only).- Throws:
SAXException
-
endTopicMap
public void endTopicMap() throws SAXException
PUBLIC: Write the end tag of the document element (fragment mode only).- Throws:
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 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.
-
setAdditionalProperties
public void setAdditionalProperties(Map<String,Object> properties)
Sets additional properties for the TMXMLWriter. Accepted properties:- 'documentElement' (String), corresponds to
setDocumentElement(java.lang.String)
- 'prefixes' (Map), each key-value pair is passed to
addPrefix(java.lang.String, java.lang.String)
as Strings.
- Specified by:
setAdditionalProperties
in interfaceTopicMapWriterIF
- Parameters:
properties
-
- 'documentElement' (String), corresponds to
-
-