Package org.incenp.obofoundry.kgcl
Class KGCLWriter
java.lang.Object
org.incenp.obofoundry.kgcl.KGCLWriter
A writer to serialise KGCL change objects into a KGCL program that is written
to a file or file-like sink.
-
Constructor Summary
ConstructorsConstructorDescriptionKGCLWriter(File kgclFile) Creates a new instance to write to a file.KGCLWriter(OutputStream kgclOutput) Creates a new instance to write to a stream.KGCLWriter(Writer kgclOutput) Creates a new instance to write to a character stream writer.KGCLWriter(String kgclFilename) Creates a new instance to write to a file. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlying writer.voidsetPrefixManager(org.semanticweb.owlapi.model.OWLOntology ontology) Deprecated.Using an ontology as the prefix manager is no longer recommended.voidsetPrefixManager(org.semanticweb.owlapi.model.PrefixManager manager) Sets the prefix manager to use to compact identifiers.voidsetPrefixMap(Map<String, String> map) Sets the prefix map to use to compact identifiers.voidWrites a comment line to the underlying sink.voidSerialises and writes a KGCL changeset to the underlying sink.voidSerialise and writes a single KGCL change to the underlying sink.
-
Constructor Details
-
KGCLWriter
Creates a new instance to write to a stream.- Parameters:
kgclOutput- The stream to write to.
-
KGCLWriter
Creates a new instance to write to a character stream writer.- Parameters:
kgclOutput- The character stream to write to.
-
KGCLWriter
Creates a new instance to write to a file.- Parameters:
kgclFile- The file to write to.- Throws:
IOException- If the file cannot be found or written to.
-
KGCLWriter
Creates a new instance to write to a file.- Parameters:
kgclFilename- The name of the file to write to.- Throws:
IOException- If the file cannot be found or written to.
-
-
Method Details
-
setPrefixManager
public void setPrefixManager(org.semanticweb.owlapi.model.PrefixManager manager) Sets the prefix manager to use to compact identifiers. The prefix manager in this class will perform the opposite task to the prefix manager inKGCLReader.setPrefixManager(PrefixManager). Given a full-length identifier, it will convert it into a short-form (“CURIEfied”) identifier.The prefix manager should be set prior to any call to the
write(java.util.List<org.incenp.obofoundry.kgcl.model.Change>)methods.If no prefix manager is set, no default compaction is performed and all identifiers will be written as they are.
- Parameters:
manager- The OWL API prefix manager to use (may benull).
-
setPrefixManager
Deprecated.Using an ontology as the prefix manager is no longer recommended. Provide the reader with an explicit PrefixManager (withsetPrefixManager(PrefixManager)) instead.Sets the prefix manager from the specified ontology. This is a convenience method that automatically gets the prefix manager from a OWL APIOWLOntologyobject and sets it as the prefix manager for the writer.- Parameters:
ontology- The ontology whose prefix manager shall be used. If the ontology has been read from aOWLDocumentFormatthat does not support prefixes, it is ignored and a default prefix manager is used instead.
-
setPrefixMap
Sets the prefix map to use to compact identifiers.This is equivalent to calling
setPrefixManager(PrefixManager)with a PrefixManager object initialised with the provided map.- Parameters:
map- The map of prefix names to prefixes to use to compact identifiers.
-
write
Serialises and writes a KGCL changeset to the underlying sink.- Parameters:
changes- The list of KGCL changes to serialise.- Throws:
IOException- If any I/O error occurs when writing.
-
write
Serialise and writes a single KGCL change to the underlying sink.- Parameters:
change- The KGCL change to serialise.- Throws:
IOException- If any I/O error occurs when writing.
-
write
Writes a comment line to the underlying sink. This method writes its argument preceded by a hash character (#), so that it would be ignored if the file is later read by aKGCLReaderobject.Note that the KGCL specification says nothing about comments in a KGCL file. A file containing such comments may not be successfully parsed by other KGCL implementations.
- Parameters:
comment- The comment to write.- Throws:
IOException- If any I/O error occurs when writing.
-
close
Closes the underlying writer.- Throws:
IOException- If any I/O error occurs.
-