KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > expression > api > Expression


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2003 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, S. Chassande-Barrioz, A. Lefebvre
22  */

23
24 package org.objectweb.medor.expression.api;
25
26 import org.objectweb.jorm.type.api.PType;
27 import org.objectweb.medor.clone.api.Cloneable;
28
29 import java.io.Serializable JavaDoc;
30
31 /**
32  * This interface represents an arithmetic and/or a
33  * boolean expression.
34  * <p> It represents operations over operands. It is
35  * represented by a tree where nodes represents operations and leafs operands.
36  * An expression have two states:
37  * <p>
38  * Not compiled in wich case it can be modified.
39  * <p>
40  * Compiled, this state is possible after compilation method
41  * CompileExpression().
42  * <p>
43  * Then it will be evaluable and its structure cannot be further modified.
44  * <p> Here is a simple example:<br>
45  * <tt> Expression exp = ...<br>
46  * exp.CompileExpression();<br>
47  * Operand op = exp.getResult();<br>
48  * exp.evaluate(......);<br>
49  * System.out.println("the result = "+ op.getInt());<br>
50  * </tt>
51  */

52 public interface Expression extends Serializable JavaDoc, Cloneable JavaDoc {
53
54     /**
55      * It gets the result type of this expression
56      * @return a PType object
57      */

58     public PType getType();
59
60     /**
61      * It evaluates the expression tree and puts the result into the operand
62      * result.
63      * @param values a list of ParameterOperand
64      * @param o the input Object from which values are taken for the
65      * evaluation
66      * @return an Operand containing the result of the evaluation
67      * @throws IllegalStateException if this expression is not
68      * compiled.
69      */

70     public Operand evaluate(ParameterOperand[] values, Object JavaDoc o)
71         throws ExpressionException;
72
73     /**
74      * Checks the semantic integrity of an expression.
75      * It checks that all types are compatible and prepare the expression to be
76      * evaluable.It also creates buffers where stores the result. Notes that
77      * when evaluating there is no creation of new objects. This method change
78      * the state of this expression object, it will be evaluable and not
79      * modifiable.
80      * @throws org.objectweb.medor.expression.api.TypingException when incompatible types error
81      * occures.
82      * @throws org.objectweb.medor.expression.api.MalformedExpressionException if syntax error
83      */

84     Operand compileExpression()
85         throws ExpressionException, MalformedExpressionException;
86
87 }
88
Popular Tags