Module org.apache.jena.ontapi
Class DocumentGraphRepository
java.lang.Object
org.apache.jena.ontapi.impl.repositories.DocumentGraphRepository
- All Implemented Interfaces:
GraphRepository
Simple GraphRepository implementation with location mapping.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMapping(String id, String uriOrFile) Adds mapping Graph's ID <-> source document location, which can be an OS file path, class-resource path, or URI (ftp or http).static StringcheckLocation(String uriOrFile) Checks whether the specified string is a valid URI or a file path.voidclear()Removes all graphs.booleanReturnstrueif a mapping for the specified identifier exists in the repository.longcount()Returns the number of identifiers.org.apache.jena.graph.GraphGets the graph by its ID, which can be ontology id, location (file or uri) or arbitrary identifier, if there is a mapping for it.ids()Lists all graph's identifiers.Stream<org.apache.jena.graph.Graph>Returns all already loaded graphs.org.apache.jena.graph.GraphAssociates the graph with the specified id.org.apache.jena.graph.GraphRemoves and returns the graph identified by the specifiedid, along with all its associations.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.jena.ontapi.GraphRepository
graphs
-
Constructor Details
-
DocumentGraphRepository
public DocumentGraphRepository() -
DocumentGraphRepository
-
-
Method Details
-
checkLocation
Checks whether the specified string is a valid URI or a file path.- Parameters:
uriOrFile- to validate- Returns:
- the same string
-
addMapping
Adds mapping Graph's ID <-> source document location, which can be an OS file path, class-resource path, or URI (ftp or http). File URL should be of the formfile:///.... Class-resource path string should be without leading "/" symbol. After successful load, the graph will be available both byidand byfileNameOrUri(viaget(String)method). A graph can be associated with different identifiers but only with one source.- Parameters:
id- Graph's id, arbitrary stringuriOrFile- location of the Graph document (e.g. "file://ontology.ttl")- Returns:
- this instance
- See Also:
-
get
Gets the graph by its ID, which can be ontology id, location (file or uri) or arbitrary identifier, if there is a mapping for it. The method attempts to load the graph if it is not yet in the repository.- Specified by:
getin interfaceGraphRepository- Parameters:
id-StringGraph's identifier- Returns:
Graph- Throws:
org.apache.jena.shared.JenaException- if graph cannot be loaded- See Also:
-
ids
Lists all graph's identifiers. Note that the number of identifiers may exceed the number of graphs if there are multiple id-source mappings.- Specified by:
idsin interfaceGraphRepository- Returns:
Streamof ids
-
put
Associates the graph with the specified id. If there is no id-source mapping yet, the given id will be used as a document source.- Specified by:
putin interfaceGraphRepository- Parameters:
id-StringGraph's identifier, which can be arbitrary stringgraph-Graph- Returns:
Graphthe previously associated with id ornull
-
remove
Removes and returns the graph identified by the specifiedid, along with all its associations.- Specified by:
removein interfaceGraphRepository- Parameters:
id-StringGraph's identifier- Returns:
Graphornullif the graph is not found
-
clear
public void clear()Removes all graphs.- Specified by:
clearin interfaceGraphRepository
-
count
public long count()Returns the number of identifiers. Note that it may exceed the number of graphs if there are multiple associations.- Specified by:
countin interfaceGraphRepository- Returns:
long
-
loadedGraphs
Returns all already loaded graphs. Note that the number of returned graphs may not be equal to the number of mappings (count()).- Returns:
- distinct
StreamofGraphs
-
contains
Returnstrueif a mapping for the specified identifier exists in the repository.- Specified by:
containsin interfaceGraphRepository- Parameters:
id-StringGraph's identifier- Returns:
- boolean
-