01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.managers;
07:
08: import java.sql.SQLException;
09:
10: import org.openrdf.sail.rdbms.managers.base.ValueManagerBase;
11: import org.openrdf.sail.rdbms.model.RdbmsURI;
12: import org.openrdf.sail.rdbms.schema.URITable;
13:
14: /**
15: * Manages URIs. Including creating, inserting, and looking up their
16: * IDs.
17: *
18: * @author James Leigh
19: *
20: */
21: public class UriManager extends ValueManagerBase<RdbmsURI> {
22: public static UriManager instance;
23: private URITable table;
24:
25: public UriManager() {
26: instance = this ;
27: }
28:
29: public void setUriTable(URITable shorter) {
30: this .table = shorter;
31: }
32:
33: @Override
34: public void close() throws SQLException {
35: super .close();
36: table.close();
37: }
38:
39: @Override
40: protected boolean expungeRemovedStatements(int count,
41: String condition) throws SQLException {
42: return table.expungeRemovedStatements(count, condition);
43: }
44:
45: @Override
46: protected int getBatchSize() {
47: return table.getBatchSize();
48: }
49:
50: @Override
51: protected String key(RdbmsURI value) {
52: return value.stringValue();
53: }
54:
55: @Override
56: protected void insert(Number id, RdbmsURI resource)
57: throws SQLException, InterruptedException {
58: String uri = resource.stringValue();
59: if (getIdSequence().isLong(id)) {
60: table.insertLong(id, uri);
61: } else {
62: table.insertShort(id, uri);
63: }
64: }
65:
66: @Override
67: protected void optimize() throws SQLException {
68: super.optimize();
69: table.optimize();
70: }
71:
72: }
|