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


001:        /******************************************************************
002:         * File:        TransitiveInfGraph.java
003:         * Created by:  Dave Reynolds
004:         * Created on:  02-Feb-03
005:         * 
006:         * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007:         * [See end of file]
008:         * $Id: TransitiveInfGraph.java,v 1.25 2008/01/02 12:07:50 andy_seaborne Exp $
009:         *****************************************************************/package com.hp.hpl.jena.reasoner.transitiveReasoner;
010:
011:        import com.hp.hpl.jena.reasoner.BaseInfGraph;
012:        import com.hp.hpl.jena.reasoner.*;
013:        import com.hp.hpl.jena.graph.*;
014:        import com.hp.hpl.jena.util.iterator.ExtendedIterator;
015:        import com.hp.hpl.jena.util.iterator.UniqueExtendedIterator;
016:
017:        /**
018:         * Implementation of InfGraph used by the TransitiveReasoner.
019:         * This is returned by the TransitiveReasoner when a data graph
020:         * (together with an optional schema) has been bound.
021:         * 
022:         * <p>The cached property and class graphs are calculated by the
023:         * reasoner when the schema is bound. If the data graph does not
024:         * include schema information then the caches generated at 
025:         * schema binding stage are reused here. Otherwise the caches
026:         * are regenerated.</p>
027:         * 
028:         * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
029:         * @version $Revision: 1.25 $ on $Date: 2008/01/02 12:07:50 $
030:         */
031:        public class TransitiveInfGraph extends BaseInfGraph {
032:
033:            /** The paire of subclass and subproperty lattices */
034:            protected TransitiveEngine transitiveEngine;
035:
036:            /** The graph registered as the schema, if any */
037:            protected Finder tbox = null;
038:
039:            /** The combined data and schema finder */
040:            protected Finder dataFind;
041:
042:            /**
043:             * Constructor. Called by the TransitiveReasoner when it
044:             * is bound to a data graph.
045:             * @param reasoner the parent instance of the transitive reasoner,
046:             * including any precomputed class and property caches
047:             * @param data the data graph being bound in.
048:             */
049:            public TransitiveInfGraph(Graph data, TransitiveReasoner reasoner) {
050:                super (data, reasoner);
051:            }
052:
053:            /**
054:             * Perform any initial processing and caching. This call is optional. Most
055:             * engines either have negligable set up work or will perform an implicit
056:             * "prepare" if necessary. The call is provided for those occasions where
057:             * substantial preparation work is possible (e.g. running a forward chaining
058:             * rule system) and where an application might wish greater control over when
059:             * this prepration is done.
060:             */
061:            public void prepare() {
062:                tbox = ((TransitiveReasoner) reasoner).getTbox();
063:                // Initially just point to the reasoner's precached information
064:                transitiveEngine = new TransitiveEngine(
065:                        ((TransitiveReasoner) reasoner).getSubClassCache()
066:                                .deepCopy(), ((TransitiveReasoner) reasoner)
067:                                .getSubPropertyCache().deepCopy());
068:                // The deepCopies reduce the value of precomputing the closure in the reasoner object
069:                // but enables people to bind the same reasoner to multiple datasets.
070:                // Perhaps need a faster deepcopy
071:
072:                // But need to check if the data graph defines schema data as well
073:                dataFind = transitiveEngine.insert(tbox, fdata);
074:                transitiveEngine.setCaching(true, true);
075:
076:                isPrepared = true;
077:            }
078:
079:            /**
080:             * Return the schema graph, if any, bound into this inference graph.
081:             */
082:            public Graph getSchemaGraph() {
083:                if (tbox == null)
084:                    return null;
085:                if (tbox instanceof  FGraph) {
086:                    return ((FGraph) tbox).getGraph();
087:                } else {
088:                    throw new ReasonerException(
089:                            "Transitive reasoner got into an illegal state");
090:                }
091:            }
092:
093:            /**
094:             * Extended find interface used in situations where the implementator
095:             * may or may not be able to answer the complete query. It will
096:             * attempt to answer the pattern but if its answers are not known
097:             * to be complete then it will also pass the request on to the nested
098:             * Finder to append more results.
099:             * @param pattern a TriplePattern to be matched against the data
100:             * @param continuation either a Finder or a normal Graph which
101:             * will be asked for additional match results if the implementor
102:             * may not have completely satisfied the query.
103:             */
104:            public ExtendedIterator findWithContinuation(TriplePattern pattern,
105:                    Finder continuation) {
106:                checkOpen();
107:                if (!isPrepared)
108:                    prepare();
109:                Finder cascade = transitiveEngine.getFinder(pattern, FinderUtil
110:                        .cascade(tbox, continuation));
111:                return new UniqueExtendedIterator(cascade.find(pattern));
112:            }
113:
114:            /** 
115:             * Returns an iterator over Triples.
116:             */
117:            public ExtendedIterator graphBaseFind(Node subject, Node property,
118:                    Node object) {
119:                return findWithContinuation(new TriplePattern(subject,
120:                        property, object), fdata);
121:            }
122:
123:            /**
124:             * Basic pattern lookup interface.
125:             * @param pattern a TriplePattern to be matched against the data
126:             * @return a ExtendedIterator over all Triples in the data set
127:             *  that match the pattern
128:             */
129:            public ExtendedIterator find(TriplePattern pattern) {
130:                return findWithContinuation(pattern, fdata);
131:            }
132:
133:            /**
134:             * Add one triple to the data graph, run any rules triggered by
135:             * the new data item, recursively adding any generated triples.
136:             */
137:            public synchronized void performAdd(Triple t) {
138:                if (!isPrepared)
139:                    prepare();
140:                fdata.getGraph().add(t);
141:                transitiveEngine.add(t);
142:            }
143:
144:            /** 
145:             * Removes the triple t (if possible) from the set belonging to this graph.
146:             */
147:            public void performDelete(Triple t) {
148:                fdata.getGraph().delete(t);
149:                if (isPrepared) {
150:                    transitiveEngine.delete(t);
151:                }
152:            }
153:
154:            /**
155:            Answer the InfCapabilities of this InfGraph.
156:             */
157:            public Capabilities getCapabilities() {
158:                if (capabilities == null)
159:                    capabilities = new InfFindSafeCapabilities();
160:                return capabilities;
161:            }
162:
163:        }
164:
165:        /*
166:         * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
167:         * All rights reserved.
168:         *
169:         * Redistribution and use in source and binary forms, with or without
170:         * modification, are permitted provided that the following conditions
171:         * are met:
172:         * 1. Redistributions of source code must retain the above copyright
173:         *    notice, this list of conditions and the following disclaimer.
174:         * 2. Redistributions in binary form must reproduce the above copyright
175:         *    notice, this list of conditions and the following disclaimer in the
176:         *    documentation and/or other materials provided with the distribution.
177:         * 3. The name of the author may not be used to endorse or promote products
178:         *    derived from this software without specific prior written permission.
179:         *
180:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
182:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
183:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
184:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
185:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
186:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
187:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
188:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
189:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
190:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.