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


001:        package org.ontoware.rdf2go.model.impl;
002:
003:        import java.util.HashMap;
004:        import java.util.Iterator;
005:        import java.util.Map;
006:
007:        import org.ontoware.rdf2go.exception.ModelRuntimeException;
008:        import org.ontoware.rdf2go.model.DiffReader;
009:        import org.ontoware.rdf2go.model.Model;
010:        import org.ontoware.rdf2go.model.ModelChangedListener;
011:        import org.ontoware.rdf2go.model.NotifyingModel;
012:        import org.ontoware.rdf2go.model.Statement;
013:        import org.ontoware.rdf2go.model.TriplePattern;
014:        import org.ontoware.rdf2go.model.node.Node;
015:        import org.ontoware.rdf2go.model.node.Resource;
016:        import org.ontoware.rdf2go.model.node.URI;
017:
018:        /**
019:         * Adds notifying capabilites to existing models.
020:         * @author voelkel
021:         *
022:         */
023:        public class NotifyingModelLayer extends DelegatingModel implements 
024:                NotifyingModel {
025:
026:            public NotifyingModelLayer(Model model) {
027:                super (model);
028:            }
029:
030:            // /////////////////////////////////
031:            // override methods to be able to notify
032:
033:            /*
034:             * (non-Javadoc)
035:             * 
036:             * @see org.ontoware.rdf2go.core.common.CommonModelWriter#addAll(org.ontoware.rdf2go.core.common.CommonModelReader)
037:             */
038:            @Override
039:            public void addAll(Iterator<? extends Statement> other)
040:                    throws ModelRuntimeException {
041:                while (other.hasNext()) {
042:                    this .addStatement(other.next());
043:                }
044:            }
045:
046:            /*
047:             * (non-Javadoc)
048:             * 
049:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#addStatement(org.ontoware.rdf2go.core.node.Resource,
050:             *      org.ontoware.rdf2go.core.node.URI,
051:             *      org.ontoware.rdf2go.core.node.Node)
052:             */
053:            @Override
054:            public void addStatement(Resource subject, URI predicate,
055:                    Node object) throws ModelRuntimeException {
056:                this .addStatement(super .getDelegatedModel().createStatement(
057:                        subject, predicate, object));
058:            }
059:
060:            /*
061:             * (non-Javadoc)
062:             * 
063:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#addStatement(org.ontoware.rdf2go.core.node.Resource,
064:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
065:             *      java.lang.String)
066:             */
067:            @Override
068:            public void addStatement(Resource subject, URI predicate,
069:                    String literal, String languageTag)
070:                    throws ModelRuntimeException {
071:                this .addStatement(getDelegatedModel().createStatement(
072:                        subject,
073:                        predicate,
074:                        getDelegatedModel().createLanguageTagLiteral(literal,
075:                                languageTag)));
076:            }
077:
078:            /*
079:             * (non-Javadoc)
080:             * 
081:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#addStatement(org.ontoware.rdf2go.core.node.Resource,
082:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
083:             *      org.ontoware.rdf2go.core.node.URI)
084:             */
085:            @Override
086:            public void addStatement(Resource subject, URI predicate,
087:                    String literal, URI datatypeURI)
088:                    throws ModelRuntimeException {
089:                this .addStatement(subject, predicate, getDelegatedModel()
090:                        .createDatatypeLiteral(literal, datatypeURI));
091:            }
092:
093:            /*
094:             * (non-Javadoc)
095:             * 
096:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#addStatement(org.ontoware.rdf2go.core.node.Resource,
097:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String)
098:             */
099:            @Override
100:            public void addStatement(Resource subject, URI predicate,
101:                    String literal) throws ModelRuntimeException {
102:                this .addStatement(getDelegatedModel().createStatement(subject,
103:                        predicate,
104:                        getDelegatedModel().createPlainLiteral(literal)));
105:            }
106:
107:            /*
108:             * (non-Javadoc)
109:             * 
110:             * @see org.ontoware.rdf2go.core.common.CommonModelWriter#addStatement(S)
111:             */
112:            @Override
113:            public void addStatement(Statement statement)
114:                    throws ModelRuntimeException {
115:                for (ModelChangedListener listener : this .modelChangeListener
116:                        .keySet()) {
117:                    TriplePattern pattern = this .modelChangeListener
118:                            .get(listener);
119:                    if (pattern == null || pattern.matches(statement)) {
120:                        listener.addedStatement(statement);
121:                    }
122:                }
123:                getDelegatedModel().addStatement(statement);
124:            }
125:
126:            /*
127:             * (non-Javadoc)
128:             * 
129:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#addStatement(java.lang.String,
130:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
131:             *      java.lang.String)
132:             */
133:            @Override
134:            public void addStatement(String subjectURIString, URI predicate,
135:                    String literal, String languageTag)
136:                    throws ModelRuntimeException {
137:                this .addStatement(getDelegatedModel().createStatement(
138:                        getDelegatedModel().createURI(subjectURIString),
139:                        predicate,
140:                        getDelegatedModel().createLanguageTagLiteral(literal,
141:                                languageTag)));
142:            }
143:
144:            /*
145:             * (non-Javadoc)
146:             * 
147:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#addStatement(java.lang.String,
148:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
149:             *      org.ontoware.rdf2go.core.node.URI)
150:             */
151:            @Override
152:            public void addStatement(String subjectURIString, URI predicate,
153:                    String literal, URI datatypeURI)
154:                    throws ModelRuntimeException {
155:                this .addStatement(getDelegatedModel().createStatement(
156:                        getDelegatedModel().createURI(subjectURIString),
157:                        predicate,
158:                        getDelegatedModel().createDatatypeLiteral(literal,
159:                                datatypeURI)));
160:            }
161:
162:            /*
163:             * (non-Javadoc)
164:             * 
165:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#addStatement(java.lang.String,
166:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String)
167:             */
168:            @Override
169:            public void addStatement(String subjectURIString, URI predicate,
170:                    String literal) throws ModelRuntimeException {
171:                this .addStatement(getDelegatedModel().createStatement(
172:                        getDelegatedModel().createURI(subjectURIString),
173:                        predicate,
174:                        getDelegatedModel().createPlainLiteral(literal)));
175:            }
176:
177:            /////////////// remove
178:
179:            /*
180:             * (non-Javadoc)
181:             * 
182:             * @see org.ontoware.rdf2go.core.common.CommonModelWriter#removeAll(org.ontoware.rdf2go.core.common.CommonModelReader)
183:             */
184:            @Override
185:            public void removeAll(Iterator<? extends Statement> other)
186:                    throws ModelRuntimeException {
187:                while (other.hasNext()) {
188:                    this .removeStatement(other.next());
189:                }
190:            }
191:
192:            /*
193:             * (non-Javadoc)
194:             * 
195:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#removeStatement(org.ontoware.rdf2go.core.node.Resource,
196:             *      org.ontoware.rdf2go.core.node.URI,
197:             *      org.ontoware.rdf2go.core.node.Node)
198:             */
199:            @Override
200:            public void removeStatement(Resource subject, URI predicate,
201:                    Node object) throws ModelRuntimeException {
202:                this .removeStatement(getDelegatedModel().createStatement(
203:                        subject, predicate, object));
204:            }
205:
206:            /*
207:             * (non-Javadoc)
208:             * 
209:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#removeStatement(org.ontoware.rdf2go.core.node.Resource,
210:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
211:             *      java.lang.String)
212:             */
213:            @Override
214:            public void removeStatement(Resource subject, URI predicate,
215:                    String literal, String languageTag)
216:                    throws ModelRuntimeException {
217:                this .removeStatement(getDelegatedModel().createStatement(
218:                        subject,
219:                        predicate,
220:                        getDelegatedModel().createLanguageTagLiteral(literal,
221:                                languageTag)));
222:            }
223:
224:            /*
225:             * (non-Javadoc)
226:             * 
227:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#removeStatement(org.ontoware.rdf2go.core.node.Resource,
228:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
229:             *      org.ontoware.rdf2go.core.node.URI)
230:             */
231:            @Override
232:            public void removeStatement(Resource subject, URI predicate,
233:                    String literal, URI datatypeURI)
234:                    throws ModelRuntimeException {
235:                this .removeStatement(subject, predicate, getDelegatedModel()
236:                        .createDatatypeLiteral(literal, datatypeURI));
237:            }
238:
239:            /*
240:             * (non-Javadoc)
241:             * 
242:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#removeStatement(org.ontoware.rdf2go.core.node.Resource,
243:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String)
244:             */
245:            @Override
246:            public void removeStatement(Resource subject, URI predicate,
247:                    String literal) throws ModelRuntimeException {
248:                this .removeStatement(getDelegatedModel().createStatement(
249:                        subject, predicate,
250:                        getDelegatedModel().createPlainLiteral(literal)));
251:            }
252:
253:            /*
254:             * (non-Javadoc)
255:             * 
256:             * @see org.ontoware.rdf2go.core.common.CommonModelWriter#removeStatement(S)
257:             */
258:            @Override
259:            public void removeStatement(Statement statement)
260:                    throws ModelRuntimeException {
261:                for (ModelChangedListener listener : this .modelChangeListener
262:                        .keySet()) {
263:                    TriplePattern pattern = this .modelChangeListener
264:                            .get(listener);
265:                    if (pattern == null || pattern.matches(statement)) {
266:                        listener.removedStatement(statement);
267:                    }
268:                }
269:                getDelegatedModel().removeStatement(statement);
270:            }
271:
272:            /*
273:             * (non-Javadoc)
274:             * 
275:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#removeStatement(java.lang.String,
276:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
277:             *      java.lang.String)
278:             */
279:            @Override
280:            public void removeStatement(String subjectURIString, URI predicate,
281:                    String literal, String languageTag)
282:                    throws ModelRuntimeException {
283:                this .removeStatement(getDelegatedModel().createStatement(
284:                        getDelegatedModel().createURI(subjectURIString),
285:                        predicate,
286:                        getDelegatedModel().createLanguageTagLiteral(literal,
287:                                languageTag)));
288:            }
289:
290:            /*
291:             * (non-Javadoc)
292:             * 
293:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#removeStatement(java.lang.String,
294:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String,
295:             *      org.ontoware.rdf2go.core.node.URI)
296:             */
297:            @Override
298:            public void removeStatement(String subjectURIString, URI predicate,
299:                    String literal, URI datatypeURI)
300:                    throws ModelRuntimeException {
301:                this .removeStatement(getDelegatedModel().createStatement(
302:                        getDelegatedModel().createURI(subjectURIString),
303:                        predicate,
304:                        getDelegatedModel().createDatatypeLiteral(literal,
305:                                datatypeURI)));
306:            }
307:
308:            /*
309:             * (non-Javadoc)
310:             * 
311:             * @see org.ontoware.rdf2go.core.triple.ModelWriter#removeStatement(java.lang.String,
312:             *      org.ontoware.rdf2go.core.node.URI, java.lang.String)
313:             */
314:            @Override
315:            public void removeStatement(String subjectURIString, URI predicate,
316:                    String literal) throws ModelRuntimeException {
317:                this .removeStatement(getDelegatedModel().createStatement(
318:                        getDelegatedModel().createURI(subjectURIString),
319:                        predicate,
320:                        getDelegatedModel().createPlainLiteral(literal)));
321:            }
322:
323:            //////////// diff
324:
325:            @Override
326:            public void update(DiffReader diff) throws ModelRuntimeException {
327:                for (ModelChangedListener listener : this .modelChangeListener
328:                        .keySet()) {
329:                    listener.performedUpdate(diff);
330:                }
331:                getDelegatedModel().update(diff);
332:            }
333:
334:            // //////////////////////////////////
335:            // implement NotifyingModel
336:
337:            private Map<ModelChangedListener, TriplePattern> modelChangeListener = new HashMap<ModelChangedListener, TriplePattern>();
338:
339:            public void addModelChangedListener(ModelChangedListener listener,
340:                    TriplePattern pattern) {
341:                this .modelChangeListener.put(listener, pattern);
342:            }
343:
344:            public void addModelChangedListener(ModelChangedListener listener) {
345:                this .modelChangeListener.put(listener, null);
346:            }
347:
348:            public void removeModelChangedListener(ModelChangedListener listener) {
349:                this.modelChangeListener.remove(listener);
350:            }
351:
352:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.