001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.unifiedGui.listener;
032:
033: import java.beans.*;
034: import java.util.*;
035:
036: import de.ug2t.kernel.*;
037: import de.ug2t.unifiedGui.*;
038: import de.ug2t.unifiedGui.interfaces.*;
039:
040: public class UnExpressionListener implements IUnGuiEventListener {
041: private String pem_obj = null;
042: private String pem_expression = null;
043: private ArrayList pem_assignments = new ArrayList();
044:
045: public UnExpressionListener(String xObj, String xExpression,
046: String xParamters) {
047: this .pem_obj = xObj;
048: this .pem_expression = xExpression;
049:
050: if (xParamters != null)
051: pem_assignments = KeTools
052: .pcmf_stringTokens(xParamters, ";");
053: }
054:
055: public void pcmf_execListener(UnComponent xParam) throws Exception {
056: Iterator l_it = this .pem_assignments.iterator();
057: ArrayList l_params = new ArrayList();
058: while (l_it.hasNext()) {
059: String l_par = l_it.next().toString().trim();
060:
061: // Hier muss noch aufgelöst werden boolean, integer, floats, strings
062: if (l_par.startsWith("Integer") && l_par.endsWith(")")) {
063: l_par = KeTools.pcmf_stringSubst(l_par, " ", "");
064: l_par = KeTools.pcmf_stringSingleSubst(l_par,
065: "Integer(", "");
066: l_par = KeTools.pcmf_stringSingleSubst(l_par, ")", "");
067:
068: l_params.add(new Integer(l_par));
069: } else if (l_par.startsWith("Boolean")
070: && l_par.endsWith(")")) {
071: l_par = KeTools.pcmf_stringSubst(l_par, " ", "");
072: l_par = KeTools.pcmf_stringSingleSubst(l_par,
073: "Boolean(", "");
074: l_par = KeTools.pcmf_stringSingleSubst(l_par, ")", "");
075:
076: l_params.add(new Boolean(l_par));
077: } else if (l_par.startsWith("String")
078: && l_par.endsWith(")")) {
079: l_par = l_par.substring(l_par.indexOf("(") + 1, l_par
080: .lastIndexOf(")"));
081: l_params.add(l_par);
082: } else if (l_par.startsWith("Float") && l_par.endsWith(")")) {
083: l_par = KeTools.pcmf_stringSubst(l_par, " ", "");
084: l_par = KeTools.pcmf_stringSingleSubst(l_par, "Float(",
085: "");
086: l_par = KeTools.pcmf_stringSingleSubst(l_par, ")", "");
087:
088: l_params.add(new Float(l_par));
089: } else if (l_par.startsWith("Double")
090: && l_par.endsWith(")")) {
091: l_par = KeTools.pcmf_stringSubst(l_par, " ", "");
092: l_par = KeTools.pcmf_stringSingleSubst(l_par,
093: "Double(", "");
094: l_par = KeTools.pcmf_stringSingleSubst(l_par, ")", "");
095:
096: l_params.add(new Double(l_par));
097: } else if (l_par.startsWith("Long") && l_par.endsWith(")")) {
098: l_par = KeTools.pcmf_stringSubst(l_par, " ", "");
099: l_par = KeTools.pcmf_stringSingleSubst(l_par, "Long(",
100: "");
101: l_par = KeTools.pcmf_stringSingleSubst(l_par, ")", "");
102:
103: l_params.add(new Long(l_par));
104: } else if (l_par.startsWith("toString")
105: && l_par.endsWith(")")) {
106: l_par = KeTools.pcmf_stringSubst(l_par, " ", "");
107: l_par = KeTools.pcmf_stringSingleSubst(l_par,
108: "toString(", "");
109: l_par = KeTools.pcmf_stringSingleSubst(l_par, ")", "");
110:
111: if (KeTools.pcmf_isObjReference(l_par))
112: l_params.add(KeTools.pcmf_deRefObj(l_par)
113: .toString());
114: else {
115: if (l_par.equalsIgnoreCase("this"))
116: l_params.add(xParam.toString());
117: else if (l_par.equalsIgnoreCase("null"))
118: l_params.add((String) null);
119: else
120: l_params.add(KeTools.pcmf_deRef(l_par)
121: .toString());
122: }
123: } else if (KeTools.pcmf_isObjReference(l_par))
124: l_params.add(KeTools.pcmf_deRefObj(l_par));
125: else {
126: if (l_par.equalsIgnoreCase("this"))
127: l_params.add(xParam);
128: else if (l_par.equalsIgnoreCase("null"))
129: l_params.add(null);
130: else
131: l_params.add(KeTools.pcmf_deRef(l_par));
132: }
133: }
134:
135: Expression l_expr = new Expression(this .pem_obj
136: .equalsIgnoreCase("this") ? xParam : KeTools
137: .pcmf_deRefObj("~" + this.pem_obj),
138: this.pem_expression, l_params.toArray());
139: l_expr.execute();
140:
141: return;
142: }
143:
144: }
|