Source Code Cross Referenced for ResultSetTripleIterator.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 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         *  All rights reserved.
004:         *
005:         *
006:         */
007:
008:        //=======================================================================
009:        // Package
010:        package com.hp.hpl.jena.db.impl;
011:
012:        //=======================================================================
013:        // Imports
014:        import java.sql.*;
015:
016:        import com.hp.hpl.jena.db.RDFRDBException;
017:        import com.hp.hpl.jena.graph.*;
018:
019:        import org.apache.commons.logging.Log;
020:        import org.apache.commons.logging.LogFactory;
021:
022:        //=======================================================================
023:        /**
024:         * Version of ResultSetIterator that extracts database rows as Triples.
025:         *
026:         * @author hkuno.  Based on ResultSetResource Iterator, by Dave Reynolds, HPLabs, Bristol <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
027:         * @version $Revision: 1.12 $ on $Date: 2008/01/02 12:08:24 $
028:         */
029:        public class ResultSetTripleIterator extends ResultSetIterator {
030:
031:            /** The rdf model in which to instantiate any resources */
032:            protected IDBID m_graphID;
033:
034:            /** The database driver, used to access namespace and resource caches */
035:            protected IPSet m_pset;
036:
037:            /** Holds the current row as a triple */
038:            protected Triple m_triple;
039:
040:            /** True if iterating over reified statements */
041:            protected boolean m_isReif;
042:
043:            /** Statement URI if iterating over reified statements */
044:            protected Node m_stmtURI;
045:
046:            /** HasType flag if iterating over reified statements */
047:            protected boolean m_hasType;
048:
049:            static protected Log logger = LogFactory
050:                    .getLog(ResultSetTripleIterator.class);
051:
052:            // Constructor
053:            public ResultSetTripleIterator(IPSet p, IDBID graphID) {
054:                m_pset = p;
055:                setGraphID(graphID);
056:                m_isReif = false;
057:            }
058:
059:            // Constructor for iterating over reified statements
060:            public ResultSetTripleIterator(IPSet p, boolean isReif,
061:                    IDBID graphID) {
062:                m_pset = p;
063:                setGraphID(graphID);
064:                m_isReif = isReif;
065:            }
066:
067:            /**
068:             * Set m_graphID.
069:             * @param gid is the id of the graph associated with this iterator.
070:             */
071:            public void setGraphID(IDBID gid) {
072:                m_graphID = gid;
073:            }
074:
075:            /**
076:             * Reset an existing iterator to scan a new result set.
077:             * @param resultSet the result set being iterated over
078:             * @param sourceStatement The source Statement to be cleaned up when the iterator finishes - return it to cache or close it if no cache
079:             * @param cache The originating SQLcache to return the statement to, can be null
080:             * @param opname The name of the original operation that lead to this statement, can be null if SQLCache is null
081:             */
082:            public void reset(ResultSet resultSet,
083:                    PreparedStatement sourceStatement, SQLCache cache,
084:                    String opname) {
085:                super .reset(resultSet, sourceStatement, cache, opname);
086:                m_triple = null;
087:            }
088:
089:            /**
090:             * Extract the current row into a triple. 
091:             * Requires the row to be of the form:
092:             *   subject URI (String)
093:             *   predicate URI (String)
094:             *   object URI (String)
095:             *   object value (String)
096:             *   Object literal id (Object)
097:             * 
098:             * The object of the triple can be either a URI, a simple literal (in 
099:             * which case it will just have an object value, or a complex literal 
100:             * (in which case both the object value and the object literal id 
101:             * columns may be populated.
102:             */
103:            protected void extractRow() throws SQLException {
104:                int rx = 1;
105:                ResultSet rs = m_resultSet;
106:                String subj = rs.getString(1);
107:                String pred = rs.getString(2);
108:                String obj = rs.getString(3);
109:
110:                if (m_isReif) {
111:                    m_stmtURI = m_pset.driver()
112:                            .RDBStringToNode(rs.getString(4));
113:                    m_hasType = rs.getString(5).equals("T");
114:                }
115:
116:                Triple t = null;
117:
118:                try {
119:                    t = m_pset.extractTripleFromRowData(subj, pred, obj);
120:                } catch (RDFRDBException e) {
121:                    logger
122:                            .debug(
123:                                    "Extracting triple from row encountered exception: ",
124:                                    e);
125:                }
126:
127:                m_triple = t;
128:
129:            }
130:
131:            /**
132:             * Return the current row, which should have already been extracted.
133:             */
134:            protected Object getRow() {
135:                return m_triple;
136:            }
137:
138:            /**
139:             * Return the current row, which should have already been extracted.
140:             */
141:            protected Node getStmtURI() {
142:                return m_stmtURI;
143:            }
144:
145:            /**
146:             * Return the current row, which should have already been extracted.
147:             */
148:            protected boolean getHasType() {
149:                return m_hasType;
150:            }
151:
152:            /**
153:             * Delete the current row, which should have already been extracted.
154:             * Should only be used (carefully and) internally by db layer.
155:             */
156:            protected void deleteRow() {
157:                try {
158:                    m_resultSet.deleteRow();
159:                } catch (SQLException e) {
160:                    throw new RDFRDBException("Internal sql error", e);
161:                }
162:            }
163:
164:            /** 
165:             * Remove the current triple from the data store.
166:             */
167:            public void remove() {
168:                if (m_triple == null)
169:                    throw new IllegalStateException();
170:                m_pset.deleteTriple(m_triple, m_graphID);
171:            }
172:
173:        } // End class
174:
175:        /*
176:         *  (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
177:         *  All rights reserved.
178:         *
179:         * Redistribution and use in source and binary forms, with or without
180:         * modification, are permitted provided that the following conditions
181:         * are met:
182:         * 1. Redistributions of source code must retain the above copyright
183:         *    notice, this list of conditions and the following disclaimer.
184:         * 2. Redistributions in binary form must reproduce the above copyright
185:         *    notice, this list of conditions and the following disclaimer in the
186:         *    documentation and/or other materials provided with the distribution.
187:         * 3. The name of the author may not be used to endorse or promote products
188:         *    derived from this software without specific prior written permission.
189:
190:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
191:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
192:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
193:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
194:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
195:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
196:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
197:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
198:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
199:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
200:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.