Source Code Cross Referenced for LogicFactory.java in  » Rule-Engine » Mandarax » org » mandarax » kernel » 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.kernel 
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.kernel;
019:
020:        import org.mandarax.kernel.validation.TestCase;
021:        import java.util.*;
022:
023:        /**
024:         * Abstract factory object for creating logical entities such as rules, facts and terms.
025:         * The implementing classes should never be instanciated
026:         * directly. Instead use instances of this class to create them.
027:         * Support for obtaining a reference to a default logic factory is provided -
028:         * use the static method <code>getDefaultFactory()</code> to obtain a reference.
029:         * Note that be default we try to initialize the default factory with an instance of
030:         * the subclass <code>org.mandarax.reference.DefaultLogicFactory</code>. The respective
031:         * refernce is obtained using <code>Class.forName()</code> so that this package does
032:         * only have a weak dependency to the <code>org.mandarax.reference</code> package.
033:         * <br>
034:         * As from 1.9, queries are supported.
035:         * @see org.mandarax.reference.DefaultLogicFactory
036:         * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
037:         * @version 3.4 <7 March 05>
038:         * @since 1.1
039:         */
040:        public abstract class LogicFactory extends LObject {
041:
042:            private static LogicFactory defaultFactory = null;
043:
044:            /**
045:             * Constructor.
046:             */
047:            public LogicFactory() {
048:                super ();
049:            }
050:
051:            /**
052:             * Create a new complex term.
053:             * @return a new complex term
054:             * @param aFunction a function
055:             * @param terms an array of terms
056:             */
057:            public abstract ComplexTerm createComplexTerm(Function aFunction,
058:                    Term[] terms);
059:
060:            /**
061:             * Create a new constant term.
062:             * @return a new constant term
063:             * @param obj the wrapped object
064:             */
065:            public abstract ConstantTerm createConstantTerm(Object obj);
066:
067:            /**
068:             * Create a new constant term.
069:             * @return a new constant term
070:             * @param obj the wrapped object
071:             * @param type the type of the object
072:             * @throws throws an IllegalArgumentException if object and type are inconsistent,
073:             * i.e. if type object is not an instance of type
074:             */
075:            public abstract ConstantTerm createConstantTerm(Object obj,
076:                    Class type);
077:
078:            /**
079:             * Create a new query.
080:             * @return a new query
081:             * @param fact aFact
082:             * @param name the name of the query
083:             */
084:            public abstract Query createQuery(Fact fact, String name);
085:
086:            /**
087:             * Create a new query.
088:             * @return a new query
089:             * @param facts an array of facts
090:             * @param name the name of the query
091:             */
092:            public abstract Query createQuery(Fact[] facts, String name);
093:
094:            /**
095:             * Create a new fact.
096:             * @return a new fact
097:             * @param aPredicate a predicate
098:             * @param terms an array of terms
099:             */
100:            public abstract Fact createFact(Predicate aPredicate, Term[] terms);
101:
102:            /**
103:             * Create a new prerequisite.
104:             * @return a new prerequisite
105:             * @param aPredicate a predicate
106:             * @param terms an array of terms
107:             * @param negatedAF whether the prerequisite is negated (as failure)
108:             */
109:            public abstract Prerequisite createPrerequisite(
110:                    Predicate aPredicate, Term[] terms, boolean negatedAF);
111:
112:            /**
113:             * Create a cut prerequisite.
114:             * @return a prerequisite
115:             */
116:            public abstract Prerequisite createCut();
117:
118:            /**
119:             * Create a new rule.
120:             * @return a new rule
121:             * @param body a list of prerequisites
122:             * @param head the head of the rule
123:             */
124:            public abstract Rule createRule(java.util.List body, Fact head);
125:
126:            /**
127:             * Create a new rule.
128:             * @return a new rule
129:             * @param body a list of prerequisites
130:             * @param head the head of the rule
131:             * @param or indicates whether the prerequisites are connected by OR
132:             */
133:            public abstract Rule createRule(java.util.List body, Fact head,
134:                    boolean or);
135:
136:            /**
137:             * Create a new rule with an empty body.
138:             * @return a new rule
139:             * @param head a fact that becomes the head of the created rule
140:             */
141:            public Rule createRule(Fact head) {
142:                return createRule(new java.util.ArrayList(), head);
143:            }
144:
145:            /**
146:             * Create a new variable term.
147:             * @return a new variable term
148:             * @param aName the name of the term
149:             * @param aType the type of the term
150:             */
151:            public abstract VariableTerm createVariableTerm(String aName,
152:                    Class aType);
153:
154:            /**
155:             * Create a new test case.
156:             * @return a new test case
157:             * @param aQuery a <strong>ground</strong> query
158:             * @param assumptions some assumptions
159:             * @param policyToAddAssumptionsToKB one of the integers in TestCase (TestCase.ON_TOP, TestCase.AT_BOTTOM)
160:             * @param expectedResult true or false
161:             * @see org.mandarax.kernel.validation.TestCase
162:             */
163:            public abstract TestCase createTestCase(Query aQuery,
164:                    ClauseSet[] assumptions, int policyToAddAssumptionsToKB,
165:                    boolean expectedResult);
166:
167:            /**
168:             * Create a new test case.
169:             * @return a new test case
170:             * @param aQuery a <strong>ground</strong> query
171:             * @param assumptions some assumptions
172:             * @param policyToAddAssumptionsToKB one of the integers in TestCase (TestCase.ON_TOP, TestCase.AT_BOTTOM)
173:             * @param expectedNumberOfResults the expected number of results
174:             */
175:            public abstract TestCase createTestCase(Query aQuery,
176:                    ClauseSet[] assumptions, int policyToAddAssumptionsToKB,
177:                    int expectedNumberOfResults);
178:
179:            /**
180:             * Create a new test case.
181:             * @return a new test case
182:             * @param aQuery a <strong>ground</strong> query
183:             * @param assumptions some assumptions
184:             * @param policyToAddAssumptionsToKB one of the integers in TestCase (TestCase.ON_TOP, TestCase.AT_BOTTOM)
185:             * @param expectedReplacements an array of expected replacements, each map contains VariableTerm -> Object associations
186:             */
187:            public abstract TestCase createTestCase(Query aQuery,
188:                    ClauseSet[] assumptions, int policyToAddAssumptionsToKB,
189:                    Map[] expectedReplacements);
190:
191:            /**
192:             * Create a new test case.
193:             * Note that the parameters are somehow redundant, expectedResult only makes sense if the query is ground while 
194:             * expectedReplacements only makes sense if the query contains variables. This is a general purpose 
195:             * creator that can be used in modules such as ZKB.
196:             * @return a new test case
197:             * @param aQuery a <strong>ground</strong> query
198:             * @param assumptions some assumptions
199:             * @param policyToAddAssumptionsToKB one of the integers in TestCase (TestCase.ON_TOP, TestCase.AT_BOTTOM)
200:             * @param expectedNumberOfResults the expected number of results
201:             * @param expectedResult true or false
202:             * @param expectedReplacements an array of expected replacements, each map contains VariableTerm -> Object associations
203:             */
204:            public abstract TestCase createTestCase(Query aQuery,
205:                    ClauseSet[] assumptions, int policyToAddAssumptionsToKB,
206:                    int expectedNumberOfResults, boolean expectedResult,
207:                    Map[] expectedReplacements);
208:
209:            /**
210:             * Get the default factory.
211:             * @return the default factory object
212:             */
213:            public static LogicFactory getDefaultFactory() {
214:                if (defaultFactory == null) {
215:                    try {
216:
217:                        // try to set the default factory, use reference by name in order
218:                        // to keep this package independent from the reference package !!
219:                        Class clazz = Class
220:                                .forName("org.mandarax.reference.DefaultLogicFactory");
221:                        LogicFactory lf = (LogicFactory) clazz.newInstance();
222:
223:                        lf.install();
224:                    } catch (Exception x) {
225:                        System.err
226:                                .println("cannot install org.mandarax.reference.DefaultLogicFactory");
227:                    }
228:                }
229:
230:                return defaultFactory;
231:            }
232:
233:            /**
234:             * Install the object to become the default factory.
235:             */
236:            public void install() {
237:                defaultFactory = this ;
238:            }
239:
240:            /**
241:             * Return the implementation class for facts. 
242:             * @return a class
243:             */
244:            public abstract Class getFactImplementationClass();
245:
246:            /**
247:             * Return the implementation class for rules. 
248:             * @return a class
249:             */
250:            public abstract Class getRuleImplementationClass();
251:
252:            /**
253:             * Return the implementation class for prerequisites. 
254:             * @return a class
255:             */
256:            public abstract Class getPrerequisiteImplementationClass();
257:
258:            /**
259:             * Return the implementation class for queries. 
260:             * @return a class
261:             */
262:            public abstract Class getQueryImplementationClass();
263:
264:            /**
265:             * Return the implementation class for constant terms. 
266:             * @return a class
267:             */
268:            public abstract Class getConstantTermImplementationClass();
269:
270:            /**
271:             * Return the implementation class for variable terms. 
272:             * @return a class
273:             */
274:            public abstract Class getVariableTermImplementationClass();
275:
276:            /**
277:             * Return the implementation class for complex terms. 
278:             * @return a class
279:             */
280:            public abstract Class getComplexTermImplementationClass();
281:
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.