Source Code Cross Referenced for GraphRDBMaker.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:          $Id: GraphRDBMaker.java,v 1.26 2008/01/02 12:08:23 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.db.impl;
008:
009:        import com.hp.hpl.jena.db.GraphRDB;
010:        import com.hp.hpl.jena.db.IDBConnection;
011:        import com.hp.hpl.jena.graph.*;
012:        import com.hp.hpl.jena.graph.impl.*;
013:        import com.hp.hpl.jena.shared.*;
014:        import com.hp.hpl.jena.util.CollectionFactory;
015:        import com.hp.hpl.jena.util.iterator.*;
016:        import com.hp.hpl.jena.vocabulary.*;
017:
018:        import java.rmi.server.UID;
019:        import java.util.*;
020:
021:        /**
022:         A GraphFactory that produces Graphs from database connections. 
023:         The connection is supplied when the factory is constructed. All the
024:         created graphs are tracked so that we can supply a removeAll call
025:         to dispose of them.
026:
027:         @author kers 
028:         */
029:
030:        public class GraphRDBMaker extends BaseGraphMaker {
031:            protected IDBConnection c;
032:            protected Set created = CollectionFactory.createHashedSet();
033:            int reificationStyle;
034:
035:            /**
036:                Construct a new GraphRDB factory based on the supplied DB connection.
037:                @param c the database connection
038:             */
039:            public GraphRDBMaker(IDBConnection c, ReificationStyle style) {
040:                super (style);
041:                this .c = c;
042:                this .reificationStyle = GraphRDB.styleRDB(style);
043:            }
044:
045:            /**
046:                Answer the RDFS class of this RDB GraphMaker
047:                @return JenaModelSpec.RDBMakerClass [as node]
048:             */
049:            public Node getMakerClass() {
050:                return JenaModelSpec.RDBMakerSpec.asNode();
051:            }
052:
053:            /**
054:                Augment the maker description of this maker with RDB-specific properties.
055:                TODO do this
056:             */
057:            protected void augmentDescription(Graph g, Node self) {
058:            }
059:
060:            /**
061:                Answer the default graph of this Maker; make it if necessary.
062:             */
063:            public Graph getGraph() {
064:                if (defaultGraph == null)
065:                    defaultGraph = consGraph(null, !c.containsDefaultModel());
066:                return defaultGraph;
067:            }
068:
069:            /**
070:                The default graph for this maker, or null if there isn't one.
071:             */
072:            protected Graph defaultGraph = null;
073:
074:            public Graph openGraph() {
075:                if (defaultGraph != null)
076:                    return defaultGraph;
077:                if (c.containsDefaultModel())
078:                    return defaultGraph = consGraph(null, false);
079:                throw new DoesNotExistException(
080:                        "no default graph in this GraphMaker");
081:            }
082:
083:            /**
084:                Answer an "anonymous", freshly-created graph. We fake this by creating 
085:                a graph with the name "anon_"+UID().toString. This may lead to problems 
086:                later; eg such a graph may need to be deleted when the connection is 
087:                closed.
088:                
089:                TODO resolve this issue.
090:             */
091:            public Graph createGraph() {
092:                return createGraph(freshGraphName(), false);
093:            }
094:
095:            /**
096:                Answer a freshly-synthesised "anonymous" name.
097:             */
098:            public String freshGraphName() {
099:                return "anon_" + new UID().toString();
100:            }
101:
102:            /**
103:             	Create an RDB graph and remember its name.
104:             */
105:            public Graph createGraph(String name, boolean strict) {
106:                created.add(name);
107:                boolean fresh = strict || !hasGraph(name);
108:                return consGraph(name, fresh);
109:            }
110:
111:            /**
112:                Open an existing graph; if there's no such graph, but failIfAbsent is
113:                false, create a new one. In any case, return that graph.
114:             */
115:            public Graph openGraph(String name, boolean strict) {
116:                boolean fresh = hasGraph(name) == false && strict == false;
117:                if (fresh)
118:                    created.add(name);
119:                return consGraph(name, fresh);
120:            }
121:
122:            protected Graph consGraph(String name, boolean fresh) {
123:                Graph p = c.getDefaultModelProperties().getGraph();
124:                return new GraphRDB(c, name, (fresh ? p : null),
125:                        reificationStyle, fresh);
126:            }
127:
128:            /**
129:             	Remove a graph from the database - at present, this has to be done by
130:                opening it first.
131:                
132:             */
133:            public void removeGraph(String name) {
134:                GraphRDB toDelete = (GraphRDB) openGraph(name, true);
135:                toDelete.remove();
136:                toDelete.close();
137:                created.remove(name);
138:            }
139:
140:            /**
141:                Return true iff there's a graph with the given name.
142:             */
143:            public boolean hasGraph(String name) {
144:                return c.containsModel(name);
145:            }
146:
147:            /**
148:                Remove all the graphs that have been created by this factory.
149:             */
150:            public void removeAll() {
151:                Iterator it = CollectionFactory.createHashedSet(created)
152:                        .iterator();
153:                while (it.hasNext())
154:                    removeGraph((String) it.next());
155:            }
156:
157:            public void close() { /* should consider - do we close the connection or not? */
158:            }
159:
160:            public ExtendedIterator listGraphs() {
161:                return c.getAllModelNames().filterDrop(filterDEFAULT);
162:            }
163:
164:            private Filter filterDEFAULT = new Filter() {
165:                public boolean accept(Object x) {
166:                    return "DEFAULT".equals(x);
167:                }
168:            };
169:        }
170:
171:        /*
172:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
173:         All rights reserved.
174:
175:         Redistribution and use in source and binary forms, with or without
176:         modification, are permitted provided that the following conditions
177:         are met:
178:
179:         1. Redistributions of source code must retain the above copyright
180:         notice, this list of conditions and the following disclaimer.
181:
182:         2. Redistributions in binary form must reproduce the above copyright
183:         notice, this list of conditions and the following disclaimer in the
184:         documentation and/or other materials provided with the distribution.
185:
186:         3. The name of the author may not be used to endorse or promote products
187:         derived from this software without specific prior written permission.
188:
189:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
190:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
192:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
193:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
194:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
195:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
196:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
197:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
198:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
199:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.