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 AttributesImplEMPTY_ATTR_LISTprotected static StringEMPTY_LOCALNAMEprotected static StringEMPTY_NAMESPACEstatic StringNS_ISOstatic StringNS_TMstatic StringNS_XTMstatic StringPROPERTY_DOCUMENT_ELEMENTstatic StringPROPERTY_PREFIXESstatic StringXSD_ANYURIstatic StringXSD_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 voidaddPrefix(String prefix, String nsuri)voidclose()PUBLIC: Closes the Writer created for internal use.voidendTopicMap()PUBLIC: Write the end tag of the document element (fragment mode only).voidgatherPrefixes(Collection topics)PUBLIC: Gets the namespace prefixes to be used (to be used in fragment exporting mode only).voidgatherPrefixes(TopicIF topic)PUBLIC: Gets the namespace prefixes to be used (to be used in fragment exporting mode only).StringgetDocumentElement()PUBLIC: Returns the element type name of the document element.MapgetNamespaceURIMapping()PRIVATE: Returns the namespace URI to prefix mapping maintained internally by the writer.protected StringgetSubjectIndicatorRef(TopicIF topic, LocatorIF indicator)voidsetAdditionalProperties(Map<String,Object> properties)Sets additional properties for the TMXMLWriter.voidsetDocumentElement(String docelem)PUBLIC: Sets the document element type name to use.voidstartTopicMap(TopicMapIF topicmap)PUBLIC: Writes the start tag of the document element (to be used in fragment exporting only).voidwrite(TopicMapIF topicmap)PUBLIC: Writes the given topic map to the underlying writer.voidwriteTopic(TopicIF topic)PUBLIC: Writes a single topic (fragment exporting mode only).voidwriteTopics(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 IOExceptionPUBLIC: 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:
writein 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 SAXExceptionPUBLIC: 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:
setAdditionalPropertiesin interfaceTopicMapWriterIF- Parameters:
properties-
- 'documentElement' (String), corresponds to
-
-