Source Code Cross Referenced for DBPropDatabase.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » db » impl » 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 » Jena 2.5.5 » com.hp.hpl.jena.db.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:          [See end of file]
004:         */
005:
006:        package com.hp.hpl.jena.db.impl;
007:
008:        import com.hp.hpl.jena.graph.*;
009:        import com.hp.hpl.jena.util.iterator.*;
010:        import com.hp.hpl.jena.vocabulary.DB;
011:
012:        import java.text.SimpleDateFormat;
013:        import java.util.*;
014:
015:        /**
016:         *
017:         * A wrapper to assist in getting and setting DB information from 
018:         * a persistent store.
019:         * 
020:         * This is written in the style of enhanced nodes - no state is
021:         * stored in the DBStoreDesc, instead all state is in the
022:         * underlying graph and this is just provided as a convenience.
023:         * 
024:         * (We don't use enhanced nodes because, since we control everything
025:         * in the persistent store system description, we can avoid any
026:         * need to handle polymorhphism).
027:         * 
028:         * 
029:         * @author csayers
030:         * @version $Revision: 1.18 $
031:         */
032:        public class DBPropDatabase extends DBProp {
033:
034:            /**
035:             * @since Jena 2.0
036:             */
037:
038:            public static final Node_URI dbEngineType = (Node_URI) DB.engineType
039:                    .asNode();
040:            public static final Node_URI dbLayoutVersion = (Node_URI) DB.layoutVersion
041:                    .asNode();
042:            public static final Node_URI dbDriverVersion = (Node_URI) DB.driverVersion
043:                    .asNode();
044:            public static final Node_URI dbFormatDate = (Node_URI) DB.formatDate
045:                    .asNode();
046:            public static final Node_URI dbGraph = (Node_URI) DB.graph.asNode();
047:            public static final Node_URI dbLongObjectLength = (Node_URI) DB.longObjectLength
048:                    .asNode();
049:            public static final Node_URI dbIndexKeyLength = (Node_URI) DB.indexKeyLength
050:                    .asNode();
051:            public static final Node_URI dbIsTransactionDb = (Node_URI) DB.isTransactionDb
052:                    .asNode();
053:            public static final Node_URI dbDoCompressURI = (Node_URI) DB.doCompressURI
054:                    .asNode();
055:            public static final Node_URI dbCompressURILength = (Node_URI) DB.compressURILength
056:                    .asNode();
057:            public static final Node_URI dbTableNamePrefix = (Node_URI) DB.tableNamePrefix
058:                    .asNode();
059:
060:            public static final String dbSystemGraphName = "SystemGraph";
061:
062:            protected static SimpleDateFormat dateFormat = null;
063:
064:            public DBPropDatabase(SpecializedGraph g, String engineType,
065:                    String driverVersion, String layoutVersion,
066:                    String longObjectLength, String indexKeyLength,
067:                    String isTransactionDb, String doCompressURI,
068:                    String compressURILength, String tableNamePrefix) {
069:                super (g);
070:
071:                if (dateFormat == null) {
072:                    // Use ISO 8601 Date format and write all dates as UTC time
073:                    dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
074:                    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
075:                }
076:
077:                String today = dateFormat.format(new Date());
078:                if (engineType != null)
079:                    putPropString(dbEngineType, engineType);
080:                if (driverVersion != null)
081:                    putPropString(dbDriverVersion, driverVersion);
082:                putPropString(dbLayoutVersion, layoutVersion);
083:                putPropString(dbFormatDate, today);
084:                putPropString(dbLongObjectLength, longObjectLength);
085:                putPropString(dbIndexKeyLength, indexKeyLength);
086:                putPropString(dbIsTransactionDb, isTransactionDb);
087:                putPropString(dbDoCompressURI, doCompressURI);
088:                putPropString(dbCompressURILength, compressURILength);
089:                putPropString(dbTableNamePrefix, tableNamePrefix);
090:            }
091:
092:            public DBPropDatabase(SpecializedGraph g, Node n) {
093:                super (g, n);
094:            }
095:
096:            public DBPropDatabase(SpecializedGraph g) {
097:                super (g, findDBPropNode(g));
098:            }
099:
100:            public String getName() {
101:                return self.getURI();
102:            }
103:
104:            public String getEngineType() {
105:                return getPropString(dbEngineType);
106:            }
107:
108:            public String getDriverVersion() {
109:                return getPropString(dbDriverVersion);
110:            }
111:
112:            public String getFormatDate() {
113:                return getPropString(dbFormatDate);
114:            }
115:
116:            public String getLayoutVersion() {
117:                return getPropString(dbLayoutVersion);
118:            }
119:
120:            public String getLongObjectLength() {
121:                return getPropString(dbLongObjectLength);
122:            }
123:
124:            public String getIndexKeyLength() {
125:                return getPropString(dbIndexKeyLength);
126:            }
127:
128:            public String getIsTransactionDb() {
129:                return getPropString(dbIsTransactionDb);
130:            }
131:
132:            public String getDoCompressURI() {
133:                return getPropString(dbDoCompressURI);
134:            }
135:
136:            public String getCompressURILength() {
137:                return getPropString(dbCompressURILength);
138:            }
139:
140:            public String getTableNamePrefix() {
141:                return getPropString(dbTableNamePrefix);
142:            }
143:
144:            public void addGraph(DBPropGraph g) {
145:                putPropNode(dbGraph, g.getNode());
146:            }
147:
148:            public void removeGraph(DBPropGraph g) {
149:                SpecializedGraph.CompletionFlag complete = newComplete();
150:                ClosableIterator matches = graph.find(self, dbGraph, g
151:                        .getNode(), complete);
152:                if (matches.hasNext()) {
153:                    graph.delete((Triple) (matches.next()), complete);
154:                    g.remove();
155:                    matches.close();
156:                }
157:            }
158:
159:            public ExtendedIterator getAllGraphs() {
160:                return graph.find(self, dbGraph, null, newComplete()).mapWith(
161:                        new MapToLSet());
162:            }
163:
164:            public ExtendedIterator getAllGraphNames() {
165:                return getAllGraphs().mapWith(graphToName);
166:            }
167:
168:            static final Map1 graphToName = new Map1() {
169:                public Object map1(Object o) {
170:                    return ((DBPropGraph) o).getName();
171:                }
172:            };
173:
174:            private class MapToLSet implements  Map1 {
175:                public Object map1(Object o) {
176:                    Triple t = (Triple) o;
177:                    return new DBPropGraph(graph, t.getObject());
178:                }
179:            }
180:
181:            static Node findDBPropNode(SpecializedGraph g) {
182:                Node res = null;
183:                ClosableIterator matches = g.find(null, dbEngineType, null,
184:                        newComplete());
185:                if (matches.hasNext()) {
186:                    try {
187:                        res = ((Triple) matches.next()).getSubject();
188:                        if (matches.hasNext())
189:                            res = null;
190:                        return res;
191:                    } finally {
192:                        matches.close();
193:                    }
194:                }
195:                return null;
196:            }
197:
198:            protected String findDBPropString(Node_URI predicate) {
199:                // similar to getPropString but doesn't match on the subject field.
200:                // there should only be one instance of the db properties in the database.
201:                // if zero or multiple instances of the property, return null.
202:                ClosableIterator it = graph.find(null, predicate, null,
203:                        newComplete());
204:                if (it.hasNext()) {
205:                    try {
206:                        String res = null;
207:                        Node obj = ((Triple) it.next()).getObject();
208:                        if (!it.hasNext())
209:                            res = obj.getLiteralLexicalForm();
210:                        return res;
211:                    } finally {
212:                        it.close();
213:                    }
214:                }
215:                return null;
216:            }
217:
218:            public String getInitLongObjectLength() {
219:                return findDBPropString(dbLongObjectLength);
220:            }
221:
222:            public String getInitIndexKeyLength() {
223:                return findDBPropString(dbIndexKeyLength);
224:            }
225:
226:            public String getInitDoCompressURI() {
227:                return findDBPropString(dbDoCompressURI);
228:            }
229:
230:            public String getInitCompressURILength() {
231:                return findDBPropString(dbCompressURILength);
232:            }
233:
234:        }
235:
236:        /*
237:         *  (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
238:         *  All rights reserved.
239:         *
240:         * Redistribution and use in source and binary forms, with or without
241:         * modification, are permitted provided that the following conditions
242:         * are met:
243:         * 1. Redistributions of source code must retain the above copyright
244:         *    notice, this list of conditions and the following disclaimer.
245:         * 2. Redistributions in binary form must reproduce the above copyright
246:         *    notice, this list of conditions and the following disclaimer in the
247:         *    documentation and/or other materials provided with the distribution.
248:         * 3. The name of the author may not be used to endorse or promote products
249:         *    derived from this software without specific prior written permission.
250:
251:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
252:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
253:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
254:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
255:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
256:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
257:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
258:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
259:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
260:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.