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


001:        /*
002:         * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
003:         *
004:         * Licensed under the Aduna BSD-style license.
005:         */
006:        package org.openrdf.sail.rdbms.algebra.factories;
007:
008:        import static org.openrdf.sail.rdbms.algebra.base.SqlExprSupport.and;
009:        import static org.openrdf.sail.rdbms.algebra.base.SqlExprSupport.coalesce;
010:        import static org.openrdf.sail.rdbms.algebra.base.SqlExprSupport.isNotNull;
011:        import static org.openrdf.sail.rdbms.algebra.base.SqlExprSupport.isNull;
012:        import static org.openrdf.sail.rdbms.algebra.base.SqlExprSupport.sqlNull;
013:        import static org.openrdf.sail.rdbms.algebra.base.SqlExprSupport.str;
014:        import static org.openrdf.sail.rdbms.algebra.base.SqlExprSupport.unsupported;
015:
016:        import org.openrdf.model.URI;
017:        import org.openrdf.model.Value;
018:        import org.openrdf.model.vocabulary.XMLSchema;
019:        import org.openrdf.query.algebra.Datatype;
020:        import org.openrdf.query.algebra.Lang;
021:        import org.openrdf.query.algebra.MathExpr;
022:        import org.openrdf.query.algebra.QueryModelNode;
023:        import org.openrdf.query.algebra.Str;
024:        import org.openrdf.query.algebra.ValueConstant;
025:        import org.openrdf.query.algebra.ValueExpr;
026:        import org.openrdf.query.algebra.Var;
027:        import org.openrdf.query.algebra.helpers.QueryModelVisitorBase;
028:        import org.openrdf.sail.rdbms.algebra.LongURIColumn;
029:        import org.openrdf.sail.rdbms.algebra.SqlCase;
030:        import org.openrdf.sail.rdbms.algebra.SqlNull;
031:        import org.openrdf.sail.rdbms.algebra.URIColumn;
032:        import org.openrdf.sail.rdbms.algebra.base.SqlExpr;
033:        import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException;
034:
035:        /**
036:         * Creates an SQL expression for a URI's string value.
037:         * 
038:         * @author James Leigh
039:         * 
040:         */
041:        public class URIExprFactory extends
042:                QueryModelVisitorBase<UnsupportedRdbmsOperatorException> {
043:            protected SqlExpr result;
044:            private SqlExprFactory sql;
045:
046:            public void setSqlExprFactory(SqlExprFactory sql) {
047:                this .sql = sql;
048:            }
049:
050:            public SqlExpr createUriExpr(ValueExpr expr)
051:                    throws UnsupportedRdbmsOperatorException {
052:                result = null;
053:                if (expr == null)
054:                    return new SqlNull();
055:                expr.visit(this );
056:                if (result == null)
057:                    return new SqlNull();
058:                return result;
059:            }
060:
061:            @Override
062:            public void meet(Datatype node)
063:                    throws UnsupportedRdbmsOperatorException {
064:                SqlCase sqlCase = new SqlCase();
065:                sqlCase.when(isNotNull(type(node.getArg())),
066:                        type(node.getArg()));
067:                sqlCase.when(and(isNull(lang(node.getArg())),
068:                        isNotNull(label(node.getArg()))), str(XMLSchema.STRING
069:                        .stringValue()));
070:                result = sqlCase;
071:            }
072:
073:            @Override
074:            public void meet(Lang node)
075:                    throws UnsupportedRdbmsOperatorException {
076:                result = sqlNull();
077:            }
078:
079:            @Override
080:            public void meet(MathExpr node)
081:                    throws UnsupportedRdbmsOperatorException {
082:                result = sqlNull();
083:            }
084:
085:            @Override
086:            public void meet(Str node) {
087:                result = sqlNull();
088:            }
089:
090:            @Override
091:            public void meet(ValueConstant vc) {
092:                result = valueOf(vc.getValue());
093:            }
094:
095:            @Override
096:            public void meet(Var var) {
097:                if (var.getValue() == null) {
098:                    result = coalesce(new URIColumn(var),
099:                            new LongURIColumn(var));
100:                } else {
101:                    result = valueOf(var.getValue());
102:                }
103:            }
104:
105:            @Override
106:            protected void meetNode(QueryModelNode arg)
107:                    throws UnsupportedRdbmsOperatorException {
108:                throw unsupported(arg);
109:            }
110:
111:            private SqlExpr label(ValueExpr arg)
112:                    throws UnsupportedRdbmsOperatorException {
113:                return sql.createLabelExpr(arg);
114:            }
115:
116:            private SqlExpr lang(ValueExpr arg)
117:                    throws UnsupportedRdbmsOperatorException {
118:                return sql.createLanguageExpr(arg);
119:            }
120:
121:            private SqlExpr type(ValueExpr arg)
122:                    throws UnsupportedRdbmsOperatorException {
123:                return sql.createDatatypeExpr(arg);
124:            }
125:
126:            private SqlExpr valueOf(Value value) {
127:                if (value instanceof  URI) {
128:                    return str(((URI) value).stringValue());
129:                }
130:                return sqlNull();
131:            }
132:
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.