Package net.ontopia.topicmaps.utils.ltm
Class LTMTopicMapWriter
- java.lang.Object
-
- net.ontopia.topicmaps.utils.ltm.LTMTopicMapWriter
-
- All Implemented Interfaces:
TopicMapWriterIF
public class LTMTopicMapWriter extends Object implements TopicMapWriterIF
PUBLIC: Exports topic maps to the LTM 1.3 interchange format.- Since:
- 2.2
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description LTMTopicMapWriter(File file)
PUBLIC: Create an LTMTopicMapWriter that writes to a given File in UTF-8.LTMTopicMapWriter(File file, String encoding)
PUBLIC: Create an LTMTopicMapWriter that writes to a given File in specified encoding.LTMTopicMapWriter(OutputStream stream)
PUBLIC: Create an LTMTopicMapWriter that writes to a given OutputStream in UTF-8.LTMTopicMapWriter(OutputStream stream, String encoding)
PUBLIC: Create an LTMTopicMapWriter that writes to a given OutputStream in the given encoding.LTMTopicMapWriter(Writer out, String encoding)
PUBLIC: Create an LTMTopicMapWriter that writes to a given Writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addPrefix(String key, String prefix)
void
setAdditionalProperties(Map<String,Object> properties)
Sets additional properties for LTMTopicMapWriter.void
setFilter(Predicate<Object> filter)
PUBLIC: Sets the filter that decides which topic map constructs are accepted in the exprted ltm.void
setPreserveIds(boolean preserveIds)
PUBLIC: Set whether IDs should be preserved or generated.void
write(TopicMapIF tm)
PUBLIC: Writes out the given topic map.
-
-
-
Field Detail
-
PROPERTY_PREFIXES
public static final String PROPERTY_PREFIXES
- See Also:
- Constant Field Values
-
PROPERTY_FILTER
public static final String PROPERTY_FILTER
- See Also:
- Constant Field Values
-
PROPERTY_PRESERVE_IDS
public static final String PROPERTY_PRESERVE_IDS
- See Also:
- Constant Field Values
-
encoding
protected String encoding
-
preserveIds
protected boolean preserveIds
-
out
protected Writer out
-
closeWriter
protected boolean closeWriter
-
calendar
protected Calendar calendar
-
base
protected String base
-
associationComparator
protected Comparator<AssociationIF> associationComparator
-
baseNameComparator
protected Comparator<TopicNameIF> baseNameComparator
-
elementIdComparator
protected Comparator<TopicIF> elementIdComparator
-
supersubComparator
protected Comparator<AssociationIF> supersubComparator
-
supersubRoleComparator
protected Comparator<AssociationRoleIF> supersubRoleComparator
-
occurrenceComparator
protected Comparator<OccurrenceIF> occurrenceComparator
-
reifierComparator
protected Comparator<Collection<TopicIF>> reifierComparator
-
roleComparator
protected Comparator<AssociationRoleIF> roleComparator
-
scopeComparator
protected Comparator<Collection<TopicIF>> scopeComparator
-
topicComparator
protected Comparator<TopicIF> topicComparator
-
variantComparator
protected Comparator<VariantNameIF> variantComparator
-
idManager
protected net.ontopia.topicmaps.utils.ltm.LTMTopicMapWriter.IdManager idManager
-
groupString1
protected String groupString1
-
-
Constructor Detail
-
LTMTopicMapWriter
public LTMTopicMapWriter(File file) throws IOException
PUBLIC: Create an LTMTopicMapWriter that writes to a given File in UTF-8.- Parameters:
file
- Where the output should be written to.- Throws:
IOException
-
LTMTopicMapWriter
public LTMTopicMapWriter(File file, String encoding) throws IOException
PUBLIC: Create an LTMTopicMapWriter that writes to a given File in specified encoding.- Parameters:
file
- Where the output should be written to.encoding
- The desired character encoding.- Throws:
IOException
-
LTMTopicMapWriter
public LTMTopicMapWriter(OutputStream stream) throws IOException
PUBLIC: Create an LTMTopicMapWriter that writes to a given OutputStream in UTF-8. Warning: Use of this method is discouraged, as it is very easy to get character encoding errors with this method. Note: Caller is responsible for closing the stream!- Parameters:
stream
- Where the output should be written.- Throws:
IOException
-
LTMTopicMapWriter
public LTMTopicMapWriter(OutputStream stream, String encoding) throws IOException
PUBLIC: Create an LTMTopicMapWriter that writes to a given OutputStream in the given encoding. Note: Caller is responsible for closing the stream!- Parameters:
stream
- Where the output should be written.encoding
- The desired character encoding.- Throws:
IOException
-
LTMTopicMapWriter
public LTMTopicMapWriter(Writer out, String encoding)
PUBLIC: Create an LTMTopicMapWriter that writes to a given Writer. Note: Caller is responsible for closing the writer!- Parameters:
out
- Where the output should be written.encoding
- The encoding used by the writer. This is the encoding that will be declared on the first line of the LTM file. It must be reported, because there is no way for the LTMTopicMapWriter to know what encoding the writer uses.- Since:
- 4.0
-
-
Method Detail
-
setPreserveIds
public void setPreserveIds(boolean preserveIds)
PUBLIC: Set whether IDs should be preserved or generated.- Parameters:
preserveIds
- Should be set to true if IDs should be preserved.
-
setFilter
public void setFilter(Predicate<Object> filter)
PUBLIC: Sets the filter that decides which topic map constructs are accepted in the exprted ltm. Uses 'filter' to identify individual topic constructs as allowed or disallowed. TM constructs that depend on the disallowed topics are also disallowed.- Parameters:
filter
- Places constraints on individual topicmap constructs.
-
write
public void write(TopicMapIF tm) throws IOException
PUBLIC: Writes out the given topic map.- Specified by:
write
in interfaceTopicMapWriterIF
- Parameters:
tm
- The topic map to be exported/written; an object implementing TopicMapIF- Throws:
IOException
- Thrown if writing the topic map fails.
-
setAdditionalProperties
public void setAdditionalProperties(Map<String,Object> properties)
Sets additional properties for LTMTopicMapWriter. Accepted properties:- 'preserveIds' (Boolean), corresponds to
setPreserveIds(boolean)
- 'filter' (DeciderIF), corresponds to
#setFilter(net.ontopia.utils.DeciderIF)
- '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
-
- 'preserveIds' (Boolean), corresponds to
-
-