Class DocumentSources

java.lang.Object
org.semanticweb.owlapi.io.DocumentSources

public class DocumentSources extends Object
Static methods from AbstractOWLParser. Mostly used by OWLOntologyDocumentSource implementations.
  • Method Details

    • wrapInputAsReader

      public static Reader wrapInputAsReader(OWLOntologyDocumentSource source, OWLOntologyLoaderConfiguration configuration, Charset encoding) throws OWLOntologyInputSourceException
      Select the available input source and, if it is not already a Reader, wrap it in a Reader. This method removes the duplication of code required for each caller to figure out if a reader or an inputstream is available. The returned Reader will be buffered.
      Parameters:
      source - ontology source
      configuration - loader configuration to use of the reader must be built form the input IRI
      encoding - character encoding if a new Reader needs to be created.
      Returns:
      A Reader for the input; if no Reader can be obtained, an OWLOntologyInputSourceException is thrown.
      Throws:
      OWLOntologyInputSourceException - if an IO related exception is thrown.
    • wrapInputAsReader

      public static Reader wrapInputAsReader(OWLOntologyDocumentSource source, OWLOntologyLoaderConfiguration configuration) throws OWLOntologyInputSourceException
      Call #wrapwrapInputAsReader(OWLOntologyLoaderConfiguration, String) with UTF-* as default encoding.
      Parameters:
      source - ontology source
      configuration - loader configuration to use of the reader must be built form the input IRI
      Returns:
      A Reader wrapped in an Optional; if no Reader can be obtained, the result is Optional.empty. @throws OWLOntologyInputSourceException if an IO related exception is thrown.
      Throws:
      OWLOntologyInputSourceException - if an IO related exception is thrown.
    • wrapInput

      Select the available input source as an input stream. The input stream will be buffered.
      Parameters:
      source - ontology source
      configuration - loader configuration to use of the reader must be built form the input IRI
      Returns:
      A Reader for the input; if no Reader can be obtained, an OWLOntologyInputSourceException is thrown.
      Throws:
      OWLOntologyInputSourceException - if an IO related exception is thrown.
    • getInputStream

      @Deprecated public static Optional<InputStream> getInputStream(IRI documentIRI, OWLOntologyLoaderConfiguration config) throws OWLOntologyInputSourceException
      A convenience method that obtains an input stream from a URI. This method sets up the correct request type and wraps the input stream within a buffered input stream.
      Parameters:
      documentIRI - The URI from which the input stream should be returned
      config - the load configuration
      Returns:
      The input stream obtained from the URI
      Throws:
      OWLOntologyInputSourceException - if there was an IOException in obtaining the input stream from the URI.
    • getInputStream

      public static Optional<InputStream> getInputStream(IRI documentIRI, OWLOntologyLoaderConfiguration config, String acceptHeaders) throws OWLOntologyInputSourceException
      A convenience method that obtains an input stream from a URI. This method sets up the correct request type and wraps the input stream within a buffered input stream.
      Parameters:
      documentIRI - The URI from which the input stream should be returned
      config - the load configuration
      acceptHeaders - accept headers for the connection
      Returns:
      The input stream obtained from the URI
      Throws:
      OWLOntologyInputSourceException - if there was an IOException in obtaining the input stream from the URI.
    • wrap

      public static InputStream wrap(InputStream delegate)
      Wrap an input stream to strip the BOM.
      Parameters:
      delegate - delegate to wrap
      Returns:
      wrapped input stream