Class OntologyCacheJena
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena.OntologyCacheJena
Cache and reader for Jena ontologies.
- Author:
- Sven Hertling, Jan Portisch
-
Field Summary
Modifier and TypeFieldDescriptionstatic 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.The internal cache for ontologies that is dependent on the OntModelSpec. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Empties the cache.static org.apache.jena.ontology.OntModel
Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.static org.apache.jena.ontology.OntModel
Returns the OntModel for the given uri using a cache by default.static org.apache.jena.ontology.OntModel
Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.static org.apache.jena.ontology.OntModel
Returns the OntModel for the given uri using a cache by default.static org.apache.jena.ontology.OntModel
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
Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.static org.apache.jena.ontology.OntModel
Returns the OntModel for the given uri using a cache by default.static org.apache.jena.ontology.OntModel
Returns the OntModel for the given uri using a cache by default and the default OntModelSpec.static org.apache.jena.ontology.OntModel
Returns the OntModel for the given uri using a cache by default.static boolean
static int
static void
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.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERLogger for logging. -
DEFAULT_JENA_ONT_MODEL_SPEC
public static final org.apache.jena.ontology.OntModelSpec DEFAULT_JENA_ONT_MODEL_SPECdefault OntModelSpec that will be used when no spec is given for the Jena implementation. -
ontologyCache
The internal cache for ontologies that is dependent on the OntModelSpec. -
isDeactivatedCache
private static boolean isDeactivatedCacheThis 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 hintLang
. 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 hintLang
. 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
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
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
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
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
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()
-