📄 abstractclause.java
字号:
/*
* Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.mandarax.kernel;
import java.util.Iterator;
import java.util.Vector;
import org.mandarax.util.logging.*;
/**
* Abstract super class providing some common functionality
* for classes implementing <code>org.mandarax.kernel.Clause</code>.
* @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
* @version 3.4 <7 March 05>
* @since 1.0
*/
public abstract class AbstractClause extends AbstractPropertiesSupport implements Clause, LogCategories {
protected transient Vector clauseSetChangeListener = new Vector ();
protected ClauseSet container = this;
/**
* Constructor.
*/
public AbstractClause() {
super ();
}
/**
* Add a clause set listener.
* @param l the listener
*/
public void addClauseSetChangeListener(ClauseSetChangeListener l) {
clauseSetChangeListener.add (l);
}
/**
* Get a clause iterator.
* @return a clause iterator
*/
public org.mandarax.util.ClauseIterator clauses() {
return new org.mandarax.util.SingleClauseIterator (this);
}
/**
* Get a clause iterator.
* @param query the query clause
* @param additionalParameter an optional additional parameter
* @return a clause iterator
*/
public org.mandarax.util.ClauseIterator clauses(Clause query,Object additionalParameter) {
return clauses ();
}
/**
* Fire a clause set change event.
* @param e the change event
*/
protected void fireClauseSetChangeEvent(ClauseSetChangeEvent e) {
ClauseSetChangeListener l;
for(Iterator it = clauseSetChangeListener.iterator (); it.hasNext (); ) {
l = (ClauseSetChangeListener) it.next ();
l.clauseSetChanged (e);
}
}
/**
* Get the clause set containing the clause. This method is in particular useful for analyzing derivations,
* since derivations show only the clauses used, not the clause set generating this clauses (e.g., AutoFacts). On the other
* hand, knowledge bases contain often clause sets. So it could be hard to find the clause sets in the knowledge base
* that caused a certain result. For sme clauses such as facts, the container is just the fact itself.
* @return a clause set
*/
public ClauseSet getContainer() {
return container;
}
/**
* Remove a clause set listener.
* @param l the listener
*/
public void removeClauseSetChangeListener(ClauseSetChangeListener l) {
clauseSetChangeListener.remove (l);
}
/**
* Set a container.
* @param aContainerthe new container
*/
public void setContainer(ClauseSet aContainer) {
container = aContainer;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -