Source Code Cross Referenced for PatternStageCompiler.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » graph » query » 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 » Jena 2.5.5 » com.hp.hpl.jena.graph.query 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:          [See end of file]
004:          $Id: PatternStageCompiler.java,v 1.10 2008/01/02 12:07:58 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.graph.query;
008:
009:        import com.hp.hpl.jena.graph.*;
010:
011:        /**
012:         PatternStageCompiler serves two purposes: it contains the standard algorithm
013:         for compiling patterns-as-triples to patterns-as-Pattern(s), and it has the
014:         standard implementation of PatternCompiler in terms of ordinary Elements.
015:        
016:         @author kers
017:         */
018:        public final class PatternStageCompiler implements  PatternCompiler {
019:            /** no state, so the constructor is boring.
020:             */
021:            public PatternStageCompiler() {
022:            }
023:
024:            /**
025:                to compile an array of triples, compile each triple and form the corresponding
026:                array of Patterns. *preserve the order*. 
027:             */
028:            public static Pattern[] compile(PatternCompiler compiler,
029:                    Mapping map, Triple[] source) {
030:                Pattern[] compiled = new Pattern[source.length];
031:                for (int i = 0; i < source.length; i += 1)
032:                    compiled[i] = compile(compiler, source[i], map);
033:                return compiled;
034:            }
035:
036:            /**
037:                to compile a triple, compile each node and form a Pattern  from the resulting Elements.
038:             */
039:            private static Pattern compile(PatternCompiler compiler, Triple t,
040:                    Mapping map) {
041:                Node S = t.getSubject(), P = t.getPredicate(), O = t
042:                        .getObject();
043:                return new Pattern(compile(compiler, S, map), compile(compiler,
044:                        P, map), compile(compiler, O, map));
045:            }
046:
047:            /**
048:                to compile a Node, special-case variables and ANYs. Surely this code is
049:                better in Node, but I really don't like exporting so much query information
050:                into the Node data-type. Hmm. Perhaps some node types are better off in
051:                the .query package.
052:             */
053:            private static Element compile(PatternCompiler compiler, Node X,
054:                    Mapping map) {
055:                if (X.equals(Query.ANY))
056:                    return compiler.any();
057:                if (X.isVariable()) {
058:                    if (map.hasBound(X))
059:                        return compiler.bound(X, map.indexOf(X));
060:                    else
061:                        return compiler.bind(X, map.newIndex(X));
062:                }
063:                return compiler.fixed(X);
064:            }
065:
066:            /*
067:                satisfy the interface
068:             */
069:            public Element fixed(Node value) {
070:                return new Fixed(value);
071:            }
072:
073:            public Element bound(Node n, int index) {
074:                return new Bound(index);
075:            }
076:
077:            public Element bind(Node n, int index) {
078:                return new Bind(index);
079:            }
080:
081:            public Element any() {
082:                return Element.ANY;
083:            }
084:        }
085:        /*
086:         (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
087:         All rights reserved.
088:
089:         Redistribution and use in source and binary forms, with or without
090:         modification, are permitted provided that the following conditions
091:         are met:
092:
093:         1. Redistributions of source code must retain the above copyright
094:         notice, this list of conditions and the following disclaimer.
095:
096:         2. Redistributions in binary form must reproduce the above copyright
097:         notice, this list of conditions and the following disclaimer in the
098:         documentation and/or other materials provided with the distribution.
099:
100:         3. The name of the author may not be used to endorse or promote products
101:         derived from this software without specific prior written permission.
102:
103:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
104:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
105:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
106:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
107:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
108:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
109:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
110:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
112:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.