Package org.incenp.obofoundry.sssom
Class SSSOMWriter
- java.lang.Object
-
- org.incenp.obofoundry.sssom.SSSOMWriter
-
- Direct Known Subclasses:
JSONWriter,RDFWriter,TSVWriter
public abstract class SSSOMWriter extends Object
Base class to serialise a mapping set.This class should be derived into specialised classes that implement a precise serialisation format.
-
-
Field Summary
Fields Modifier and Type Field Description protected PropagationPolicycondensationPolicyprotected ExtensionSlotManagerextensionManagerprotected ExtraMetadataPolicyextraPolicyprotected PrefixManagerprefixManagerprotected VersiontargetVersion
-
Constructor Summary
Constructors Constructor Description SSSOMWriter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Set<String>condenseSet(MappingSet mappingSet)Performs condensation of "propagatable slots" in a mapping set.protected abstract voiddoWrite(MappingSet mappingSet)Actually serialises a mapping set.protected Set<String>getUsedPrefixes(MappingSet mappingSet)Gets the prefix names that are actually used in the given set.protected Set<String>getUsedPrefixes(MappingSet mappingSet, boolean includeBuiltin)Gets the prefix names that are actually used in the given set, possibly including the builtin prefix names.voidsetCondensationEnabled(boolean enabled)Enables or disables the condensation of "propagatable slots".voidsetCurieMap(Map<String,String> map)Sets the Curie map to use to shorten identifiers.voidsetExtraMetadataPolicy(ExtraMetadataPolicy policy)Sets the policy to deal with non-standard metadata in the mapping set to write.voidsetSortingEnabled(boolean enabled)Enables or disables sorting the mappings when writing them.voidsetTargetVersion(Version targetVersion)Sets the highest version of the SSSOM specification that the written set must be compliant with.voidwrite(MappingSet mappingSet)Serialises a mapping set into the underlying file.
-
-
-
Field Detail
-
extraPolicy
protected ExtraMetadataPolicy extraPolicy
-
condensationPolicy
protected PropagationPolicy condensationPolicy
-
targetVersion
protected Version targetVersion
-
extensionManager
protected ExtensionSlotManager extensionManager
-
prefixManager
protected PrefixManager prefixManager
-
-
Method Detail
-
setCurieMap
public void setCurieMap(Map<String,String> map)
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
public void setExtraMetadataPolicy(ExtraMetadataPolicy policy)
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-Falseto disable condensation; it is enabled by default.
-
setTargetVersion
public void setTargetVersion(Version targetVersion)
Sets the highest version of the SSSOM specification that the written set must be compliant with.Any slot that is defined in a higher version will be forcibly removed.
- Parameters:
targetVersion- The targeted SSSOM version. The default is the highest currently supported version.
-
setSortingEnabled
public void setSortingEnabled(boolean enabled)
Enables or disables sorting the mappings when writing them.- Parameters:
enabled-Falseto disable sorting; it is enabled by default.
-
write
public void write(MappingSet mappingSet) throws IOException
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
protected abstract void doWrite(MappingSet mappingSet) throws IOException
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
protected Set<String> getUsedPrefixes(MappingSet mappingSet)
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
protected Set<String> getUsedPrefixes(MappingSet mappingSet, boolean includeBuiltin)
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
protected Set<String> condenseSet(MappingSet mappingSet)
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).
-
-