Package org.incenp.obofoundry.sssom
Class JSONWriter
java.lang.Object
org.incenp.obofoundry.sssom.SSSOMWriter
org.incenp.obofoundry.sssom.JSONWriter
A writer to serialise a SSSOM mapping set into a JSON format.
The JSON format generated by this writer is not the JSON format used by SSSOM-Py! SSSOM-Py uses a JSON-LD format that, for now, is completely unspecified. Instead, this writer produces a “pure” JSON format that is merely a direct JSON rendering of the internal SSSOM data model.
-
Field Summary
Fields inherited from class org.incenp.obofoundry.sssom.SSSOMWriter
condensationPolicy, extensionManager, extraPolicy, prefixManager
-
Constructor Summary
ConstructorsConstructorDescriptionJSONWriter
(File file) Creates a new instance that will write data to the specified file.JSONWriter
(OutputStream stream) Creates a new instance that will write data to the specified stream.JSONWriter
(String filename) Creates a new instance that will write data to a file with the specified filename. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doWrite
(MappingSet mappingSet) Serialises a mapping set into the underlying file.void
setShortenIRIs
(boolean shorten) Enables or disables shortening of identifiers.void
setWriteCurieMapInContext
(boolean enabled) Enables writing the curie map in a JSON-LD-like "@context" object.Methods inherited from class org.incenp.obofoundry.sssom.SSSOMWriter
condenseSet, getUsedPrefixes, getUsedPrefixes, setCondensationEnabled, setCurieMap, setExtraMetadataPolicy, setSortingEnabled, write
-
Constructor Details
-
JSONWriter
Creates a new instance that will write data to the specified file.- Parameters:
file
- The file to write the mapping set to.- Throws:
IOException
- If the file cannot be opened for any reason.
-
JSONWriter
Creates a new instance that will write data to the specified stream.- Parameters:
stream
- The stream to write the mapping set to.
-
JSONWriter
Creates a new instance that will write data to a file with the specified filename.- Parameters:
filename
- The name of the file to write the mapping set to.- Throws:
IOException
- If the file cannot be opened for any reason.
-
-
Method Details
-
setShortenIRIs
public void setShortenIRIs(boolean shorten) Enables or disables shortening of identifiers. If enabled, all identifiers will be written as CURIEs and a curie_map will be included in the output.- Parameters:
shorten
-True
to enable shortening of all identifiers. It is disabled by default.
-
setWriteCurieMapInContext
public void setWriteCurieMapInContext(boolean enabled) Enables writing the curie map in a JSON-LD-like "@context" object.SSSOM-Py expects the prefix names to be declared in the @context dictionary, so this option enables that behaviour. Note that it only has effect is shortening of IRIs (see
setShortenIRIs(boolean)
) is also enabled, because there is no curie map to write otherwise.- Parameters:
enabled
-True
to write the curie map as a @context dictionary. The default is to write it as a normal curie_map slot.
-
doWrite
Serialises a mapping set into the underlying file.- Specified by:
doWrite
in classSSSOMWriter
- Parameters:
mappingSet
- The mapping set to serialise.- Throws:
IOException
- If an I/O error occurs.
-