Source Code Cross Referenced for FoafExample.java in  » Search-Engine » semweb4j » org » ontoware » rdf2go » example » 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 » Search Engine » semweb4j » org.ontoware.rdf2go.example 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.ontoware.rdf2go.example;
002:
003:        import org.ontoware.aifbcommons.collection.ClosableIterator;
004:        import org.ontoware.rdf2go.Reasoning;
005:        import org.ontoware.rdf2go.impl.jena24.DumpUtils;
006:        import org.ontoware.rdf2go.impl.jena24.ModelImplJena24;
007:        import org.ontoware.rdf2go.model.Model;
008:        import org.ontoware.rdf2go.model.Statement;
009:        import org.ontoware.rdf2go.model.node.BlankNode;
010:        import org.ontoware.rdf2go.model.node.Resource;
011:        import org.ontoware.rdf2go.model.node.URI;
012:        import org.ontoware.rdf2go.model.node.Variable;
013:        import org.ontoware.rdf2go.vocabulary.RDF;
014:        import org.ontoware.rdf2go.vocabulary.RDFS;
015:
016:        /**
017:         * This is a simple example of how to use RDF2GO to create some statments about
018:         * persons using the FOAF vocabulary.
019:         * 
020:         * It shows
021:         * <ul>
022:         * <li>how to create a model</li>
023:         * <li>how to add some statements to the model</li>
024:         * <li>how to query the model
025:         * <li>
026:         * </ul>
027:         * 
028:         * @author mvo (Max V�lkel), wth (Werner Thiemann)
029:         * 
030:         */
031:        public class FoafExample {
032:
033:            /**
034:             * Create a foaf file
035:             * 
036:             * @param args
037:             *            None
038:             * @throws Exception
039:             */
040:            public static void main(String[] args) throws Exception {
041:
042:                /*
043:                 * first of all we have to instantiate a RDF2GO model with an underlying
044:                 * framework here we choose Jena
045:                 */
046:
047:                // no inferencing
048:                Model model = new ModelImplJena24(Reasoning.none);
049:                // alternatives
050:                // new ModelImplYars();
051:                // new ModelImplNG4J();
052:
053:                /*
054:                 * before we can do anything useful, we have to define the uris we want
055:                 * to use
056:                 */
057:                // use the uris defined by foaf
058:                URI foafName = model
059:                        .createURI("http://xmlns.com/foaf/0.1/name");
060:                URI foafPerson = model
061:                        .createURI("http://xmlns.com/foaf/0.1/Person");
062:                URI foafTitle = model
063:                        .createURI("http://xmlns.com/foaf/0.1/title");
064:                URI foafKnows = model
065:                        .createURI("http://xmlns.com/foaf/0.1/knows");
066:                URI foafHomepage = model
067:                        .createURI("http://xmlns.com/foaf/0.1/homepage");
068:                // use a blank node for the person
069:                BlankNode werner = model.createBlankNode();
070:
071:                /*
072:                 * now we can add statements to the model (for easier reading we
073:                 * replaced the blank nodes cryptical letters with a human readable
074:                 * version - you will see something different when exectuing this
075:                 * example
076:                 */
077:                // _:blankNodeWerner
078:                // <http://xmlns.com/foaf/0.1/homepage>
079:                // <http://www.blue-agents.com> .
080:                model.addStatement(werner, foafHomepage, model
081:                        .createURI("http://www.blue-agents.com"));
082:                // _:blankNodeWerner
083:                // <http://xmlns.com/foaf/0.1/title>
084:                // "Mr" .
085:                model.addStatement(werner, foafTitle, "Mr");
086:                // _:blankNodeWerner
087:                // <http://xmlns.com/foaf/0.1/name>
088:                // "Werner Thiemann" .
089:                model.addStatement(werner, foafName, "Werner Thiemann");
090:
091:                // _:blankNodeWerner
092:                // <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
093:                // <http://xmlns.com/foaf/0.1/Person> .
094:                model.addStatement(werner, RDF.type, foafPerson);
095:
096:                BlankNode max = model.createBlankNode();
097:                // _:blankNodeMax
098:                // <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
099:                // <http://xmlns.com/foaf/0.1/Person> .
100:                model.addStatement(max, RDF.type, foafPerson);
101:                // _:blankNodeMax
102:                // <http://xmlns.com/foaf/0.1/name>
103:                // "Max Voelkel" .
104:                model.addStatement(max, foafName, "Max V�lkel");
105:                // _:blankNodeMax
106:                // <http://www.w3.org/2000/01/rdf-schema#seeAlso>
107:                // <http://www.aifb.uni-karlsruhe.de/WBS/mvo/foaf.rdf.xml> .
108:                model.addStatement(max, RDFS.seeAlso, model
109:                        .createURI("http://www.xam.de/foaf.rdf.xml"));
110:
111:                // link via foaf:knows
112:                // _:blankNodeWerner
113:                // <http://xmlns.com/foaf/0.1/knows>
114:                // _:blankNodeMax.
115:                model.addStatement(werner, foafKnows, max);
116:
117:                // default dump
118:                DumpUtils.dump(model, null);
119:
120:                // queries
121:                // get all persons
122:
123:                ClosableIterator<? extends Statement> it = model
124:                        .findStatements(Variable.ANY, RDF.type, foafPerson);
125:                while (it.hasNext()) {
126:                    Resource person = it.next().getSubject();
127:                    System.out.println(person + " is a person");
128:
129:                    // get foaf:name
130:                    ClosableIterator<? extends Statement> it2 = model
131:                            .findStatements(person, foafName, Variable.ANY);
132:                    while (it2.hasNext()) {
133:                        System.out.println(person + " has the foaf:name "
134:                                + it2.next().getObject());
135:                    }
136:                }
137:            }
138:
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.