KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > filter > jorm > lib > IsNullPName


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, A. Lefebvre, S. Chassande-Barrioz
22  */

23 package org.objectweb.medor.filter.jorm.lib;
24
25 import org.objectweb.jorm.naming.api.PName;
26 import org.objectweb.medor.expression.api.ExpressionException;
27 import org.objectweb.medor.expression.api.ParameterOperand;
28 import org.objectweb.medor.expression.api.CalculatedParameterOperand;
29 import org.objectweb.medor.expression.lib.BasicParameterOperand;
30 import org.objectweb.medor.type.lib.PTypeSpaceMedor;
31 import org.objectweb.medor.type.lib.QType;
32
33 /**
34  * This implementation of the CalculatedParameterOperand interface checks if
35  * a PName is null. This PName must be given in parameter among the
36  * ParameterOperand of the evaluate method.
37  *
38  * @author A. Lefebvre
39  */

40 public class IsNullPName
41     extends BasicParameterOperand
42     implements CalculatedParameterOperand {
43
44
45     public IsNullPName(String JavaDoc parameterName) {
46         super(PTypeSpaceMedor.BOOLEAN, parameterName);
47     }
48
49     // IMPLEMENTATION OF THE CalculatedParameterOperand INTERFACE //
50
//------------------------------------------------------------//
51

52     public void evaluate(ParameterOperand[] pos) throws ExpressionException {
53         PName pn = null;
54         for (int i = 0; i < pos.length; i++) {
55             if (pos[i] != null
56                     && name.equals(pos[i].getName())
57                     && pos[i].getType().getTypeCode() == QType.TYPECODE_PNAME) {
58                 pn = (PName) pos[i].getObject();
59             }
60         }
61         if (pn == null) {
62             throw new ExpressionException("Impossible to evaluate this parameter wihtout the parameter " + name);
63         }
64         this.setValue(pn.isNull());
65     }
66 }
67
Popular Tags