1414namespace sweetrdf \InMemoryStoreSqlite \Store ;
1515
1616use Exception ;
17+ use rdfInterface \DataFactory as iDataFactory ;
1718use rdfInterface \Term ;
1819use sweetrdf \InMemoryStoreSqlite \KeyValueBag ;
1920use sweetrdf \InMemoryStoreSqlite \Log \LoggerPool ;
2021use sweetrdf \InMemoryStoreSqlite \Parser \SPARQLPlusParser ;
2122use sweetrdf \InMemoryStoreSqlite \PDOSQLiteAdapter ;
22- use sweetrdf \InMemoryStoreSqlite \Rdf \BlankNode ;
23- use sweetrdf \InMemoryStoreSqlite \Rdf \Literal ;
24- use sweetrdf \InMemoryStoreSqlite \Rdf \NamedNode ;
23+ use sweetrdf \InMemoryStoreSqlite \Rdf \DataFactory ;
2524use sweetrdf \InMemoryStoreSqlite \Serializer \TurtleSerializer ;
2625use sweetrdf \InMemoryStoreSqlite \Store \QueryHandler \AskQueryHandler ;
2726use sweetrdf \InMemoryStoreSqlite \Store \QueryHandler \ConstructQueryHandler ;
@@ -39,13 +38,20 @@ class InMemoryStoreSqlite
3938
4039 private PDOSQLiteAdapter $ db ;
4140
41+ private iDataFactory $ dataFactory ;
42+
4243 private KeyValueBag $ rowCache ;
4344
4445 private LoggerPool $ loggerPool ;
4546
46- public function __construct (PDOSQLiteAdapter $ db , LoggerPool $ loggerPool , KeyValueBag $ rowCache )
47- {
47+ public function __construct (
48+ PDOSQLiteAdapter $ db ,
49+ iDataFactory $ dataFactory ,
50+ LoggerPool $ loggerPool ,
51+ KeyValueBag $ rowCache
52+ ) {
4853 $ this ->db = $ db ;
54+ $ this ->dataFactory = $ dataFactory ;
4955 $ this ->loggerPool = $ loggerPool ;
5056 $ this ->rowCache = $ rowCache ;
5157 }
@@ -55,7 +61,7 @@ public function __construct(PDOSQLiteAdapter $db, LoggerPool $loggerPool, KeyVal
5561 */
5662 public static function createInstance ()
5763 {
58- return new self (new PDOSQLiteAdapter (), new LoggerPool (), new KeyValueBag ());
64+ return new self (new PDOSQLiteAdapter (), new DataFactory (), new LoggerPool (), new KeyValueBag ());
5965 }
6066
6167 public function getLoggerPool (): LoggerPool
@@ -193,11 +199,11 @@ public function query(string $q, string $format = 'raw'): array | bool | Term
193199 $ resultEntry = [];
194200 foreach ($ variables as $ variable ) {
195201 if ('uri ' == $ row [$ variable .' type ' ]) {
196- $ resultEntry [$ variable ] = new NamedNode ($ row [$ variable ]);
202+ $ resultEntry [$ variable ] = $ this -> dataFactory -> namedNode ($ row [$ variable ]);
197203 } elseif ('bnode ' == $ row [$ variable .' type ' ]) {
198- $ resultEntry [$ variable ] = new BlankNode ($ row [$ variable ]);
204+ $ resultEntry [$ variable ] = $ this -> dataFactory -> blankNode ($ row [$ variable ]);
199205 } elseif ('literal ' == $ row [$ variable .' type ' ]) {
200- $ resultEntry [$ variable ] = new Literal (
206+ $ resultEntry [$ variable ] = $ this -> dataFactory -> literal (
201207 $ row [$ variable ],
202208 $ row [$ variable .' lang ' ] ?? null ,
203209 $ row [$ variable .' datatype ' ] ?? null
@@ -209,7 +215,7 @@ public function query(string $q, string $format = 'raw'): array | bool | Term
209215 $ result [] = $ resultEntry ;
210216 }
211217 } else {
212- $ result = new Literal ($ queryResult );
218+ $ result = $ this -> dataFactory -> literal ($ queryResult );
213219 }
214220 }
215221
0 commit comments