Class OWLZipSaver

java.lang.Object
org.semanticweb.owlapi.util.OWLZipSaver

public class OWLZipSaver extends Object
Class for saving ontologies to zip files with an optional index.
Author:
ignazio
  • Field Details

  • Constructor Details

    • OWLZipSaver

      public OWLZipSaver()
  • Method Details

    • setEntryPath

      public void setEntryPath(Function<OWLOntologyID,String> entryPath)
      Parameters:
      entryPath - function to use to generate the path in the zip file for an ontology. The default strategy is to use the last part of the ontology IRI.
    • setIndex

      public void setIndex(BiFunction<Collection<OWLOntology>,Collection<OWLOntology>,String> index)
      Parameters:
      index - function to use to generate the index content. The default strategy is to create a YAML file. The methods on this class can be passed here to switch to different strategies, or a user defined strategy can be used.
    • setIndexName

      public void setIndexName(Supplier<String> indexName)
      Parameters:
      indexName - the name for the index entry. This defaults to owlzip.yaml; other known values are owlzip.poperties and catalog-v001.xml. A supplier that returns a null or empty string will cause the class to skip creating an index; in that case, the ontologies will just be compressed.
    • saveImportsClosure

      public void saveImportsClosure(OWLOntology root, OutputStream out) throws IOException, OWLOntologyStorageException
      Save the root ontology as root in the index and its imports closure as companion ontologies.
      Parameters:
      root - root ontology to save
      out - output stream; to be created by the caller, closed in this method
      Throws:
      IOException - if writing to the file fails
      OWLOntologyStorageException - if serializing the ontologies fails
    • saveImportsClosures

      public void saveImportsClosures(Collection<OWLOntology> roots, OutputStream out) throws IOException, OWLOntologyStorageException
      Save the root ontologies as root in the index and their imports closures as companion ontologies.
      Parameters:
      roots - root ontologies to save
      out - output stream; to be created by the caller, closed in this method
      Throws:
      IOException - if writing to the file fails
      OWLOntologyStorageException - if serializing the ontologies fails
    • saveOntologies

      public void saveOntologies(Collection<OWLOntology> ontologies, OutputStream out) throws IOException, OWLOntologyStorageException
      Save the ontologies in the index and their content as companion ontologies; no ontology will be marked as root.
      Parameters:
      ontologies - ontologies to save
      out - output stream; to be created by the caller, closed in this method
      Throws:
      IOException - if writing to the file fails
      OWLOntologyStorageException - if serializing the ontologies fails
    • saveOntologies

      public void saveOntologies(Collection<OWLOntology> roots, Collection<OWLOntology> ontologies, OutputStream out) throws IOException, OWLOntologyStorageException
      Save the ontologies in the index, marking as root the ontologies in the roots collection; the other ontologies will be saved as companion ontologies. This method assumes the caller takes care of flattening ontology imports closures, and will not navigate imports statements.
      Parameters:
      roots - root ontologies
      ontologies - ontologies to save
      out - output stream; to be created by the caller, closed in this method
      Throws:
      IOException - if writing to the file fails
      OWLOntologyStorageException - if serializing the ontologies fails
    • catalogIndex

      public String catalogIndex(Collection<OWLOntology> roots, Collection<OWLOntology> ontologies)
      Prepare a catalog index; this method can be used as a BiFunction for setIndex(BiFunction). Imports statements are not navigated; all ontologies required have to appear explicitly in the collections.
      Parameters:
      roots - collection of roots, if any
      ontologies - collection of ontologies, if any
      Returns:
      content of a catalog index for the input ontologies
    • yamlIndex

      public String yamlIndex(Collection<OWLOntology> roots, Collection<OWLOntology> ontologies)
      Prepare a yaml index; this method can be used as a BiFunction for setIndex(BiFunction). Imports statements are not navigated; all ontologies required have to appear explicitly in the collections.
      Parameters:
      roots - collection of roots, if any
      ontologies - collection of ontologies, if any
      Returns:
      content of a yaml index for the input ontologies
    • propertiesIndex

      public String propertiesIndex(Collection<OWLOntology> roots, Collection<OWLOntology> ontologies)
      Prepare a properties index; this method can be used as a BiFunction for setIndex(BiFunction). Imports statements are not navigated; all ontologies required have to appear explicitly in the collections.
      Parameters:
      roots - collection of roots, if any
      ontologies - collection of ontologies, if any
      Returns:
      content of a properties index for the input ontologies
    • entryPath

      public String entryPath(OWLOntologyID id)
      Prepare a zip name for an ontology id; this method can be used as a Function for setEntryPath.
      Parameters:
      id - ontology id
      Returns:
      zip entry name for the ontology