Class OntologyCacheJena

java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena.OntologyCacheJena

public class OntologyCacheJena extends Object
Cache and reader for Jena ontologies.
Author:
Sven Hertling, Jan Portisch
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.jena.ontology.OntModelSpec
    default OntModelSpec that will be used when no spec is given for the Jena implementation.
    private static boolean
    This flag indicates whether the cache is to be used (i.e., ontologies are held in memory).
    private static final org.slf4j.Logger
    Logger for logging.
    private static Map<String,org.apache.jena.ontology.OntModel>
    The internal cache for ontologies that is dependent on the OntModelSpec.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Empties the cache.
    static org.apache.jena.ontology.OntModel
    get(File file)
    Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
    static org.apache.jena.ontology.OntModel
    get(File file, org.apache.jena.ontology.OntModelSpec spec)
    Returns the OntModel for the given uri using a cache by default.
    static org.apache.jena.ontology.OntModel
    get(String uri)
    Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
    static org.apache.jena.ontology.OntModel
    get(String uri, org.apache.jena.ontology.OntModelSpec spec)
    Returns the OntModel for the given uri using a cache by default.
    static org.apache.jena.ontology.OntModel
    get(String uri, org.apache.jena.ontology.OntModelSpec spec, boolean useCache)
    Returns the OntModel for the given uri using a cache if indicated to do so.
    static org.apache.jena.ontology.OntModel
    get(String uri, org.apache.jena.ontology.OntModelSpec spec, boolean useCache, org.apache.jena.riot.Lang hintlang)
    Returns the OntModel for the given uri using a cache if indicated to do so.
    static org.apache.jena.ontology.OntModel
    get(URI uri)
    Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
    static org.apache.jena.ontology.OntModel
    get(URI uri, org.apache.jena.ontology.OntModelSpec spec)
    Returns the OntModel for the given uri using a cache by default.
    static org.apache.jena.ontology.OntModel
    get(URL url)
    Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
    static org.apache.jena.ontology.OntModel
    get(URL url, org.apache.jena.ontology.OntModelSpec spec)
    Returns the OntModel for the given uri using a cache by default.
    static boolean
     
    static int
     
    static void
    put(String key, org.apache.jena.ontology.OntModel model)
    Adds an ont model with a specified key to the cache.
    private static org.apache.jena.ontology.OntModel
    readOntModel(String uri, org.apache.jena.ontology.OntModelSpec spec, org.apache.jena.riot.Lang hintLang)
    Read and parse an ontology.
    static void
    setDeactivatedCache(boolean deactivatedCache)
    Deactivating the cache will also clear the cache.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
      Logger for logging.
    • DEFAULT_JENA_ONT_MODEL_SPEC

      public static final org.apache.jena.ontology.OntModelSpec DEFAULT_JENA_ONT_MODEL_SPEC
      default OntModelSpec that will be used when no spec is given for the Jena implementation.
    • ontologyCache

      private static Map<String,org.apache.jena.ontology.OntModel> ontologyCache
      The internal cache for ontologies that is dependent on the OntModelSpec.
    • isDeactivatedCache

      private static boolean isDeactivatedCache
      This flag indicates whether the cache is to be used (i.e., ontologies are held in memory).
  • Constructor Details

    • OntologyCacheJena

      public OntologyCacheJena()
  • Method Details

    • get

      public static org.apache.jena.ontology.OntModel get(String uri, org.apache.jena.ontology.OntModelSpec spec, boolean useCache)
      Returns the OntModel for the given uri using a cache if indicated to do so.
      Parameters:
      uri - The URI of the ontology that shall be cached.
      spec - The specification of the ontology.
      useCache - Indicates whether the cache shall be used. If set to false, ontologies will not be held in memory but re-read every time time.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(String uri, org.apache.jena.ontology.OntModelSpec spec, boolean useCache, org.apache.jena.riot.Lang hintlang)
      Returns the OntModel for the given uri using a cache if indicated to do so.
      Parameters:
      uri - The URI of the ontology that shall be cached.
      spec - The specification of the ontology.
      useCache - Indicates whether the cache shall be used. If set to false, ontologies will not be held in memory but re-read every time time.
      hintlang - Set the hint Lang. This is the RDF syntax used when there is no way to deduce the syntax (e.g. read from a InputStream, no recognized file extension, no recognized HTTP Content-Type provided).
      Returns:
      OntModel reference.
    • readOntModel

      private static org.apache.jena.ontology.OntModel readOntModel(String uri, org.apache.jena.ontology.OntModelSpec spec, org.apache.jena.riot.Lang hintLang)
      Read and parse an ontology.
      Parameters:
      uri - URI from which shall be read.
      spec - Jena Ontology Model specification.
      hintLang - Set the hint Lang. This is the RDF syntax used when there is no way to deduce the syntax (e.g. read from a InputStream, no recognized file extension, no recognized HTTP Content-Type provided).
      Returns:
      OntModel instance that was read.
    • get

      public static org.apache.jena.ontology.OntModel get(String uri, org.apache.jena.ontology.OntModelSpec spec)
      Returns the OntModel for the given uri using a cache by default.
      Parameters:
      uri - The URI of the ontology that shall be cached.
      spec - The specification of the ontology.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(URL url, org.apache.jena.ontology.OntModelSpec spec)
      Returns the OntModel for the given uri using a cache by default.
      Parameters:
      url - The URI of the ontology that shall be cached.
      spec - The specification of the ontology.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(URI uri, org.apache.jena.ontology.OntModelSpec spec)
      Returns the OntModel for the given uri using a cache by default.
      Parameters:
      uri - The URI of the ontology that shall be cached.
      spec - The specification of the ontology.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(File file, org.apache.jena.ontology.OntModelSpec spec)
      Returns the OntModel for the given uri using a cache by default.
      Parameters:
      file - The File of the ontology that shall be cached.
      spec - The specification of the ontology.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(String uri)
      Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
      Parameters:
      uri - The URI of the ontology that shall be cached.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(URI uri)
      Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
      Parameters:
      uri - The URI of the ontology that shall be cached.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(URL url)
      Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
      Parameters:
      url - The URL of the ontology that shall be cached.
      Returns:
      OntModel reference.
    • get

      public static org.apache.jena.ontology.OntModel get(File file)
      Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.
      Parameters:
      file - The File of the ontology that shall be cached.
      Returns:
      OntModel reference.
    • put

      public static void put(String key, org.apache.jena.ontology.OntModel model)
      Adds an ont model with a specified key to the cache.
      Parameters:
      key - key is usually uri + "_" + OntModelSpec.hashCode()
      model - the ontmodel
    • emptyCache

      public static void emptyCache()
      Empties the cache.
    • isDeactivatedCache

      public static boolean isDeactivatedCache()
    • setDeactivatedCache

      public static void setDeactivatedCache(boolean deactivatedCache)
      Deactivating the cache will also clear the cache. If an ontology is requested twice it is ready every time from disk.
      Parameters:
      deactivatedCache - true if cache is to be deactivated, else false.
    • numberOfCacheEntries

      public static int numberOfCacheEntries()