1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.ontotext.ordi.wsmo4rdf.impl;
19
20 import org.openrdf.model.URI;
21 import org.openrdf.model.Value;
22
23 import com.ontotext.ordi.exception.ORDIException;
24 import com.ontotext.ordi.tripleset.TConnection;
25 import com.ontotext.ordi.wsmo4rdf.WSMLTripleHandler;
26
27 public class Handler2TConnectionImpl implements WSMLTripleHandler {
28
29 protected final TConnection connection;
30 private int statementsProcessed;
31
32 public Handler2TConnectionImpl(TConnection connection) {
33 if (connection == null) {
34 throw new IllegalArgumentException();
35 }
36 if (connection.isOpen() == false) {
37 throw new IllegalArgumentException("Connection is closed!");
38 }
39 this.connection = connection;
40 }
41
42 public void handleTriple(URI subject, URI predicate, Value object,
43 URI namedGraph, URI... tripleSets) {
44 try {
45 connection.addStatement(subject, predicate, object, namedGraph,
46 tripleSets);
47 statementsProcessed++;
48 } catch (ORDIException e) {
49 throw new RuntimeException(
50 "Could not persist WSML triple to ORDI model!", e);
51 }
52 }
53
54 public int getStatementsProcessed() {
55 return statementsProcessed;
56 }
57
58 }