001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.sail.rdbms.schema;
007:
008: import java.sql.SQLException;
009:
010: /**
011: * A Facade to the five literal value tables. Which are labels, languages,
012: * datatypes, numeric values, and dateTime values.
013: *
014: * @author James Leigh
015: *
016: */
017: public class LiteralTable {
018: public static final boolean ONLY_INSERT_LABEL = false;
019:
020: private ValueTable labels;
021: private ValueTable longLabels;
022: private ValueTable languages;
023: private ValueTable datatypes;
024: private ValueTable numeric;
025: private ValueTable dateTime;
026: private int version;
027: private IdSequence ids;
028:
029: public void setIdSequence(IdSequence ids) {
030: this .ids = ids;
031: }
032:
033: public ValueTable getLabelTable() {
034: return labels;
035: }
036:
037: public void setLabelTable(ValueTable labels) {
038: this .labels = labels;
039: }
040:
041: public ValueTable getLongLabelTable() {
042: return longLabels;
043: }
044:
045: public void setLongLabelTable(ValueTable longLabels) {
046: this .longLabels = longLabels;
047: }
048:
049: public ValueTable getLanguageTable() {
050: return languages;
051: }
052:
053: public void setLanguageTable(ValueTable languages) {
054: this .languages = languages;
055: }
056:
057: public ValueTable getDatatypeTable() {
058: return datatypes;
059: }
060:
061: public void setDatatypeTable(ValueTable datatypes) {
062: this .datatypes = datatypes;
063: }
064:
065: public ValueTable getNumericTable() {
066: return numeric;
067: }
068:
069: public void setNumericTable(ValueTable numeric) {
070: this .numeric = numeric;
071: }
072:
073: public ValueTable getDateTimeTable() {
074: return dateTime;
075: }
076:
077: public void setDateTimeTable(ValueTable dateTime) {
078: this .dateTime = dateTime;
079: }
080:
081: public void close() throws SQLException {
082: labels.close();
083: longLabels.close();
084: languages.close();
085: datatypes.close();
086: numeric.close();
087: dateTime.close();
088: }
089:
090: public int getBatchSize() {
091: return labels.getBatchSize();
092: }
093:
094: public int getIdVersion() {
095: return version;
096: }
097:
098: public void insertSimple(Number id, String label)
099: throws SQLException, InterruptedException {
100: if (ids.isLong(id)) {
101: longLabels.insert(id, label);
102: } else {
103: labels.insert(id, label);
104: }
105: }
106:
107: public void insertLanguage(Number id, String label, String language)
108: throws SQLException, InterruptedException {
109: insertSimple(id, label);
110: languages.insert(id, language);
111: }
112:
113: public void insertDatatype(Number id, String label, String datatype)
114: throws SQLException, InterruptedException {
115: insertSimple(id, label);
116: datatypes.insert(id, datatype);
117: }
118:
119: public void insertNumeric(Number id, String label, String datatype,
120: double value) throws SQLException, InterruptedException {
121: labels.insert(id, label);
122: datatypes.insert(id, datatype);
123: numeric.insert(id, value);
124: }
125:
126: public void insertDateTime(Number id, String label,
127: String datatype, long value) throws SQLException,
128: InterruptedException {
129: labels.insert(id, label);
130: datatypes.insert(id, datatype);
131: dateTime.insert(id, value);
132: }
133:
134: public void optimize() throws SQLException {
135: labels.optimize();
136: longLabels.optimize();
137: languages.optimize();
138: datatypes.optimize();
139: numeric.optimize();
140: dateTime.optimize();
141: }
142:
143: public boolean expungeRemovedStatements(int count, String condition)
144: throws SQLException {
145: boolean bool = false;
146: bool |= labels.expungeRemovedStatements(count, condition);
147: bool |= longLabels.expungeRemovedStatements(count, condition);
148: bool |= languages.expungeRemovedStatements(count, condition);
149: bool |= datatypes.expungeRemovedStatements(count, condition);
150: bool |= numeric.expungeRemovedStatements(count, condition);
151: bool |= dateTime.expungeRemovedStatements(count, condition);
152: return bool;
153: }
154: }
|