Source Code Cross Referenced for TriplePatternImpl.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:        /*
002:         * LICENSE INFORMATION
003:         * Copyright 2005-2007 by FZI (http://www.fzi.de).
004:         * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
005:         * <OWNER> = Max Völkel
006:         * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
007:         * <YEAR> = 2007
008:         * 
009:         * Project information at http://semweb4j.org/rdf2go
010:         */
011:        package org.ontoware.rdf2go.model.impl;
012:
013:        import org.ontoware.rdf2go.model.Statement;
014:        import org.ontoware.rdf2go.model.TriplePattern;
015:        import org.ontoware.rdf2go.model.node.Node;
016:        import org.ontoware.rdf2go.model.node.NodeOrVariable;
017:        import org.ontoware.rdf2go.model.node.Resource;
018:        import org.ontoware.rdf2go.model.node.ResourceOrVariable;
019:        import org.ontoware.rdf2go.model.node.URI;
020:        import org.ontoware.rdf2go.model.node.UriOrVariable;
021:        import org.ontoware.rdf2go.model.node.Variable;
022:        import org.ontoware.rdf2go.model.node.impl.PlainLiteralImpl;
023:
024:        /**
025:         * A statement with variables
026:         * 
027:         * @author voelkel
028:         * 
029:         */
030:        public class TriplePatternImpl implements  TriplePattern {
031:
032:            public enum SPO {
033:                SUBJECT, PREDICATE, OBJECT
034:            }
035:
036:            private ResourceOrVariable subject;
037:
038:            private UriOrVariable predicate;
039:
040:            private NodeOrVariable object;
041:
042:            public SPO extract;
043:
044:            public TriplePatternImpl(ResourceOrVariable subject,
045:                    UriOrVariable predicate, NodeOrVariable object) {
046:                this .subject = subject;
047:                this .predicate = predicate;
048:                this .object = object;
049:            }
050:
051:            public TriplePatternImpl(ResourceOrVariable subject,
052:                    UriOrVariable predicate, NodeOrVariable object, SPO extract) {
053:                this .subject = subject;
054:                this .predicate = predicate;
055:                this .object = object;
056:                this .extract = extract;
057:            }
058:
059:            /**
060:             * Convenience constructor
061:             * 
062:             * @param subject
063:             * @param predicate
064:             * @param object
065:             */
066:            public TriplePatternImpl(ResourceOrVariable subject, URI predicate,
067:                    String object) {
068:                this .subject = subject;
069:                this .predicate = predicate;
070:                this .object = new PlainLiteralImpl(object);
071:            }
072:
073:            public NodeOrVariable getObject() {
074:                return this .object;
075:            }
076:
077:            public UriOrVariable getPredicate() {
078:                return this .predicate;
079:            }
080:
081:            public ResourceOrVariable getSubject() {
082:                return this .subject;
083:            }
084:
085:            /**
086:             * @param statement
087:             *            an RDF2Go statement
088:             * @return the part of the statement which should be extracted according to
089:             *         this pattern
090:             */
091:            public Node getExtract(Statement statement) {
092:                switch (this .extract) {
093:                case SUBJECT:
094:                    return statement.getSubject();
095:                case PREDICATE:
096:                    return statement.getPredicate();
097:                case OBJECT:
098:                    return statement.getObject();
099:                default: {
100:                    assert false;
101:                    throw new RuntimeException();
102:                }
103:                }
104:            }
105:
106:            @Override
107:            public boolean equals(Object o) {
108:                return ((o instanceof  Statement)
109:                        && (this .getSubject().equals(((Statement) o)
110:                                .getSubject()))
111:                        && (this .getPredicate().equals(((Statement) o)
112:                                .getPredicate())) && (this .getObject()
113:                        .equals(((Statement) o).getObject())));
114:            }
115:
116:            @Override
117:            public int hashCode() {
118:                return this .object.hashCode() + this .predicate.hashCode()
119:                        + this .object.hashCode();
120:            }
121:
122:            public static TriplePatternImpl createObjectPattern(
123:                    Resource resource, URI propertyURI) {
124:                return new TriplePatternImpl(resource, propertyURI,
125:                        Variable.ANY, SPO.OBJECT);
126:            }
127:
128:            public static TriplePatternImpl createSubjectPattern(
129:                    URI propertyURI, Node objectNode) {
130:                return new TriplePatternImpl(Variable.ANY, propertyURI,
131:                        objectNode, SPO.SUBJECT);
132:            }
133:
134:            public boolean matches(Statement statement) {
135:                boolean matchesSubject = statement.getSubject().equals(
136:                        this .getSubject())
137:                        || this .getSubject() instanceof  Variable;
138:
139:                boolean matchesPredicate = statement.getPredicate().equals(
140:                        this .getPredicate())
141:                        || this .getPredicate() instanceof  Variable;
142:
143:                boolean matchesObject = statement.getObject().equals(
144:                        this .getObject())
145:                        || this .getObject() instanceof  Variable;
146:
147:                return matchesSubject && matchesPredicate && matchesObject;
148:            }
149:
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.