Interface OWLOntologyDocumentSource

All Known Implementing Classes:
FileDocumentSource, GZipFileDocumentSource, GZipStreamDocumentSource, IRIDocumentSource, OWLOntologyDocumentSourceBase, ReaderDocumentSource, StreamDocumentSource, StreamDocumentSourceBase, StringDocumentSource, XZFileDocumentSource, XZStreamDocumentSource

public interface OWLOntologyDocumentSource
A document source provides a point for loading an ontology. A document source may provide three ways of obtaining an ontology document:
  1. From a Reader
  2. From an InputStream
  3. From an ontology document IRI
Consumers that use a document source will attempt to obtain a concrete representation of an ontology in the above order.
Note that while an ontology document source may appear similar to a SAX input source, an important difference is that the getReader and getInputStream methods return new instances each time the method is called. This allows multiple attempts at loading an ontology.
Since:
2.0.0
Author:
Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group
  • Method Details

    • getReader

      default Optional<Reader> getReader()
      Gets a reader which an ontology document can be read from. This method may be called multiple times. Each invocation will return a new Reader. If there is no reader stream available, returns Optional.absent.
      Returns:
      A new Reader which the ontology can be read from, wrapped in an Optional.
    • getInputStream

      default Optional<InputStream> getInputStream()
      If an input stream can be obtained from this document source then this method creates it. This method may be called multiple times. Each invocation will return a new input stream. If there is no input stream available, returns Optional.absent. .
      Returns:
      A new input stream which the ontology can be read from, wrapped in an Optional.
    • getDocumentIRI

      IRI getDocumentIRI()
      Gets the IRI of the ontology document.
      Returns:
      An IRI which represents the ontology document IRI
    • getFormat

      default Optional<OWLDocumentFormat> getFormat()
      Returns:
      format for the ontology. If none is known, return Optional.absent.
    • getMIMEType

      default Optional<String> getMIMEType()
      Returns:
      MIME type for this source, if one is specified. If none is known, return Optional.absent.
    • setAcceptHeaders

      default void setAcceptHeaders(String headers)
      Parameters:
      headers - accept headers; if not set, the mime type will be used; if that is also missing, the available parsers will contribute the headers
    • getAcceptHeaders

      default Optional<String> getAcceptHeaders()
      Returns:
      currently set accept headers
    • hasAlredyFailedOnStreams

      boolean hasAlredyFailedOnStreams()
      Returns:
      true if there is no reader or input stream available for this source, or reading from them has already been attempted in a previous call and has failed. This leaves attempting to resolve the document IRI as input. No attempt is made to verify that the document IRI is resolvable.
    • hasAlredyFailedOnIRIResolution

      boolean hasAlredyFailedOnIRIResolution()
      Returns:
      true if resolving the document IRI has been attempted by a previous call and has failed, false if resolution has not been attempted yet or it has happened successfully.
    • setIRIResolutionFailed

      void setIRIResolutionFailed(boolean value)
      IRI resolution does not happen inside this class. This method allows the resolver to mark the document IRI as unresolvable, so that the information is tracked with the source.
      Parameters:
      value - new value for the flag