Source Code Cross Referenced for ValueTableFactory.java in  » RSS-RDF » sesame » org » openrdf » sail » rdbms » schema » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » sesame » org.openrdf.sail.rdbms.schema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 static java.sql.Types.BIGINT;
009:        import static java.sql.Types.DOUBLE;
010:        import static java.sql.Types.LONGVARCHAR;
011:        import static java.sql.Types.VARCHAR;
012:
013:        import java.sql.Connection;
014:        import java.sql.SQLException;
015:        import java.util.concurrent.BlockingQueue;
016:
017:        /**
018:         * Factory class used to create or load the database tables.
019:         * 
020:         * @author James Leigh
021:         * 
022:         */
023:        public class ValueTableFactory {
024:            private static final int VCS = 127;
025:            private static final int VCL = 255;
026:            public static final boolean INDEX_VALUES = false;
027:            protected static final String LANGUAGES = "LANGUAGES";
028:            protected static final String NAMESPACES = "NAMESPACE_PREFIXES";
029:            protected static final String RESOURCES = "RESOURCES";
030:            protected static final String BNODE_VALUES = "BNODE_VALUES";
031:            protected static final String URI_VALUES = "URI_VALUES";
032:            protected static final String LURI_VALUES = "LONG_URI_VALUES";
033:            protected static final String LBS = "LABEL_VALUES";
034:            protected static final String LLBS = "LONG_LABEL_VALUES";
035:            protected static final String LANGS = "LANGUAGE_VALUES";
036:            protected static final String DTS = "DATATYPE_VALUES";
037:            protected static final String NUM_VALUES = "NUMERIC_VALUES";
038:            protected static final String TIMES = "DATETIME_VALUES";
039:            protected static final String HASH_TABLE = "HASH_VALUES";
040:            private TableFactory factory;
041:            private IdSequence ids;
042:            private boolean sequenced;
043:
044:            public ValueTableFactory(TableFactory factory) {
045:                super ();
046:                this .factory = factory;
047:            }
048:
049:            public void setIdSequence(IdSequence ids) {
050:                this .ids = ids;
051:            }
052:
053:            public void setSequenced(boolean sequenced) {
054:                this .sequenced = sequenced;
055:            }
056:
057:            public HashTable createHashTable(Connection conn,
058:                    BlockingQueue<Batch> queue) throws SQLException {
059:                ValueTable table = newValueTable();
060:                table.setRdbmsTable(createTable(conn, HASH_TABLE));
061:                //table.setTemporaryTable(factory.createTemporaryTable(conn, "INSERT_" + HASH_TABLE));
062:                initValueTable(table, queue, BIGINT, -1, true);
063:                HashTable hashTable = newHashtable(table);
064:                hashTable.init();
065:                return hashTable;
066:            }
067:
068:            public NamespacesTable createNamespacesTable(Connection conn) {
069:                return new NamespacesTable(createTable(conn, NAMESPACES));
070:            }
071:
072:            public BNodeTable createBNodeTable(Connection conn,
073:                    BlockingQueue<Batch> queue) throws SQLException {
074:                ValueTable table = createValueTable(conn, queue, BNODE_VALUES,
075:                        VARCHAR, VCS);
076:                return new BNodeTable(table);
077:            }
078:
079:            public URITable createURITable(Connection conn,
080:                    BlockingQueue<Batch> queue) throws SQLException {
081:                ValueTable shorter = createValueTable(conn, queue, URI_VALUES,
082:                        VARCHAR, VCL);
083:                ValueTable longer = createValueTable(conn, queue, LURI_VALUES,
084:                        LONGVARCHAR);
085:                return new URITable(shorter, longer);
086:            }
087:
088:            public LiteralTable createLiteralTable(Connection conn,
089:                    BlockingQueue<Batch> queue) throws SQLException {
090:                ValueTable lbs = createValueTable(conn, queue, LBS, VARCHAR,
091:                        VCL);
092:                ValueTable llbs = createValueTable(conn, queue, LLBS,
093:                        LONGVARCHAR);
094:                ValueTable lgs = createValueTable(conn, queue, LANGS, VARCHAR,
095:                        VCS);
096:                ValueTable dt = createValueTable(conn, queue, DTS, VARCHAR, VCL);
097:                ValueTable num = createValueTable(conn, queue, NUM_VALUES,
098:                        DOUBLE);
099:                ValueTable dateTime = createValueTable(conn, queue, TIMES,
100:                        BIGINT);
101:                LiteralTable literals = new LiteralTable();
102:                literals.setLabelTable(lbs);
103:                literals.setLongLabelTable(llbs);
104:                literals.setLanguageTable(lgs);
105:                literals.setDatatypeTable(dt);
106:                literals.setNumericTable(num);
107:                literals.setDateTimeTable(dateTime);
108:                return literals;
109:            }
110:
111:            public TripleTable createTripleTable(Connection conn,
112:                    String tableName) {
113:                RdbmsTable table = createTable(conn, tableName);
114:                return new TripleTable(table);
115:            }
116:
117:            protected RdbmsTable createTable(Connection conn, String name) {
118:                return factory.createTable(conn, name);
119:            }
120:
121:            protected ValueTable createValueTable(Connection conn,
122:                    BlockingQueue<Batch> queue, String name, int sqlType)
123:                    throws SQLException {
124:                return createValueTable(conn, queue, name, sqlType, -1);
125:            }
126:
127:            protected ValueTable createValueTable(Connection conn,
128:                    BlockingQueue<Batch> queue, String name, int sqlType,
129:                    int length) throws SQLException {
130:                ValueTable table = newValueTable();
131:                table.setRdbmsTable(createTable(conn, name));
132:                if (!sequenced) {
133:                    table.setTemporaryTable(factory.createTemporaryTable(conn,
134:                            "INSERT_" + name));
135:                }
136:                initValueTable(table, queue, sqlType, length, INDEX_VALUES);
137:                return table;
138:            }
139:
140:            protected HashTable newHashtable(ValueTable table) {
141:                return new HashTable(table);
142:            }
143:
144:            protected ValueTable newValueTable() {
145:                return new ValueTable();
146:            }
147:
148:            private void initValueTable(ValueTable table,
149:                    BlockingQueue<Batch> queue, int sqlType, int length,
150:                    boolean indexValues) throws SQLException {
151:                table.setQueue(queue);
152:                table.setSqlType(sqlType);
153:                table.setIdType(ids.getJdbcIdType());
154:                table.setLength(length);
155:                table.setIndexingValues(indexValues);
156:                table.initialize();
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.