Package net.ontopia.topicmaps.xml
Class XTMTopicMapWriter
- java.lang.Object
-
- net.ontopia.topicmaps.xml.XTMTopicMapWriter
-
- All Implemented Interfaces:
TopicMapWriterIF
- Direct Known Subclasses:
XTM21TopicMapWriter,XTM2TopicMapWriter
public class XTMTopicMapWriter extends Object implements TopicMapWriterIF
PUBLIC: A topic map writer that can write topic maps out as either XTM 1.0, 2.0 or 2.1. The default is XTM 1.0.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanadd_idsprotected booleanexport_srclocsprotected Predicatefilterprotected ContentHandleroutstatic StringPROPERTY_ADD_IDSstatic StringPROPERTY_EXPORT_SOURCE_LOCATORSstatic StringPROPERTY_FILTERstatic StringPROPERTY_VERSIONprotected Writerwriter
-
Constructor Summary
Constructors Constructor Description XTMTopicMapWriter(File file)PUBLIC: Creates a topic map writer bound to the file given in the arguments.XTMTopicMapWriter(File file, String encoding)PUBLIC: Creates a topic map writer bound to the file given in the arguments.XTMTopicMapWriter(OutputStream stream, String encoding)PUBLIC: Creates a topic map writer bound to the output stream given in the arguments.XTMTopicMapWriter(Writer writer, String encoding)PUBLIC: Creates a topic map writer bound to the Writer given in the arguments; we do not recommend the use of this method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetAddIds()PUBLIC: Returns true if configured to add IDs to all elements.booleangetExportSourceLocators()INTERNAL: Returns true if source locators should be exported.voidsetAddIds(boolean add_ids)PUBLIC: Tells the exporter whether or not to add IDs to all elements.voidsetAdditionalProperties(Map<String,Object> properties)Sets additional properties for the XTMTopicMapWriter.voidsetExportSourceLocators(boolean export_srclocs)INTERNAL: Set the flag that says whether source locators should be exported or not.voidsetFilter(Predicate filter)PUBLIC: Sets a filter used to filter the topic map before export.voidsetVersion(XTMVersion version)PUBLIC: Set XTM version to use on export.voidwrite(TopicMapIF topicmap)PUBLIC: Writes the given topic map to an implicit implementation dependent destination.
-
-
-
Field Detail
-
PROPERTY_ADD_IDS
public static final String PROPERTY_ADD_IDS
- See Also:
- Constant Field Values
-
PROPERTY_EXPORT_SOURCE_LOCATORS
public static final String PROPERTY_EXPORT_SOURCE_LOCATORS
- See Also:
- Constant Field Values
-
PROPERTY_FILTER
public static final String PROPERTY_FILTER
- See Also:
- Constant Field Values
-
PROPERTY_VERSION
public static final String PROPERTY_VERSION
- See Also:
- Constant Field Values
-
out
protected ContentHandler out
-
writer
protected Writer writer
-
filter
protected Predicate filter
-
export_srclocs
protected boolean export_srclocs
-
add_ids
protected boolean add_ids
-
-
Constructor Detail
-
XTMTopicMapWriter
public XTMTopicMapWriter(File file) throws IOException
PUBLIC: Creates a topic map writer bound to the file given in the arguments. The topic map will be written out in the UTF-8 encoding.- Parameters:
file- The file object to which the topic map is to be written.- Throws:
IOException
-
XTMTopicMapWriter
public XTMTopicMapWriter(File file, String encoding) throws IOException
PUBLIC: Creates a topic map writer bound to the file given in the arguments.- Parameters:
file- The file object to which the topic map is to be written.encoding- The character encoding to write the topic map in.- Throws:
IOException
-
XTMTopicMapWriter
public XTMTopicMapWriter(OutputStream stream, String encoding) throws IOException, UnsupportedEncodingException
PUBLIC: Creates a topic map writer bound to the output stream given in the arguments.- Parameters:
stream- The output stream to which the topic map is to be written.encoding- The character encoding to write the topic map in.- Throws:
UnsupportedEncodingException- Thrown when the character encoding is not supported by the Java environment.IOException
-
XTMTopicMapWriter
public XTMTopicMapWriter(Writer writer, String encoding) throws IOException
PUBLIC: Creates a topic map writer bound to the Writer given in the arguments; we do not recommend the use of this method.- Parameters:
writer- The Writer to which the topic map is to be written.encoding- The character encoding the Writer writes in. Note that this must be set correctly, or the XML document will not parse correctly.- Throws:
IOException- Since:
- 1.1
-
-
Method Detail
-
setFilter
public void setFilter(Predicate filter)
PUBLIC: Sets a filter used to filter the topic map before export. Only topics, associations, and other characteristics accepted by the filter are included in the export.- Since:
- 3.0
-
getAddIds
public boolean getAddIds()
PUBLIC: Returns true if configured to add IDs to all elements.- Since:
- 2.0
-
setAddIds
public void setAddIds(boolean add_ids)
PUBLIC: Tells the exporter whether or not to add IDs to all elements. (Default: false.)- Since:
- 2.0
-
setVersion
public void setVersion(XTMVersion version)
PUBLIC: Set XTM version to use on export.- Since:
- 5.1.0
-
write
public void write(TopicMapIF topicmap) throws IOException
Description copied from interface:TopicMapWriterIFPUBLIC: Writes the given topic map to an implicit implementation dependent destination. The write method will close any resources opened internally. This means that the write method can only be called once if the stream/writer was opened internally.- Specified by:
writein interfaceTopicMapWriterIF- Parameters:
topicmap- The topic map to be exported/written; an object implementing TopicMapIF- Throws:
IOException- Thrown if writing the topic map fails.
-
getExportSourceLocators
public boolean getExportSourceLocators()
INTERNAL: Returns true if source locators should be exported.
-
setExportSourceLocators
public void setExportSourceLocators(boolean export_srclocs)
INTERNAL: Set the flag that says whether source locators should be exported or not.
-
setAdditionalProperties
public void setAdditionalProperties(Map<String,Object> properties)
Sets additional properties for the XTMTopicMapWriter. Accepted properties:- 'addIds' (Boolean), corresponds to
setAddIds(boolean) - 'exportSourceLocators' (Boolean), corresponds to
setExportSourceLocators(boolean) - 'version' (XTMVersion), corresponds to
setVersion(net.ontopia.topicmaps.xml.XTMVersion) - 'filter' (DeciderIF), corresponds to
#setFilter(net.ontopia.utils.DeciderIF)
- Specified by:
setAdditionalPropertiesin interfaceTopicMapWriterIF- Parameters:
properties-
- 'addIds' (Boolean), corresponds to
-
-