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


001:        package org.ontoware.rdfreactor.runtime;
002:
003:        import org.ontoware.rdf2go.model.Model;
004:        import org.ontoware.rdf2go.model.node.BlankNode;
005:        import org.ontoware.rdf2go.model.node.DatatypeLiteral;
006:        import org.ontoware.rdf2go.model.node.LanguageTagLiteral;
007:        import org.ontoware.rdf2go.model.node.Literal;
008:        import org.ontoware.rdf2go.model.node.Node;
009:        import org.ontoware.rdf2go.model.node.Resource;
010:        import org.ontoware.rdf2go.model.node.URI;
011:        import org.ontoware.rdf2go.vocabulary.RDF;
012:        import org.slf4j.Logger;
013:        import org.slf4j.LoggerFactory;
014:
015:        /**
016:         * <b>ReactorBaseImpl</b> is the base class for instances of classes from the
017:         * RDFS/OWL schema generated by the code generator. <br>
018:         * 
019:         * If a class inheriting from ReactorBaseImpl is instantiated, it represents an
020:         * instance of a class from an RDFS/OWL schema. The properties of this class
021:         * instance are stored in an RDF model using RDF2Go (via the static Bridge
022:         * object) as triples of the form: (this.instanceIdentifier, key, value). <br>
023:         * 
024:         * Besides methods for putting, getting and removing properties, the Map<URI,
025:         * Object> Interface is also supported for handling of all properties of this
026:         * instance in one Map, backed by the actual RDF2Go model.
027:         * 
028:         * <br>
029:         * RDF Reactor uses the following naming:
030:         * 
031:         * <b>resource</b> - instance of an RDF schema class, identified by the
032:         * resource ID (an URI or BlankNode), almost all statements about the resource
033:         * use the resource ID as the object
034:         * 
035:         * <b>property</b> - a property belongs to a resource, represented by the
036:         * predicate of a statement about a resource
037:         * 
038:         * <b>value</b> - value of a property of a resource, represented by the object
039:         * of the statement with the property as predicate and the resource ID as the
040:         * subject
041:         * 
042:         * @author $Author: xamde $
043:         * @version $Id: ReactorBaseImpl.java,v 1.24 2006/12/05 19:47:28 xamde Exp $
044:         * 
045:         * 
046:         */
047:        public class ReactorRuntimeEntity implements  Resource {
048:
049:            private static Logger log = LoggerFactory
050:                    .getLogger(ReactorRuntimeEntity.class);
051:
052:            /**
053:             * the underlying RDF2Go model in which the triples representing the
054:             * properties of this object are saved
055:             */
056:            protected Model model;
057:
058:            /**
059:             * the URI of the RDFS class from which this object is an instance
060:             */
061:            protected URI classURI;
062:
063:            /**
064:             * the identifier of this instance is a URI or a BlankNode. It is used as
065:             * the Subject of all triples representing this instance in the RDF model.
066:             */
067:            private Resource instanceIdentifier;
068:
069:            /**
070:             * Constructor: create a ReactorBaseImpl for the RDFS/OWL schema class
071:             * identified by classURI, with instanceIdentifier as the identifing URL or
072:             * BlankNode.
073:             * 
074:             * @param model,
075:             *            the underlying RDF2Go model
076:             * @param classURI,
077:             *            URI of the RDFS/OWL class from which this object is an
078:             *            instance
079:             * @param instanceIdentifier,
080:             *            has to be an URI or URL or BlankNode
081:             * @param write
082:             *            if true, the triple (this, rdf:type, classURI) is written to
083:             *            the model (in addition to any other triples denoting
084:             *            properties of the instance)
085:             */
086:            public ReactorRuntimeEntity(Model model, URI classURI,
087:                    Resource instanceIdentifier, boolean write) {
088:                this .model = model;
089:                this .classURI = classURI;
090:                this .instanceIdentifier = (Resource) instanceIdentifier;
091:
092:                // this can lead to concurrenty exceptions when used in
093:                // iterators on the model
094:                if (write) {
095:                    try {
096:                        // add type information only if not present
097:                        if (!model.contains(this .instanceIdentifier, RDF.type,
098:                                classURI)) {
099:                            log.debug("adding type information: "
100:                                    + this .instanceIdentifier + " a "
101:                                    + classURI);
102:                            Base.add(model, instanceIdentifier, RDF.type,
103:                                    classURI);
104:
105:                        }
106:                    } catch (Exception e) {
107:                        throw new RuntimeException(e);
108:                    }
109:                }
110:            }
111:
112:            /**
113:             * Constructor: create a ReactorBaseImpl for the RDFS/OWL schema class
114:             * identified by classURI, with instanceIdentifier as the identifing URL or
115:             * BlankNode. Don't write (this, rdf:type, classURI) for this instance to the
116:             * model.
117:             * 
118:             * @param model,
119:             *            the underlying RDF2Go model
120:             * @param classURI,
121:             *            URI of the RDFS/OWL class from which this object is an
122:             *            instance
123:             * @param instanceIdentifier,
124:             *            has to be an URI or URL or BlankNode
125:             */
126:            public ReactorRuntimeEntity(Model model, URI classURI,
127:                    Resource instanceIdentifier) {
128:                // FIXME: default true or false?
129:                this (model, classURI, instanceIdentifier, false);
130:            }
131:
132:            /**
133:             * implements
134:             * 
135:             * @see ReactorEntity
136:             */
137:            public Resource getResource() {
138:                return this .instanceIdentifier;
139:            }
140:
141:            public Model getModel() {
142:                return this .model;
143:            }
144:
145:            /**
146:             * @return the URI of the RDFS schema class of which this object is an
147:             *         instance
148:             */
149:            public URI getRDFSClassURI() {
150:                return this .classURI;
151:            }
152:
153:            // //////////////////////////////////////
154:            // override some java.lang.Object methods
155:
156:            /**
157:             * implement
158:             * 
159:             * @see Object methods
160:             */
161:            public boolean equals(Object other) {
162:
163:                if (other instanceof  ReactorRuntimeEntity) {
164:                    return ((ReactorRuntimeEntity) other).getResource().equals(
165:                            this .getResource());
166:                } else if (other instanceof  URI) {
167:                    return this .getResource().equals(other);
168:                } else
169:                    return false;
170:            }
171:
172:            /**
173:             * implement
174:             * 
175:             * @see Object methods
176:             */
177:            public int hashCode() {
178:                return this .instanceIdentifier.hashCode();
179:            }
180:
181:            /**
182:             * implement
183:             * 
184:             * @see Object methods
185:             * @return a string representation of the instance identifier (URI or blank
186:             *         node). Representations are dependant on the used RDF2Go adaptor.
187:             */
188:            public String toString() {
189:                return this .instanceIdentifier.toString();
190:            }
191:
192:            /**
193:             * Cast .this object to the given target Java type.
194:             * 
195:             * @param targetType -
196:             *            Java type to which to cast this object
197:             * @return converted object
198:             */
199:            public Object castTo(Class<?> targetType) {
200:                return Base.castTo(model, instanceIdentifier, targetType);
201:            }
202:
203:            public boolean isInstanceof(URI classURI) {
204:                return Base.hasInstance(model, classURI, instanceIdentifier);
205:            }
206:
207:            public BlankNode asBlankNode() throws ClassCastException {
208:                return instanceIdentifier.asBlankNode();
209:            }
210:
211:            public DatatypeLiteral asDatatypeLiteral()
212:                    throws ClassCastException {
213:                return instanceIdentifier.asDatatypeLiteral();
214:            }
215:
216:            public LanguageTagLiteral asLanguageTagLiteral()
217:                    throws ClassCastException {
218:                return instanceIdentifier.asLanguageTagLiteral();
219:            }
220:
221:            public Literal asLiteral() throws ClassCastException {
222:                return instanceIdentifier.asLiteral();
223:            }
224:
225:            public Resource asResource() throws ClassCastException {
226:                return instanceIdentifier.asResource();
227:            }
228:
229:            public URI asURI() throws ClassCastException {
230:                return instanceIdentifier.asURI();
231:            }
232:
233:            public int compareTo(Node o) {
234:                return instanceIdentifier.compareTo(o);
235:            }
236:
237:            public String toSPARQL() {
238:                return instanceIdentifier.toSPARQL();
239:            }
240:
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.