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


001:        /*
002:         * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
003:         *
004:         * Licensed under the Aduna BSD-style license.
005:         */
006:        package org.openrdf.query.algebra;
007:
008:        import java.util.HashSet;
009:        import java.util.Set;
010:
011:        /**
012:         * A tuple expression that matches a statement pattern against an RDF graph.
013:         * Statement patterns can be targeted at one of three context scopes: all
014:         * contexts, null context only, or named contexts only.
015:         */
016:        public class StatementPattern extends QueryModelNodeBase implements 
017:                TupleExpr {
018:
019:            /*------------*
020:             * enum Scope *
021:             *------------*/
022:
023:            /**
024:             * Indicates the scope of the statement pattern.
025:             */
026:            public enum Scope {
027:                /**
028:                 * Scope for patterns that should be matched against statements from the
029:                 * default contexts.
030:                 */
031:                DEFAULT_CONTEXTS,
032:
033:                /**
034:                 * Scope for patterns that should be matched against statements from named
035:                 * contexts only.
036:                 */
037:                NAMED_CONTEXTS
038:            }
039:
040:            /*-----------*
041:             * Variables *
042:             *-----------*/
043:
044:            private Scope scope;
045:
046:            private Var subjectVar;
047:
048:            private Var predicateVar;
049:
050:            private Var objectVar;
051:
052:            private Var contextVar;
053:
054:            /*--------------*
055:             * Constructors *
056:             *--------------*/
057:
058:            public StatementPattern() {
059:            }
060:
061:            /**
062:             * Creates a statement pattern that matches a subject-, predicate- and object
063:             * variable against statements from all contexts.
064:             */
065:            public StatementPattern(Var subject, Var predicate, Var object) {
066:                this (Scope.DEFAULT_CONTEXTS, subject, predicate, object);
067:            }
068:
069:            /**
070:             * Creates a statement pattern that matches a subject-, predicate- and object
071:             * variable against statements from the specified context scope.
072:             */
073:            public StatementPattern(Scope scope, Var subject, Var predicate,
074:                    Var object) {
075:                this (scope, subject, predicate, object, null);
076:            }
077:
078:            /**
079:             * Creates a statement pattern that matches a subject-, predicate-, object-
080:             * and context variable against statements from all contexts.
081:             */
082:            public StatementPattern(Var subject, Var predicate, Var object,
083:                    Var context) {
084:                this (Scope.DEFAULT_CONTEXTS, subject, predicate, object,
085:                        context);
086:            }
087:
088:            /**
089:             * Creates a statement pattern that matches a subject-, predicate-, object-
090:             * and context variable against statements from the specified context scope.
091:             */
092:            public StatementPattern(Scope scope, Var subjVar, Var predVar,
093:                    Var objVar, Var conVar) {
094:                setScope(scope);
095:                setSubjectVar(subjVar);
096:                setPredicateVar(predVar);
097:                setObjectVar(objVar);
098:                setContextVar(conVar);
099:            }
100:
101:            /*---------*
102:             * Methods *
103:             *---------*/
104:
105:            /**
106:             * Gets the context scope for the statement pattern.
107:             */
108:            public Scope getScope() {
109:                return scope;
110:            }
111:
112:            /**
113:             * Sets the context scope for the statement pattern.
114:             */
115:            public void setScope(Scope scope) {
116:                assert scope != null : "scope must not be null";
117:                this .scope = scope;
118:            }
119:
120:            public Var getSubjectVar() {
121:                return subjectVar;
122:            }
123:
124:            public void setSubjectVar(Var subject) {
125:                assert subject != null : "subject must not be null";
126:                subject.setParentNode(this );
127:                subjectVar = subject;
128:            }
129:
130:            public Var getPredicateVar() {
131:                return predicateVar;
132:            }
133:
134:            public void setPredicateVar(Var predicate) {
135:                assert predicate != null : "predicate must not be null";
136:                predicate.setParentNode(this );
137:                predicateVar = predicate;
138:            }
139:
140:            public Var getObjectVar() {
141:                return objectVar;
142:            }
143:
144:            public void setObjectVar(Var object) {
145:                assert object != null : "object must not be null";
146:                object.setParentNode(this );
147:                objectVar = object;
148:            }
149:
150:            /**
151:             * Returns the context variable, if available.
152:             * 
153:             * @return
154:             */
155:            public Var getContextVar() {
156:                return contextVar;
157:            }
158:
159:            public void setContextVar(Var context) {
160:                if (context != null) {
161:                    context.setParentNode(this );
162:                }
163:                contextVar = context;
164:            }
165:
166:            public Set<String> getBindingNames() {
167:                Set<String> bindingNames = new HashSet<String>(8);
168:
169:                if (subjectVar != null) {
170:                    bindingNames.add(subjectVar.getName());
171:                }
172:                if (predicateVar != null) {
173:                    bindingNames.add(predicateVar.getName());
174:                }
175:                if (objectVar != null) {
176:                    bindingNames.add(objectVar.getName());
177:                }
178:                if (contextVar != null) {
179:                    bindingNames.add(contextVar.getName());
180:                }
181:
182:                return bindingNames;
183:            }
184:
185:            public <X extends Exception> void visit(QueryModelVisitor<X> visitor)
186:                    throws X {
187:                visitor.meet(this );
188:            }
189:
190:            @Override
191:            public <X extends Exception> void visitChildren(
192:                    QueryModelVisitor<X> visitor) throws X {
193:                if (subjectVar != null) {
194:                    subjectVar.visit(visitor);
195:                }
196:                if (predicateVar != null) {
197:                    predicateVar.visit(visitor);
198:                }
199:                if (objectVar != null) {
200:                    objectVar.visit(visitor);
201:                }
202:                if (contextVar != null) {
203:                    contextVar.visit(visitor);
204:                }
205:
206:                super .visitChildren(visitor);
207:            }
208:
209:            @Override
210:            public void replaceChildNode(QueryModelNode current,
211:                    QueryModelNode replacement) {
212:                if (subjectVar == current) {
213:                    setSubjectVar((Var) replacement);
214:                } else if (predicateVar == current) {
215:                    setPredicateVar((Var) replacement);
216:                } else if (objectVar == current) {
217:                    setObjectVar((Var) replacement);
218:                } else if (contextVar == current) {
219:                    setContextVar((Var) replacement);
220:                } else {
221:                    super .replaceChildNode(current, replacement);
222:                }
223:            }
224:
225:            @Override
226:            public String getSignature() {
227:                StringBuilder sb = new StringBuilder(128);
228:
229:                sb.append(super .getSignature());
230:
231:                if (scope == Scope.NAMED_CONTEXTS) {
232:                    sb.append(" FROM NAMED CONTEXT");
233:                }
234:
235:                return sb.toString();
236:            }
237:
238:            @Override
239:            public StatementPattern clone() {
240:                StatementPattern clone = (StatementPattern) super.clone();
241:                clone.setSubjectVar(getSubjectVar().clone());
242:                clone.setPredicateVar(getPredicateVar().clone());
243:                clone.setObjectVar(getObjectVar().clone());
244:
245:                if (getContextVar() != null) {
246:                    clone.setContextVar(getContextVar().clone());
247:                }
248:
249:                return clone;
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.