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 java.util.Iterator;
021: import java.util.List;
022: import org.mandarax.kernel.validation.TestCase;
023:
024: /**
025: * Knowledge Base objects are containers managing knowledge represented
026: * by clauses sets (this includes facts and rules).
027: * <br/>
028: * As from version 1.9 the knowledge base manages also a set of (named) queries.
029: * This is consistent with <a href="www.ruleml.org">RuleML</a> where knowledge bases ("rule bases") also contain queries.
030: * <br/>
031: * New methods for adding/removing plugins to the knowledgebase are added since 3.3.1 (by Adrian Paschke).
032: * <br/>
033: * New methods for adding/removing test cases to the knowledgebase are added since 3.4 (by Jens Dietrich).
034: * @see org.mandarax.kernel.Fact
035: * @see org.mandarax.kernel.Rule
036: * @see org.mandarax.kernel.ClauseSet
037: * @see org.mandarax.kernel.validation.TestCase
038: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
039: * @version 3.4 <7 March 05>
040: * @since 1.0
041: */
042: public interface KnowledgeBase extends KnowledgeOwner,
043: ClauseSetChangeListener {
044:
045: /**
046: * Add a plugin to knowledgebase
047: * @parameter plugin a KnowledgeBase
048: * @parameter id String - the URI of the plugin
049: * @since 3.3.1 added by Adrian Paschke
050: */
051: void addPlugIn(KnowledgeBase plugin, String id);
052:
053: /**
054: * Add a plugin to knowledgebase
055: * @parameter plugin a KnowledgeBase
056: * @parameter id String - the URI of the plugin
057: * @since 3.3.1 added by Adrian Paschke
058: */
059: void addPlugIn(List plugin, String id);
060:
061: /**
062: * Add a plugin to knowledgebase
063: * @parameter plugin a KnowledgeBase
064: * @parameter id String - the URI of the plugin
065: * @since 3.3.1 added by Adrian Paschke
066: */
067: void addPlugIn(ClauseSet[] plugin, String id);
068:
069: /**
070: * Remove a plugin with the id from knowledgebase
071: * @parameter id String - the plugin URI
072: * @since 3.3.1 added by Adrian Paschke
073: */
074: void removePlugIn(String id);
075:
076: /**
077: * Add a clause set.
078: * @param c a clause set
079: */
080: void add(ClauseSet c);
081:
082: /**
083: * Add a knowledge base change listener.
084: * @param l a listener
085: */
086: void addKnowledgeBaseChangeListener(KnowledgeBaseChangeListener l);
087:
088: /**
089: * Get a collection containing all clause sets.
090: * @return a list containing all clause sets
091: */
092: java.util.List getClauseSets();
093:
094: /**
095: * Get a collection containing all clause sets that have the key.
096: * @param the key object
097: * @return a list containing all clause sets
098: */
099: java.util.List getClauseSets(Object key);
100:
101: /**
102: * Get the feature descriptions.
103: * @return the feature descriptions
104: */
105: KnowledgeBaseFeatureDescriptions getFeatureDescriptions();
106:
107: /**
108: * Get the keys.
109: * @return the list of keys
110: */
111: java.util.Collection getKeys();
112:
113: /**
114: * Remove a clause.
115: * @return true if the object has been found (true) or not (false)
116: * @param c org.mandarax.kernel.ClauseSet
117: */
118: public boolean remove(ClauseSet c);
119:
120: /**
121: * Remove all clauses.
122: */
123: public void removeAll();
124:
125: /**
126: * Remove a knowledge base change listener.
127: * @param l a listener
128: */
129: void removeKnowledgeBaseChangeListener(KnowledgeBaseChangeListener l);
130:
131: /**
132: * Add a query.
133: * @param q a query
134: */
135: void addQuery(Query q);
136:
137: /**
138: * Remove a query.
139: * @param q a query
140: * @return true if the object has been found (true) or not (false)
141: */
142: boolean removeQuery(Query q);
143:
144: /**
145: * Get a query by name or null if there is no query with this name.
146: * @param queryName a query name
147: * @return a query of null if there is no query registered with this name
148: */
149: Query getQuery(String queryName);
150:
151: /**
152: * Get an iterator for the names of all queries registered.
153: * @return an iterator
154: */
155: Iterator queryNames();
156:
157: /**
158: * Get an iterator for all queries registered.
159: * @return an iterator
160: */
161: Iterator queries();
162:
163: /**
164: * Get an iterator for all predicates contained (in any clause set with-) in the kb.
165: * @return an iterator
166: */
167: Iterator predicates();
168:
169: /**
170: * Get a predicate by name.
171: * Note that there might by more than one predicate in the kb with the same name.
172: * In some cases, this makes sense (e.g. polymorphic predicates such as < for different
173: * types), but should be avoided for "custom" predicates (such as SimplePredicates).
174: * In this case, this method should return one predicate. In this case, applications can still use
175: * predicates() in order to find all predicates with a particular name.
176: * @return a predicate or null indicating that the kb does not contain a predicate with this name
177: * @param name a predicate name
178: */
179: Predicate getPredicate(String name);
180:
181: /**
182: * Add a test case.
183: * @param testCase a test case
184: */
185: void addTestCase(TestCase testCase);
186:
187: /**
188: * Remove a test case.
189: * @param testCase a test case
190: * @return true if the object has been found (true) or not (false)
191: */
192: boolean removeTestCase(TestCase testCase);
193:
194: /**
195: * Get an iterator for all test cases registered.
196: * @return an iterator
197: */
198: Iterator testcases();
199:
200: }
|