Source Code Cross Referenced for Ex1.java in  » RSS-RDF » Jena-2.5.5 » arq » examples » 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 » arq.examples 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         * All rights reserved.
004:         * [See end of file]
005:         */
006:
007:        package arq.examples;
008:
009:        // The ARQ application API.
010:        import com.hp.hpl.jena.sparql.util.IndentedWriter;
011:        import com.hp.hpl.jena.query.*;
012:        import com.hp.hpl.jena.rdf.model.*;
013:        import com.hp.hpl.jena.vocabulary.DC;
014:
015:        /** Example 1 : Execute a simple SELECT query on a model
016:         *  to find the DC titles contained in a model. 
017:         * 
018:         * @author Andy Seaborne
019:         */
020:
021:        public class Ex1 {
022:            static public final String NL = System
023:                    .getProperty("line.separator");
024:
025:            public static void main(String[] args) {
026:                // Create the data.
027:                // This wil be the background (unnamed) graph in the dataset.
028:                Model model = createModel();
029:
030:                // First part or the query string 
031:                String prolog = "PREFIX dc: <" + DC.getURI() + ">";
032:
033:                // Query string.
034:                String queryString = prolog + NL
035:                        + "SELECT ?title WHERE {?x dc:title ?title}";
036:
037:                Query query = QueryFactory.create(queryString);
038:                // Print with line numbers
039:                query.serialize(new IndentedWriter(System.out, true));
040:                System.out.println();
041:
042:                // Create a single execution of this query, apply to a model
043:                // which is wrapped up as a Dataset
044:
045:                QueryExecution qexec = QueryExecutionFactory.create(query,
046:                        model);
047:                // Or QueryExecutionFactory.create(queryString, model) ;
048:
049:                System.out.println("Titles: ");
050:
051:                try {
052:                    // Assumption: it's a SELECT query.
053:                    ResultSet rs = qexec.execSelect();
054:
055:                    // The order of results is undefined. 
056:                    for (; rs.hasNext();) {
057:                        QuerySolution rb = rs.nextSolution();
058:
059:                        // Get title - variable names do not include the '?' (or '$')
060:                        RDFNode x = rb.get("title");
061:
062:                        // Check the type of the result value
063:                        if (x.isLiteral()) {
064:                            Literal titleStr = (Literal) x;
065:                            System.out.println("    " + titleStr);
066:                        } else
067:                            System.out.println("Strange - not a literal: " + x);
068:
069:                    }
070:                } finally {
071:                    // QueryExecution objects should be closed to free any system resources 
072:                    qexec.close();
073:                }
074:            }
075:
076:            public static Model createModel() {
077:                Model m = ModelFactory.createDefaultModel();
078:
079:                Resource r1 = m.createResource("http://example.org/book#1");
080:                Resource r2 = m.createResource("http://example.org/book#2");
081:
082:                r1.addProperty(DC.title, "SPARQL - the book").addProperty(
083:                        DC.description, "A book about SPARQL");
084:
085:                r2.addProperty(DC.title, "Advanced techniques for SPARQL");
086:
087:                return m;
088:            }
089:        }
090:
091:        /*
092:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
093:         * All rights reserved.
094:         *
095:         * Redistribution and use in source and binary forms, with or without
096:         * modification, are permitted provided that the following conditions
097:         * are met:
098:         * 1. Redistributions of source code must retain the above copyright
099:         *    notice, this list of conditions and the following disclaimer.
100:         * 2. Redistributions in binary form must reproduce the above copyright
101:         *    notice, this list of conditions and the following disclaimer in the
102:         *    documentation and/or other materials provided with the distribution.
103:         * 3. The name of the author may not be used to endorse or promote products
104:         *    derived from this software without specific prior written permission.
105:         *
106:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
107:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
108:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
109:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
110:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
111:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
112:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
113:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
114:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
115:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
116:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.