Package org.incenp.obofoundry.sssom
Class SSSOMWriter
java.lang.Object
org.incenp.obofoundry.sssom.SSSOMWriter
- Direct Known Subclasses:
JSONWriter
,RDFWriter
,TSVWriter
Base class to serialise a mapping set.
This class should be derived into specialised classes that implement a precise serialisation format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PropagationPolicy
protected ExtensionSlotManager
protected ExtraMetadataPolicy
protected PrefixManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncondenseSet
(MappingSet mappingSet) Performs condensation of "propagatable slots" in a mapping set.protected abstract void
doWrite
(MappingSet mappingSet) Actually serialises a mapping set.getUsedPrefixes
(MappingSet mappingSet) Gets the prefix names that are actually used in the given set.getUsedPrefixes
(MappingSet mappingSet, boolean includeBuiltin) Gets the prefix names that are actually used in the given set, possibly including the builtin prefix names.void
setCondensationEnabled
(boolean enabled) Enables or disables the condensation of "propagatable slots".void
setCurieMap
(Map<String, String> map) Sets the Curie map to use to shorten identifiers.void
Sets the policy to deal with non-standard metadata in the mapping set to write.void
setSortingEnabled
(boolean enabled) Enables or disables sorting the mappings when writing them.void
write
(MappingSet mappingSet) Serialises a mapping set into the underlying file.
-
Field Details
-
extraPolicy
-
condensationPolicy
-
extensionManager
-
prefixManager
-
-
Constructor Details
-
SSSOMWriter
public SSSOMWriter()
-
-
Method Details
-
setCurieMap
Sets the Curie map to use to shorten identifiers. The Curie map associated with the mapping set (MappingSet.getCurieMap()
) will then be completely ignored in favour of the specified map.- Parameters:
map
- A map associating prefix names to prefixes.
-
setExtraMetadataPolicy
Sets the policy to deal with non-standard metadata in the mapping set to write.- Parameters:
policy
- The policy instructing the writer about what to do with any non-standard metadata. The default policy isExtraMetadataPolicy.NONE
, meaning that no non-standard metadata is ever written.
-
setCondensationEnabled
public void setCondensationEnabled(boolean enabled) Enables or disables the condensation of "propagatable slots".- Parameters:
enabled
-False
to disable condensation; it is enabled by default.
-
setSortingEnabled
public void setSortingEnabled(boolean enabled) Enables or disables sorting the mappings when writing them.- Parameters:
enabled
-False
to disable sorting; it is enabled by default.
-
write
Serialises a mapping set into the underlying file. This method performs some prelimiary steps that are common to all serialisers, then delegates the actual serialisation task todoWrite(MappingSet)
.- Parameters:
mappingSet
- The mapping set to serialise.- Throws:
IOException
- If an I/O error occurs.
-
doWrite
Actually serialises a mapping set. This method should be overridden by derived classes to implement the serialisation in a specific format.- Parameters:
mappingSet
- The mapping set to serialise.- Throws:
IOException
- If an I/O error occurs.
-
getUsedPrefixes
Gets the prefix names that are actually used in the given set. This excludes prefix names that are considered builtin.- Parameters:
mappingSet
- The mapping set to query for used prefix names.- Returns:
- A set of all prefix names that are effectively needed to condense all identifiers in the mapping set.
-
getUsedPrefixes
Gets the prefix names that are actually used in the given set, possibly including the builtin prefix names.- Parameters:
mappingSet
- The mapping set to query for used prefix names.includeBuiltin
- Iftrue
, builtin prefix names will be included.- Returns:
- A set of all prefix names that are effectively needed to condense all identifiers in the mapping set.
-
condenseSet
Performs condensation of "propagatable slots" in a mapping set.If condensation is disabled (see
setCondensationEnabled(boolean)
), this is merely a no-op.- Parameters:
mappingSet
- The mapping set whose slots should be condensed.- Returns:
- A set of all mapping slot names that have been effectively condensed (may be empty if no slots have been condensed at all).
-