Source Code Cross Referenced for RepositoryConfig.java in  » RSS-RDF » sesame » org » openrdf » repository » config » 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 » sesame » org.openrdf.repository.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
003:         *
004:         * Licensed under the Aduna BSD-style license.
005:         */
006:        package org.openrdf.repository.config;
007:
008:        import static org.openrdf.repository.config.RepositoryConfigSchema.REPOSITORY;
009:        import static org.openrdf.repository.config.RepositoryConfigSchema.REPOSITORYID;
010:        import static org.openrdf.repository.config.RepositoryConfigSchema.REPOSITORYIMPL;
011:
012:        import org.openrdf.model.BNode;
013:        import org.openrdf.model.Graph;
014:        import org.openrdf.model.Literal;
015:        import org.openrdf.model.Resource;
016:        import org.openrdf.model.ValueFactory;
017:        import org.openrdf.model.util.GraphUtil;
018:        import org.openrdf.model.util.GraphUtilException;
019:        import org.openrdf.model.vocabulary.RDF;
020:        import org.openrdf.model.vocabulary.RDFS;
021:
022:        /**
023:         * @author Arjohn Kampman
024:         */
025:        public class RepositoryConfig {
026:
027:            private String id;
028:
029:            private String title;
030:
031:            private RepositoryImplConfig implConfig;
032:
033:            /**
034:             * Create a new RepositoryConfig.
035:             */
036:            public RepositoryConfig() {
037:            }
038:
039:            /**
040:             * Create a new RepositoryConfigImpl.
041:             */
042:            public RepositoryConfig(String id) {
043:                this ();
044:                setID(id);
045:            }
046:
047:            /**
048:             * Create a new RepositoryConfigImpl.
049:             */
050:            public RepositoryConfig(String id, RepositoryImplConfig implConfig) {
051:                this (id);
052:                setRepositoryImplConfig(implConfig);
053:            }
054:
055:            /**
056:             * Create a new RepositoryConfigImpl.
057:             */
058:            public RepositoryConfig(String id, String title) {
059:                this (id);
060:                setTitle(title);
061:            }
062:
063:            /**
064:             * Create a new RepositoryConfigImpl.
065:             */
066:            public RepositoryConfig(String id, String title,
067:                    RepositoryImplConfig implConfig) {
068:                this (id, title);
069:                setRepositoryImplConfig(implConfig);
070:            }
071:
072:            public String getID() {
073:                return id;
074:            }
075:
076:            public void setID(String id) {
077:                this .id = id;
078:            }
079:
080:            public String getTitle() {
081:                return title;
082:            }
083:
084:            public void setTitle(String title) {
085:                this .title = title;
086:            }
087:
088:            public RepositoryImplConfig getRepositoryImplConfig() {
089:                return implConfig;
090:            }
091:
092:            public void setRepositoryImplConfig(RepositoryImplConfig implConfig) {
093:                this .implConfig = implConfig;
094:            }
095:
096:            /**
097:             * Validates this configuration. A {@link RepositoryConfigException} is
098:             * thrown when the configuration is invalid. The exception should contain an
099:             * error message that indicates why the configuration is invalid.
100:             * 
101:             * @throws RepositoryConfigException
102:             *         If the configuration is invalid.
103:             */
104:            public void validate() throws RepositoryConfigException {
105:                if (id == null) {
106:                    throw new RepositoryConfigException("Repository ID missing");
107:                }
108:                if (implConfig == null) {
109:                    throw new RepositoryConfigException(
110:                            "Repository implementation for repository missing");
111:                }
112:                implConfig.validate();
113:            }
114:
115:            public void export(Graph graph) {
116:                ValueFactory vf = graph.getValueFactory();
117:
118:                BNode repositoryNode = vf.createBNode();
119:
120:                graph.add(repositoryNode, RDF.TYPE, REPOSITORY);
121:
122:                if (id != null) {
123:                    graph.add(repositoryNode, REPOSITORYID, vf
124:                            .createLiteral(id));
125:                }
126:                if (title != null) {
127:                    graph.add(repositoryNode, RDFS.LABEL, vf
128:                            .createLiteral(title));
129:                }
130:                if (implConfig != null) {
131:                    Resource implNode = implConfig.export(graph);
132:                    graph.add(repositoryNode, REPOSITORYIMPL, implNode);
133:                }
134:            }
135:
136:            public void parse(Graph graph, Resource repositoryNode)
137:                    throws RepositoryConfigException {
138:                try {
139:                    Literal idLit = GraphUtil.getOptionalObjectLiteral(graph,
140:                            repositoryNode, REPOSITORYID);
141:                    if (idLit != null) {
142:                        setID(idLit.getLabel());
143:                    }
144:
145:                    Literal titleLit = GraphUtil.getOptionalObjectLiteral(
146:                            graph, repositoryNode, RDFS.LABEL);
147:                    if (titleLit != null) {
148:                        setTitle(titleLit.getLabel());
149:                    }
150:
151:                    Resource implNode = GraphUtil.getOptionalObjectResource(
152:                            graph, repositoryNode, REPOSITORYIMPL);
153:                    if (implNode != null) {
154:                        setRepositoryImplConfig(RepositoryImplConfigBase
155:                                .create(graph, implNode));
156:                    }
157:                } catch (GraphUtilException e) {
158:                    throw new RepositoryConfigException(e.getMessage(), e);
159:                }
160:            }
161:
162:            /**
163:             * Creates a new <tt>RepositoryConfig</tt> object and initializes it by
164:             * supplying the <tt>graph</tt> and <tt>repositoryNode</tt> to its
165:             * {@link #parse(Graph, Resource) parse} method.
166:             * 
167:             * @param graph
168:             * @param repositoryNode
169:             * @return
170:             * @throws RepositoryConfigException
171:             */
172:            public static RepositoryConfig create(Graph graph,
173:                    Resource repositoryNode) throws RepositoryConfigException {
174:                RepositoryConfig config = new RepositoryConfig();
175:                config.parse(graph, repositoryNode);
176:                return config;
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.