diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-09-23 19:59:06 +0200 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-09-23 19:59:06 +0200 |
| commit | 099cad0129edb9822cc6ccb044b2109834715bb9 (patch) | |
| tree | 66a8b2fb048467e6c65ecb2f43531f4051a6dcd3 /src/main/scala/rsacomb/RDFoxUtil.scala | |
| parent | 5e1a39b0a4863268764de949d0f25d87fec00cce (diff) | |
| download | RSAComb-099cad0129edb9822cc6ccb044b2109834715bb9.tar.gz RSAComb-099cad0129edb9822cc6ccb044b2109834715bb9.zip | |
Add method to parse a string into a Query
This is using `SPARQLParser`, an undocumented class provided by JRDFox
Diffstat (limited to 'src/main/scala/rsacomb/RDFoxUtil.scala')
| -rw-r--r-- | src/main/scala/rsacomb/RDFoxUtil.scala | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/scala/rsacomb/RDFoxUtil.scala b/src/main/scala/rsacomb/RDFoxUtil.scala index d5a4dbb..b523d4e 100644 --- a/src/main/scala/rsacomb/RDFoxUtil.scala +++ b/src/main/scala/rsacomb/RDFoxUtil.scala | |||
| @@ -2,13 +2,16 @@ package rsacomb | |||
| 2 | 2 | ||
| 3 | /* Java imports */ | 3 | /* Java imports */ |
| 4 | import java.util.HashMap | 4 | import java.util.HashMap |
| 5 | import java.io.ByteArrayInputStream | ||
| 5 | import tech.oxfordsemantic.jrdfox.Prefixes | 6 | import tech.oxfordsemantic.jrdfox.Prefixes |
| 6 | import tech.oxfordsemantic.jrdfox.logic.IRI | 7 | import tech.oxfordsemantic.jrdfox.logic.{IRI, Query} |
| 7 | import tech.oxfordsemantic.jrdfox.client.{ | 8 | import tech.oxfordsemantic.jrdfox.client.{ |
| 8 | ConnectionFactory, | 9 | ConnectionFactory, |
| 9 | ServerConnection, | 10 | ServerConnection, |
| 10 | DataStoreConnection | 11 | DataStoreConnection |
| 11 | } | 12 | } |
| 13 | import tech.oxfordsemantic.jrdfox.formats.SPARQLParser | ||
| 14 | |||
| 12 | object RDFoxUtil { | 15 | object RDFoxUtil { |
| 13 | 16 | ||
| 14 | implicit def owlapi2rdfox(iri: org.semanticweb.owlapi.model.IRI): IRI = { | 17 | implicit def owlapi2rdfox(iri: org.semanticweb.owlapi.model.IRI): IRI = { |
| @@ -41,6 +44,14 @@ object RDFoxUtil { | |||
| 41 | (server, data) | 44 | (server, data) |
| 42 | } | 45 | } |
| 43 | 46 | ||
| 47 | def parseQuery(query: String): Query = { | ||
| 48 | val parser = new SPARQLParser( | ||
| 49 | RSA.Prefixes, | ||
| 50 | new ByteArrayInputStream(query.getBytes()) | ||
| 51 | ) | ||
| 52 | parser.parseSingleQuery() | ||
| 53 | } | ||
| 54 | |||
| 44 | def submitQuery( | 55 | def submitQuery( |
| 45 | data: DataStoreConnection, | 56 | data: DataStoreConnection, |
| 46 | prefixes: Prefixes, | 57 | prefixes: Prefixes, |
