KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > filter > lib > Max


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.filter.lib;
25
26 import org.objectweb.medor.expression.api.ExpressionException;
27 import org.objectweb.medor.expression.api.MalformedExpressionException;
28 import org.objectweb.medor.expression.api.Operator;
29 import org.objectweb.medor.expression.api.ParameterOperand;
30 import org.objectweb.medor.expression.api.Operand;
31 import org.objectweb.medor.expression.api.Expression;
32 import org.objectweb.medor.expression.lib.BasicVariableOperand;
33
34 /**
35  * Max aggregate function.
36  * <p> Max applies to :
37  * <ol>
38  * <li>a FieldOperand, which is part of a NestedField.</li>
39  * <li>a Collection of values (TupleCollection), specifying which Field
40  * is to be aggregated</li>
41  * <li>a Collection of values (Java Collection)</li>
42  * </ol>
43  * @author Alexandre Lefebvre
44  */

45 public class Max extends BasicAggregateOperator {
46
47     public Max(Expression e) {
48         super(e.getType(), e);
49     }
50
51     public Max(Expression e, boolean distinct) {
52         super(e.getType(), e, distinct);
53     }
54
55     public String JavaDoc getOperatorString() {
56         return Operator.MAX;
57     }
58
59     public Operand compileExpression()
60             throws ExpressionException, MalformedExpressionException {
61         if (expressions[0] != null) {
62             expressions[0].compileExpression();
63                 result = new BasicVariableOperand(expressions[0].getType());
64                 verified = true;
65         }
66         else
67         // Operands not yet assigned
68
throw new MalformedExpressionException("null children value");
69         return result;
70     }
71
72     public org.objectweb.medor.expression.api.Operand evaluate(ParameterOperand[] pos, Object JavaDoc o)
73             throws ExpressionException {
74         throw new ExpressionException("Implementation of Avg by MEDOR not yet implemented");
75     }
76 }
77
Popular Tags