Package com.powsybl.cgmes.model.test
Class FakeTripleStore
- java.lang.Object
-
- com.powsybl.cgmes.model.test.FakeTripleStore
-
- All Implemented Interfaces:
TripleStore
public final class FakeTripleStore extends Object implements TripleStore
- Author:
- Miora Vedelago
-
-
Constructor Summary
Constructors Constructor Description FakeTripleStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(TripleStore source)
Add all statements of the source Triplestore to this Triplestore.String
add(String contextName, String namespace, String type, PropertyBag properties)
Add to the triple store statements for creating a new resource, instance of a specific classvoid
add(String contextName, String namespace, String type, PropertyBags objects)
Add to the triple store statements for creating new resources, instances of a specific classvoid
addNamespace(String prefix, String namespace)
Add a namespace to the triple storevoid
clear(String contextName)
Delete all the statements in a given context.Set<String>
contextNames()
Get all the context names currently defined in the Triplestore.void
defineQueryPrefix(String prefix, String namespace)
Define namespace prefix bindings that will be used in the text of queries.String
getImplementationName()
Return the implementation name defined in the triple storeList<PrefixNamespace>
getNamespaces()
Return the namespaces defined in the triple storevoid
print(PrintStream out)
Print a summary of the contents of the Triplestore.void
print(Consumer<String> liner)
Print a summary of the contents of the Triplestore.PropertyBags
query(String query)
Perform a SPARQL query on the Triplestore.void
read(InputStream is, String base, String contextName)
Read statements from an input stream and store them in the Triplestore under the given context name.void
update(String queryText)
Perform a SPARQL update on the Triplestore.void
write(DataSource ds)
Write the contents of the Triplestore in the given data source.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.powsybl.triplestore.api.TripleStore
getOptions, write
-
-
-
-
Method Detail
-
read
public void read(InputStream is, String base, String contextName)
Description copied from interface:TripleStore
Read statements from an input stream and store them in the Triplestore under the given context name.- Specified by:
read
in interfaceTripleStore
- Parameters:
is
- input stream containing statements that will be added to the Triplestorebase
- the base URI used to convert relative URI's to absolute URI'scontextName
- name of the context where statements will be added
-
write
public void write(DataSource ds)
Description copied from interface:TripleStore
Write the contents of the Triplestore in the given data source. Statements in each context will be written to separate fileNames in the output data source- Specified by:
write
in interfaceTripleStore
- Parameters:
ds
- the output data source
-
print
public void print(PrintStream out)
Description copied from interface:TripleStore
Print a summary of the contents of the Triplestore. Typically a list of contexts and its size (number of statements).- Specified by:
print
in interfaceTripleStore
- Parameters:
out
- output stream where the summary will be written
-
print
public void print(Consumer<String> liner)
Description copied from interface:TripleStore
Print a summary of the contents of the Triplestore. Typically a list of contexts and its size (number of statements).- Specified by:
print
in interfaceTripleStore
- Parameters:
liner
- a function that accepts strings (the lines of the summary report)
-
clear
public void clear(String contextName)
Description copied from interface:TripleStore
Delete all the statements in a given context.- Specified by:
clear
in interfaceTripleStore
- Parameters:
contextName
- the context to be cleared
-
defineQueryPrefix
public void defineQueryPrefix(String prefix, String namespace)
Description copied from interface:TripleStore
Define namespace prefix bindings that will be used in the text of queries. Example:tripleStore.defineQueryPrefix("foaf", "http://xmlns.com/foaf/0.1/");
- Specified by:
defineQueryPrefix
in interfaceTripleStore
- Parameters:
prefix
- the prefix to be used in the text of queries as a replacement for the namespacenamespace
- the URL of the namespace
-
query
public PropertyBags query(String query)
Description copied from interface:TripleStore
Perform a SPARQL query on the Triplestore.- Specified by:
query
in interfaceTripleStore
- Parameters:
query
- the text of the query, written in SPARQL query language- Returns:
- the solution sequence of the query (the ways in which the query matches the data)
-
add
public void add(String contextName, String namespace, String type, PropertyBags objects)
Description copied from interface:TripleStore
Add to the triple store statements for creating new resources, instances of a specific class- Specified by:
add
in interfaceTripleStore
- Parameters:
contextName
- context where the statements are addednamespace
- the namespace of the class of the new resourcestype
- the class of the new resourcesobjects
- properties of the resources
-
add
public String add(String contextName, String namespace, String type, PropertyBag properties)
Description copied from interface:TripleStore
Add to the triple store statements for creating a new resource, instance of a specific class- Specified by:
add
in interfaceTripleStore
- Parameters:
contextName
- the context where the statements are addednamespace
- the namespace of the class of the new resourcetype
- the class of the new resourceproperties
- properties of the resource- Returns:
- the id of the new resource
-
add
public void add(TripleStore source)
Description copied from interface:TripleStore
Add all statements of the source Triplestore to this Triplestore.- Specified by:
add
in interfaceTripleStore
- Parameters:
source
- the Triplestore containing statements to be added to this Triplestore
-
contextNames
public Set<String> contextNames()
Description copied from interface:TripleStore
Get all the context names currently defined in the Triplestore.- Specified by:
contextNames
in interfaceTripleStore
- Returns:
- a set of all context names
-
update
public void update(String queryText)
Description copied from interface:TripleStore
Perform a SPARQL update on the Triplestore.- Specified by:
update
in interfaceTripleStore
- Parameters:
queryText
- the text of the query, written in SPARQL Update language
-
addNamespace
public void addNamespace(String prefix, String namespace)
Description copied from interface:TripleStore
Add a namespace to the triple store- Specified by:
addNamespace
in interfaceTripleStore
- Parameters:
prefix
- the prefix of the namespacenamespace
- the namespace
-
getNamespaces
public List<PrefixNamespace> getNamespaces()
Description copied from interface:TripleStore
Return the namespaces defined in the triple store- Specified by:
getNamespaces
in interfaceTripleStore
- Returns:
- the list of namespaces defined in the triple store
-
getImplementationName
public String getImplementationName()
Description copied from interface:TripleStore
Return the implementation name defined in the triple store- Specified by:
getImplementationName
in interfaceTripleStore
- Returns:
- the string implementation name of the triplestore object
-
-