01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.mandarax.kernel;
19:
20: /**
21: * General interface for logical entities used to build complex
22: * logical entities from simple entities. In particular, this
23: * includes predicates and functions (used to build fact and complex terms).
24: * Instances should be identified (<code>equals()</code>) using name and structure!
25: * @see org.mandarax.kernel.Predicate
26: * @see org.mandarax.kernel.Function
27: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
28: * @version 3.4 <7 March 05>
29: * @since 1.0
30: */
31: public interface Constructor extends java.io.Serializable,
32: SemanticsSupport {
33:
34: /**
35: * Get the name of the object.
36: * @return the name of the constructor
37: */
38: String getName();
39:
40: /**
41: * Get the type structure of the object, e.g. the types of terms
42: * that can be used with this constructor.
43: * @return the structure of this constructor
44: */
45: Class[] getStructure();
46:
47: /**
48: * Perform the function or predicate using an array of terms as
49: * parameters.
50: * This usually can only succeed if all terms are constant and
51: * the function has a semantic. E.g. if the function is (a wrapper around)
52: * a java method, perform means invoking the method with the objects
53: * wrapped by the constant terms as parameters.
54: * <br>
55: * The interface has been changed in 3.2 and takes now a session parameter.
56: * This is to support functionality such as concurrent simulations. The session
57: * object provides a context in which the operation is executed. The main
58: * purpose of the session is to identify this context. Most applications
59: * will not need this and can ignore this parameter.
60: * @return the result of the perform operation
61: * @param parameter an array of terms
62: * @param session a session object
63: * @throws java.lang.UnsupportedOperationException thrown if this constructor does not have a sematics and this operation cannot be supported
64: * @throws java.lang.IllegalArgumentException
65: */
66: Object perform(Term[] parameter, Session session)
67: throws IllegalArgumentException,
68: UnsupportedOperationException;
69: }
|