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


001:        /******************************************************************
002:         * File:        RDFSRuleInfGraph.java
003:         * Created by:  Dave Reynolds
004:         * Created on:  22-Jun-2003
005:         * 
006:         * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007:         * [See end of file]
008:         * $Id: RDFSRuleInfGraph.java,v 1.9 2008/01/02 12:07:47 andy_seaborne Exp $
009:         *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys;
010:
011:        import com.hp.hpl.jena.reasoner.*;
012:        import com.hp.hpl.jena.graph.*;
013:        import com.hp.hpl.jena.graph.impl.LiteralLabel;
014:        import com.hp.hpl.jena.datatypes.*;
015:        import com.hp.hpl.jena.vocabulary.*;
016:
017:        import java.util.*;
018:
019:        /**
020:         * Customization of the generic rule inference graph for RDFS inference.
021:         * In fact all the rule processing is unchanged, the only extenstion is
022:         * the validation support.
023:         * 
024:         * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
025:         * @version $Revision: 1.9 $ on $Date: 2008/01/02 12:07:47 $
026:         */
027:        public class RDFSRuleInfGraph extends FBRuleInfGraph {
028:
029:            /** Optional map of property node to datatype ranges */
030:            protected HashMap dtRange = null;
031:
032:            /**
033:             * Constructor.
034:             * @param reasoner the reasoner which created this inf graph instance
035:             * @param rules the rules to process
036:             * @param schema the (optional) schema graph to be included
037:             */
038:            public RDFSRuleInfGraph(Reasoner reasoner, List rules, Graph schema) {
039:                super (reasoner, rules, schema);
040:            }
041:
042:            /**
043:             * Constructor.
044:             * @param reasoner the reasoner which created this inf graph instance
045:             * @param rules the rules to process
046:             * @param schema the (optional) schema graph to be included
047:             * @param data the data graph to be processed
048:             */
049:            public RDFSRuleInfGraph(Reasoner reasoner, List rules,
050:                    Graph schema, Graph data) {
051:                super (reasoner, rules, schema, data);
052:            }
053:
054:            /**
055:             * Test the consistency of the bound data. For RDFS this checks that all
056:             * instances of datatype-ranged properties have correct data values.
057:             * 
058:             * @return a ValidityReport structure
059:             */
060:            public ValidityReport validate() {
061:                // The full configuration uses validation rules so check for these
062:                StandardValidityReport report = (StandardValidityReport) super 
063:                        .validate();
064:                // Also do a hardwired check to handle the simpler configurations
065:                HashMap dtRange = getDTRange();
066:                for (Iterator props = dtRange.keySet().iterator(); props
067:                        .hasNext();) {
068:                    Node prop = (Node) props.next();
069:                    for (Iterator i = find(null, prop, null); i.hasNext();) {
070:                        Triple triple = (Triple) i.next();
071:                        report.add(checkLiteral(prop, triple.getObject()));
072:                    }
073:                }
074:                return report;
075:            }
076:
077:            /**
078:             * Check a given literal value for a property against the set of
079:             * known range constraints for it.
080:             * @param prop the property node whose range is under scrutiny
081:             * @param value the literal node whose value is to be checked
082:             * @return null if the range is legal, otherwise a ValidityReport.Report
083:             * which describes the problem.
084:             */
085:            public ValidityReport.Report checkLiteral(Node prop, Node value) {
086:                List range = (List) getDTRange().get(prop);
087:                if (range != null) {
088:                    if (value.isBlank())
089:                        return null;
090:                    if (!value.isLiteral()) {
091:                        return new ValidityReport.Report(
092:                                true,
093:                                "dtRange",
094:                                "Property "
095:                                        + prop
096:                                        + " has a typed range but was given a non literal value "
097:                                        + value);
098:                    }
099:                    LiteralLabel ll = value.getLiteral();
100:                    for (Iterator i = range.iterator(); i.hasNext();) {
101:                        RDFDatatype dt = (RDFDatatype) i.next();
102:                        if (!dt.isValidLiteral(ll)) {
103:                            return new ValidityReport.Report(true, "dtRange",
104:                                    "Property " + prop + " has a typed range "
105:                                            + dt
106:                                            + "that is not compatible with "
107:                                            + value);
108:                        }
109:                    }
110:                }
111:                return null;
112:            }
113:
114:            /**
115:             * Return a map from property nodes to a list of RDFDatatype objects
116:             * which have been declared as the range of that property.
117:             */
118:            private HashMap getDTRange() {
119:                if (dtRange == null) {
120:                    dtRange = new HashMap();
121:                    for (Iterator i = find(null, RDFS.range.asNode(), null); i
122:                            .hasNext();) {
123:                        Triple triple = (Triple) i.next();
124:                        Node prop = triple.getSubject();
125:                        Node rangeValue = triple.getObject();
126:                        if (rangeValue.isURI()) {
127:                            RDFDatatype dt = TypeMapper.getInstance()
128:                                    .getTypeByName(rangeValue.getURI());
129:                            if (dt != null) {
130:                                List range = (ArrayList) dtRange.get(prop);
131:                                if (range == null) {
132:                                    range = new ArrayList();
133:                                    dtRange.put(prop, range);
134:                                }
135:                                range.add(dt);
136:                            }
137:                        }
138:                    }
139:                }
140:                return dtRange;
141:            }
142:
143:        }
144:
145:        /*
146:         (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
147:         All rights reserved.
148:
149:         Redistribution and use in source and binary forms, with or without
150:         modification, are permitted provided that the following conditions
151:         are met:
152:
153:         1. Redistributions of source code must retain the above copyright
154:         notice, this list of conditions and the following disclaimer.
155:
156:         2. Redistributions in binary form must reproduce the above copyright
157:         notice, this list of conditions and the following disclaimer in the
158:         documentation and/or other materials provided with the distribution.
159:
160:         3. The name of the author may not be used to endorse or promote products
161:         derived from this software without specific prior written permission.
162:
163:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
164:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
165:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
166:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
167:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
168:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
169:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
170:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
171:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
172:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
173:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.