Source Code Cross Referenced for RuleML0_8Driver.java in  » Rule-Engine » Mandarax » org » mandarax » xkb » ruleml » 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 » Rule Engine » Mandarax » org.mandarax.xkb.ruleml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:        package org.mandarax.xkb.ruleml;
019:
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import org.jdom.Element;
024:        import org.mandarax.kernel.ClauseSet;
025:        import org.mandarax.kernel.Fact;
026:        import org.mandarax.kernel.KnowledgeBase;
027:        import org.mandarax.kernel.Rule;
028:        import org.mandarax.reference.AdvancedKnowledgeBase;
029:        import org.mandarax.xkb.XKBException;
030:
031:        /**
032:         * Driver implementation for the RULE ML version 0.8.
033:         * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
034:         * @version 3.4 <7 March 05>
035:         * @since 1.9
036:         */
037:        public class RuleML0_8Driver extends AbstractRuleMLDriver {
038:
039:            /**
040:             * Constructor.
041:             */
042:            public RuleML0_8Driver() {
043:                super ();
044:            }
045:
046:            /**
047:             * Export a knowledge base, e.g. convert it into an xml element.
048:             * @return an element (of the jdom tree)
049:             * @param kb a knowledge base
050:             */
051:            protected Element export(KnowledgeBase kb) {
052:                Element e = new Element(RULEBASE);
053:                List clauseSets = kb.getClauseSets();
054:                ClauseSet nextClauseSet = null;
055:                // export clause sets
056:                for (Iterator it = clauseSets.iterator(); it.hasNext();) {
057:                    nextClauseSet = (ClauseSet) it.next();
058:                    if (nextClauseSet instanceof  Fact)
059:                        e.addContent(export((Fact) nextClauseSet));
060:                    else if (nextClauseSet instanceof  Rule)
061:                        e.addContent(export((Rule) nextClauseSet));
062:                    else
063:                        LOG_XKB
064:                                .warn("Only facts and rules are suported by driver "
065:                                        + getName()
066:                                        + ", cannot export "
067:                                        + nextClauseSet);
068:                }
069:                return e;
070:            }
071:
072:            /**
073:             * Get a short text describing the driver.
074:             * @return a text
075:             */
076:            public String getDescription() {
077:                return "Driver for rulebases as specified by the RULE ML version 0.8 specification";
078:            }
079:
080:            /**
081:             * Get the location (URL) of the associated DTD.
082:             * @return a text
083:             */
084:            public String getDTD() {
085:                return "http://www.dfki.uni-kl.de/ruleml/dtd/0.8/ruleml-datalog-monolith.dtd";
086:            }
087:
088:            /**
089:             * Get the name of the driver.
090:             * @return a text
091:             */
092:            public String getName() {
093:                return "RuleML 0.8";
094:            }
095:
096:            /**
097:             * Import a knowledge base.
098:             * @return a knowledge base
099:             * @param e an xml element
100:             * @throws an XKBException is thrown if import fails
101:             */
102:            protected KnowledgeBase importKnowledgeBase(Element e)
103:                    throws XKBException {
104:
105:                // since we have no chance to store the class name in this xml format,
106:                // we choose the default class
107:                KnowledgeBase kb = new AdvancedKnowledgeBase();
108:
109:                // build the clause sets
110:                List all = e.getChildren();
111:                Element next = null;
112:                ClauseSet nextCS = null;
113:
114:                for (Iterator it = all.iterator(); it.hasNext();) {
115:                    next = (Element) it.next();
116:                    if (compare(next.getName(), IMP))
117:                        kb.add(importRule(next));
118:                    else if (compare(next.getName(), FACT))
119:                        kb.add(importFact(next));
120:                    else
121:                        LOG_XKB.warn("Cannot import element <" + next.getName()
122:                                + "> - driver " + getName()
123:                                + " does not support this tag");
124:                }
125:                return kb;
126:            }
127:
128:            /**
129:             * Indicates whether the driver (and the underlying xml format (=dtd))
130:             * supports auto facts.
131:             * @return a boolean
132:             */
133:            public boolean supportsAutoFacts() {
134:                return false;
135:            }
136:
137:            /**
138:             * Indicates whether the driver (and the underlying xml format (=dtd))
139:             * supports clause sets.
140:             * @return a boolean
141:             */
142:            public boolean supportsClauseSets() {
143:                return false;
144:            }
145:
146:            /**
147:             * Indicates whether the driver (and the underlying xml format (=dtd))
148:             * supports facts. (some formats might see facts as rules without body)
149:             * @return a boolean
150:             */
151:            public boolean supportsFacts() {
152:                return true;
153:            }
154:
155:            /**
156:             * Indicates whether the driver (and the underlying xml format (=dtd))
157:             * supports functions.
158:             * @return a boolean
159:             */
160:            public boolean supportsFunctions() {
161:                return false;
162:            }
163:
164:            /**
165:             * Indicates whether the driver (and the underlying xml format (=dtd))
166:             * supports the java semantics (e.g. JFunctions, JPredicate).
167:             * @return a boolean
168:             */
169:            public boolean supportsJavaSemantics() {
170:                return false;
171:            }
172:
173:            /**
174:             * Indicates whether the driver (and the underlying xml format (=dtd))
175:             * supports multiple premises.
176:             * @return a boolean
177:             */
178:            public boolean supportsMultiplePremises() {
179:                return true;
180:            }
181:
182:            /**
183:             * Indicates whether the driver (and the underlying xml format (=dtd))
184:             * supports multiple premises connected by OR.
185:             * @return a boolean
186:             */
187:            public boolean supportsOrPremises() {
188:                return false;
189:            }
190:
191:            /**
192:             * Indicates whether the driver (and the underlying xml format (=dtd))
193:             * supports types.
194:             * @return a boolean
195:             */
196:            public boolean supportsTypes() {
197:                return false;
198:            }
199:
200:            /**
201:             * Indicates whether the driver (and the underlying xml format (=dtd))
202:             * supports queries.
203:             * @return a boolean
204:             */
205:            public boolean supportsQueries() {
206:                return false;
207:            }
208:
209:            /**
210:             * Indicates whether the driver (and the underlying xml format (=dtd))
211:             * supports negation as failure.
212:             * @return a boolean
213:             */
214:            public boolean supportsNegationAsFailure() {
215:                return false;
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.