0001: // @@
0002: // @@
0003: /*
0004: * Wi.Ser Framework
0005: *
0006: * Version: 1.8.1, 20-September-2007
0007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
0008: *
0009: * This library is free software; you can redistribute it and/or
0010: * modify it under the terms of the GNU Lesser General Public
0011: * License as published by the Free Software Foundation; either
0012: * version 2 of the License, or (at your option) any later version.
0013: *
0014: * This library is distributed in the hope that it will be useful,
0015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0017: * Lesser General Public License for more details.
0018: *
0019: * You should have received a copy of the GNU Lesser General Public
0020: * License along with this library located in LGPL.txt in the
0021: * license directory; if not, write to the
0022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0023: * Boston, MA 02111-1307, USA.
0024: *
0025: * If this agreement does not cover your requirements, please contact us
0026: * via email to get detailed information about the commercial license
0027: * or our service offerings!
0028: *
0029: */
0030: // @@
0031: package de.ug2t.xmlScript;
0032:
0033: import java.io.*;
0034: import java.lang.reflect.*;
0035: import java.util.*;
0036:
0037: import org.xml.sax.*;
0038: import org.xml.sax.helpers.*;
0039:
0040: import com.bluecast.xml.*;
0041:
0042: import de.ug2t.kernel.*;
0043: import de.ug2t.unifiedGui.*;
0044: import de.ug2t.unifiedGui.interfaces.*;
0045: import de.ug2t.workflow.*;
0046:
0047: class ScXmlSAXHandler extends DefaultHandler {
0048: private IScExecutable pem_act = null;
0049: private ScXmlScript pem_actScript = null;
0050: private ArrayList pem_elements = new ArrayList(50);
0051: private boolean pem_doParse = false;
0052:
0053: public final void pcmf_setxScript(ScXmlScript xxScript) {
0054: this .pem_actScript = xxScript;
0055: this .pem_elements.clear();
0056: this .pem_elements.add(this .pem_actScript);
0057: };
0058:
0059: public final void startElement(String uri, String localName,
0060: String qName, Attributes attributes) throws SAXException {
0061: boolean l_do = qName.equals("x") || qName.equals("xScript");
0062: if (l_do)
0063: this .pem_doParse = true;
0064:
0065: if (this .pem_doParse == false)
0066: return;
0067:
0068: if (l_do) {
0069: // Debug
0070: // System.out.println("XMLParser-found: xScript");
0071: pem_act = pem_actScript;
0072: // Debug
0073: // System.out.println("XMLParser-akt: " + pem_act.toString());
0074: } else {
0075: try {
0076: // Debug
0077: // System.out.println("XMLParser-found: "+qName);
0078:
0079: Object newitem = pem_act.pcmf_addParam(qName,
0080: attributes);
0081: // Debug
0082: // System.out.println("XMLParser PUSH: " + pem_act.toString());
0083:
0084: pem_elements.add(this .pem_act);
0085: pem_act = (IScExecutable) newitem;
0086:
0087: // Debug
0088: // System.out.println("XMLParser-akt: " + pem_act.toString());
0089: } catch (Exception e) {
0090: KeLog.pcmf_logException("ug2t", this , e);
0091: }
0092: ;
0093: }
0094: ;
0095:
0096: return;
0097: };
0098:
0099: public final void endElement(String uri, String localName,
0100: String qName) throws SAXException {
0101: if (qName.equals("x") || qName.equals("xScript"))
0102: this .pem_doParse = false;
0103:
0104: if (this .pem_doParse == false)
0105: return;
0106: // Debug
0107: // System.out.println("XMLParser-end: " + qName);
0108: pem_act = (IScExecutable) this .pem_elements
0109: .remove(this .pem_elements.size() - 1);
0110: // Debug
0111: // System.out.println("XMLParser POP: " + pem_act.toString());
0112:
0113: return;
0114: };
0115:
0116: public final ScXmlScript pcmf_getxScript() {
0117: return (this .pem_actScript);
0118: };
0119: };
0120:
0121: // ==============================================================================
0122:
0123: interface IScExecutable {
0124: public Object pcmf_exec(ScXmlProcedure xCaller, Object xPar)
0125: throws Exception;
0126:
0127: public Object pcmf_addParam(String xParName, Attributes xAttr)
0128: throws Exception;
0129: };
0130:
0131: // ==============================================================================
0132:
0133: class ScXmlProcedure extends KeRegisteredObject implements
0134: IScExecutable, IUnGuiEventListener, IWfAction {
0135: private ArrayList pem_statements = new ArrayList(50);
0136: private Map pem_labels = new HashMap();
0137: private Map pem_myObjs = new HashMap();
0138: private int pem_lineptr = 0;
0139: private boolean pem_keepObjs = false;
0140:
0141: public ScXmlProcedure() {
0142: super (false);
0143: }
0144:
0145: public final void pcmf_addLocalObj(String xName, Object xObj) {
0146: KeLog.pcmf_log("ug2t", "creating object in xScript: " + xName
0147: + "=" + xObj, this , KeLog.TRACE);
0148:
0149: this .pem_myObjs.put(xName, xObj);
0150: };
0151:
0152: public void pcmf_delete() throws Exception {
0153: if (this .pdm_deleted == true)
0154: return;
0155:
0156: Iterator it = this .pem_myObjs.values().iterator();
0157: Object value = null;
0158:
0159: KeLog.pcmf_log("ug2t", "cleaning up xProc", this , KeLog.TRACE);
0160:
0161: while (it.hasNext()) {
0162: value = it.next();
0163: if (value instanceof KeRegisteredObject)
0164: ((KeRegisteredObject) value).pcmf_delete();
0165: else
0166: KeRegisteredObject.pcmf_unRegister(value);
0167: }
0168: ;
0169: this .pem_myObjs.clear();
0170: this .pem_statements.clear();
0171:
0172: super .pcmf_delete();
0173: };
0174:
0175: public final void pcmf_Goto(String xLabel) {
0176: pem_lineptr = ((Integer) this .pem_labels.get(xLabel))
0177: .intValue();
0178:
0179: return;
0180: };
0181:
0182: public final void pcmf_keepObjects(boolean xKeep) {
0183: pem_keepObjs = xKeep;
0184:
0185: return;
0186: };
0187:
0188: public final Object pcmf_exec(ScXmlProcedure xCaller, Object xPar)
0189: throws Exception {
0190: int len = this .pem_statements.size();
0191: IScExecutable exec = null;
0192: Object l_retval = null;
0193:
0194: if (pem_keepObjs == false) {
0195: Iterator it = this .pem_myObjs.values().iterator();
0196: Object value = null;
0197:
0198: KeLog.pcmf_log("ug2t", "cleaning up xProc", this ,
0199: KeLog.TRACE);
0200:
0201: while (it.hasNext()) {
0202: value = it.next();
0203: if (value instanceof KeRegisteredObject)
0204: ((KeRegisteredObject) value).pcmf_delete();
0205: else
0206: KeRegisteredObject.pcmf_unRegister(value);
0207: }
0208: ;
0209: this .pem_myObjs.clear();
0210: }
0211: ;
0212:
0213: while (pem_lineptr != len) {
0214: try {
0215: exec = (IScExecutable) this .pem_statements
0216: .get(this .pem_lineptr);
0217: if (xCaller == null)
0218: l_retval = exec.pcmf_exec(this , null);
0219: else
0220: l_retval = exec.pcmf_exec(xCaller, null);
0221:
0222: this .pem_lineptr++;
0223: } catch (Exception e) {
0224: KeLog.pcmf_logException("ug2t", this , e);
0225: KeLog.pcmf_log("ug2t",
0226: "exception during xScript [line: "
0227: + Integer.toString(this .pem_lineptr)
0228: + "] [command-class: "
0229: + exec.toString() + "]", this ,
0230: KeLog.FATAL);
0231: return (null);
0232: }
0233: ;
0234: }
0235: ;
0236:
0237: pem_lineptr = 0;
0238:
0239: return (l_retval);
0240: };
0241:
0242: public final void pcmf_execListener(UnComponent xParam)
0243: throws Exception {
0244: pcmf_exec(this , xParam);
0245:
0246: return;
0247: };
0248:
0249: public final void pcmf_execWF(WfState xState) throws Exception {
0250: pcmf_exec(this , xState);
0251:
0252: return;
0253: };
0254:
0255: public final Object pcmf_addParam(String xParName, Attributes xAttr)
0256: throws Exception {
0257: IScExecutable newline = null;
0258:
0259: if (xParName.equals("d") || xParName.equals("Declare")) {
0260: ScXmlDeclaration decl = new ScXmlDeclaration();
0261:
0262: String l_type = xAttr.getValue("t");
0263: String l_name = xAttr.getValue("n");
0264: String l_ctx = xAttr.getValue("c");
0265:
0266: if (l_type == null)
0267: l_type = xAttr.getValue("objtype");
0268: if (l_name == null)
0269: l_name = xAttr.getValue("objname");
0270: if (l_ctx == null)
0271: l_ctx = xAttr.getValue("objctx");
0272:
0273: decl.pcmf_setObjClass(KeTools.pcmf_deRef(l_type));
0274: decl.pcmf_setObjName(KeTools.pcmf_deRef(l_name));
0275: decl.pcmf_setObjCtx(KeTools.pcmf_deRef(l_ctx));
0276:
0277: this .pcmf_addStmtLine(decl);
0278:
0279: newline = decl;
0280: } else if (xParName.equals("c") || xParName.equals("Call")) {
0281: ScXmlCall call = new ScXmlCall();
0282:
0283: String l_method = xAttr.getValue("m");
0284: String l_name = xAttr.getValue("n");
0285: String l_result = xAttr.getValue("r");
0286:
0287: if (l_method == null)
0288: l_method = xAttr.getValue("method");
0289: if (l_name == null)
0290: l_name = xAttr.getValue("objname");
0291: if (l_result == null)
0292: l_result = xAttr.getValue("result");
0293:
0294: call.pcmf_setObjName(KeTools.pcmf_deRef(l_name));
0295: call.pcmf_setMethod(KeTools.pcmf_deRef(l_method));
0296: call.pcmf_setResult(KeTools.pcmf_deRef(l_result));
0297:
0298: this .pcmf_addStmtLine(call);
0299:
0300: newline = call;
0301: }
0302:
0303: // @@
0304:
0305: return (newline);
0306: };
0307:
0308: public final void pcmf_addStmtLine(IScExecutable xLine) {
0309: // @@
0310:
0311: pem_statements.add(xLine);
0312:
0313: return;
0314: };
0315: };
0316:
0317: // ==============================================================================
0318:
0319: class ScParameter {
0320: public ScParameter(String xValue, boolean xObj, String xType) {
0321: this .pcm_obj = xObj;
0322: this .pcm_value = xValue;
0323: this .pcm_type = xType;
0324:
0325: return;
0326: };
0327:
0328: public String pcm_value;
0329: public boolean pcm_obj;
0330: public String pcm_type;
0331: };
0332:
0333: // ==============================================================================
0334:
0335: class ScXmlDeclaration implements IScExecutable {
0336: private String pem_objName = null;
0337: private String pem_class = null;
0338: private ArrayList pem_parameter = new ArrayList(5);
0339: private ArrayList pem_parameterNames = new ArrayList(5);
0340: private String pem_global = "local";
0341:
0342: public String toString() {
0343: String l_ret = "StmtType: Decl, ObjName: " + this .pem_objName
0344: + ", Class: " + this .pem_class;
0345:
0346: return (l_ret);
0347: }
0348:
0349: public final Object pcmf_exec(ScXmlProcedure xCaller, Object xPar)
0350: throws Exception {
0351: Object newObj = null;
0352: Class classOfObj = ScXmlScript.pcmf_getClass(pem_class);
0353: Object param[] = null;
0354: Class cparam[] = new Class[this .pem_parameterNames.size()];
0355:
0356: ScParameter phelp = null;
0357:
0358: pem_parameter.clear();
0359:
0360: Iterator it = this .pem_parameterNames.iterator();
0361: while (it.hasNext()) {
0362: phelp = (ScParameter) it.next();
0363: this .pcmf_setParamter(phelp.pcm_value, phelp.pcm_obj,
0364: phelp.pcm_type);
0365: }
0366: ;
0367:
0368: param = this .pem_parameter.toArray();
0369:
0370: for (int i = 0; i < this .pem_parameter.size(); i++) {
0371: if (param[i] != null) {
0372: if (param[i] instanceof Integer)
0373: cparam[i] = Integer.TYPE;
0374: else if (param[i] instanceof Float)
0375: cparam[i] = Float.TYPE;
0376: else if (param[i] instanceof Double)
0377: cparam[i] = Double.TYPE;
0378: else if (param[i] instanceof Long)
0379: cparam[i] = Long.TYPE;
0380: else if (param[i] instanceof Boolean)
0381: cparam[i] = Boolean.TYPE;
0382: else {
0383: phelp = (ScParameter) pem_parameterNames.get(i);
0384: if (phelp.pcm_type != null)
0385: cparam[i] = ScXmlScript
0386: .pcmf_getClass(phelp.pcm_type);
0387: else
0388: cparam[i] = param[i].getClass();
0389: }
0390: ;
0391: } else {
0392: phelp = (ScParameter) pem_parameterNames.get(i);
0393: if (phelp.pcm_obj == true && phelp.pcm_type != null)
0394: cparam[i] = ScXmlScript
0395: .pcmf_getClass(phelp.pcm_type);
0396: else
0397: cparam[i] = null;
0398: }
0399: ;
0400: }
0401: ;
0402:
0403: Constructor objConstr = classOfObj.getConstructor(cparam);
0404:
0405: newObj = objConstr.newInstance(param);
0406:
0407: if (newObj instanceof KeRegisteredObject) {
0408: // Objektdeklaration, auch die Remote-ID muss angepasst werden
0409: ((KeRegisteredObject) newObj).pcmf_unRegister();
0410: ((KeRegisteredObject) newObj).pcmf_resetRemoteName();
0411: if (this .pem_global.equals("global"))
0412: ((KeRegisteredObject) newObj)
0413: .pcmf_registerGlobal(pem_objName);
0414: else
0415: ((KeRegisteredObject) newObj)
0416: .pcmf_register(pem_objName);
0417: } else if (this .pem_global.equals("global"))
0418: KeRegisteredObject.pcmf_registerGlobal(pem_objName, newObj);
0419: else
0420: KeRegisteredObject.pcmf_register(pem_objName, newObj);
0421:
0422: if (this .pem_global.equals("local"))
0423: xCaller.pcmf_addLocalObj(pem_objName, newObj);
0424:
0425: return (newObj);
0426: };
0427:
0428: public final Object pcmf_addParam(String xParName, Attributes xAttr)
0429: throws Exception {
0430: if (xParName.equals("v") || xParName.equals("Parameter")) {
0431: String l_value = xAttr.getValue("v");
0432: String l_obj = xAttr.getValue("o");
0433: String l_objtype = xAttr.getValue("t");
0434:
0435: if (l_value == null)
0436: l_value = xAttr.getValue("value");
0437: if (l_obj == null)
0438: l_obj = xAttr.getValue("obj");
0439: if (l_objtype == null)
0440: l_objtype = xAttr.getValue("objtype");
0441:
0442: this .pcmf_setParameterName(KeTools.pcmf_deRef(l_value),
0443: KeTools.pcmf_deRef(l_obj).equals("true"), KeTools
0444: .pcmf_deRef(l_objtype));
0445: }
0446:
0447: return (this );
0448: };
0449:
0450: public final void pcmf_setObjName(String xobjName) {
0451: this .pem_objName = xobjName;
0452:
0453: return;
0454: };
0455:
0456: public final void pcmf_setObjClass(String xObjClass) {
0457: this .pem_class = xObjClass;
0458:
0459: return;
0460: };
0461:
0462: public final void pcmf_setObjCtx(String xObjCtx) {
0463: if (xObjCtx == null)
0464: return;
0465:
0466: this .pem_global = xObjCtx;
0467:
0468: return;
0469: };
0470:
0471: public final void pcmf_setParameterName(String xValue,
0472: boolean xObj, String xType) {
0473: this .pem_parameterNames
0474: .add(new ScParameter(xValue, xObj, xType));
0475:
0476: return;
0477: };
0478:
0479: public final void pcmf_setParamter(String xValue, boolean xObj,
0480: String xType) throws Exception {
0481: Object par2Add = null;
0482:
0483: if (xObj == true)
0484: par2Add = KeRegisteredObject.pcmf_getObjByName(xValue);
0485: else {
0486: if (xType == null && xValue.equals("null"))
0487: par2Add = null;
0488: else if (xType == null)
0489: par2Add = xValue;
0490: else if (xType.equals("int"))
0491: par2Add = new Integer(xValue);
0492: else if (xType.equals("float"))
0493: par2Add = new Float(xValue);
0494: else if (xType.equals("double"))
0495: par2Add = new Double(xValue);
0496: else if (xType.equals("long"))
0497: par2Add = new Long(xValue);
0498: else if (xType.equals("boolean"))
0499: par2Add = new Boolean(xValue);
0500: else {
0501: Object param[] = { xValue };
0502: Class cparam[] = { ScXmlScript
0503: .pcmf_getClass("java.lang.String") };
0504: Class classOfObj = cparam[0];
0505: Constructor objConstr = classOfObj
0506: .getConstructor(cparam);
0507:
0508: par2Add = objConstr.newInstance(param);
0509: }
0510: ;
0511: }
0512: ;
0513:
0514: this .pem_parameter.add(par2Add);
0515:
0516: return;
0517: };
0518: };
0519:
0520: // ==============================================================================
0521:
0522: class ScXmlCall implements IScExecutable {
0523: private String pem_ObjName = null;
0524: private String pem_Method = null;
0525: private String pem_Result = null;
0526: private ArrayList pem_parameter = new ArrayList(5);
0527: private ArrayList pem_parameterNames = new ArrayList(5);
0528:
0529: public String toString() {
0530: String l_ret = "StmtType: Call, ObjName: " + this .pem_ObjName
0531: + ", Method: " + this .pem_Method + ", Result: "
0532: + this .pem_Result;
0533:
0534: return (l_ret);
0535: }
0536:
0537: public final Object RETURN(Object xRetVal) {
0538: return (xRetVal);
0539: };
0540:
0541: public final Object pcmf_exec(ScXmlProcedure xCaller, Object xPar)
0542: throws Exception {
0543: Object obj = null;
0544:
0545: if (this .pem_ObjName.equals("THIS"))
0546: obj = this ;
0547: else
0548: obj = KeRegisteredObject
0549: .pcmf_getObjByName(this .pem_ObjName);
0550:
0551: if (obj == null) {
0552: KeLog.pcmf_log("ug2t", "object for script call: "
0553: + this .pem_Method + " not found: "
0554: + this .pem_ObjName, this , KeLog.DEBUG);
0555: return (null);
0556: }
0557:
0558: Class classOfObj = obj.getClass();
0559: Object param[] = null;
0560: Class cparam[] = new Class[this .pem_parameterNames.size()];
0561: Method methodptr = null;
0562: Object retval = null;
0563:
0564: ScParameter phelp = null;
0565:
0566: pem_parameter.clear();
0567:
0568: Iterator it = this .pem_parameterNames.iterator();
0569: while (it.hasNext()) {
0570: phelp = (ScParameter) it.next();
0571: this .pcmf_setParameter(phelp.pcm_value, phelp.pcm_obj,
0572: phelp.pcm_type);
0573: }
0574: ;
0575:
0576: param = this .pem_parameter.toArray();
0577:
0578: for (int i = 0; i < this .pem_parameter.size(); i++) {
0579: if (param[i] != null) {
0580: if (param[i] instanceof Integer)
0581: cparam[i] = Integer.TYPE;
0582: else if (param[i] instanceof Float)
0583: cparam[i] = Float.TYPE;
0584: else if (param[i] instanceof Double)
0585: cparam[i] = Double.TYPE;
0586: else if (param[i] instanceof Long)
0587: cparam[i] = Long.TYPE;
0588: else if (param[i] instanceof Boolean)
0589: cparam[i] = Boolean.TYPE;
0590: else {
0591: phelp = (ScParameter) pem_parameterNames.get(i);
0592: if (phelp.pcm_type != null)
0593: cparam[i] = ScXmlScript
0594: .pcmf_getClass(phelp.pcm_type);
0595: else
0596: cparam[i] = param[i].getClass();
0597: }
0598: ;
0599: } else {
0600: phelp = (ScParameter) pem_parameterNames.get(i);
0601: if (phelp.pcm_obj == true && phelp.pcm_type != null)
0602: cparam[i] = ScXmlScript
0603: .pcmf_getClass(phelp.pcm_type);
0604: else
0605: cparam[i] = null;
0606: }
0607: ;
0608: }
0609: ;
0610:
0611: methodptr = classOfObj.getMethod(this .pem_Method, cparam);
0612: retval = methodptr.invoke(obj, param);
0613:
0614: if (this .pem_Result != null) {
0615: if (retval instanceof KeRegisteredObject) {
0616: ((KeRegisteredObject) retval).pcmf_delete();
0617: ((KeRegisteredObject) retval)
0618: .pcmf_register(this .pem_Result);
0619: } else {
0620: KeRegisteredObject.pcmf_unRegister(this .pem_Result);
0621: KeRegisteredObject.pcmf_register(this .pem_Result,
0622: retval);
0623: }
0624: ;
0625: }
0626: ;
0627:
0628: return (retval);
0629: };
0630:
0631: public final Object pcmf_addParam(String xParName, Attributes xAttr)
0632: throws Exception {
0633: if (xParName.equals("v") || xParName.equals("Parameter")) {
0634: String l_value = xAttr.getValue("v");
0635: String l_obj = xAttr.getValue("o");
0636: String l_objtype = xAttr.getValue("t");
0637:
0638: if (l_value == null)
0639: l_value = xAttr.getValue("value");
0640: if (l_obj == null)
0641: l_obj = xAttr.getValue("obj");
0642: if (l_objtype == null)
0643: l_objtype = xAttr.getValue("objtype");
0644:
0645: this .pcmf_setParameterName(KeTools.pcmf_deRef(l_value),
0646: KeTools.pcmf_deRef(l_obj).equals("true"), KeTools
0647: .pcmf_deRef(l_objtype));
0648: }
0649:
0650: return (this );
0651: };
0652:
0653: public final void pcmf_setParameterName(String xValue,
0654: boolean xObj, String xType) {
0655: this .pem_parameterNames
0656: .add(new ScParameter(xValue, xObj, xType));
0657:
0658: return;
0659: };
0660:
0661: public final void pcmf_setParameter(String xValue, boolean xObj,
0662: String xType) throws Exception {
0663: Object par2Add = null;
0664:
0665: if (xObj == true)
0666: par2Add = KeRegisteredObject.pcmf_getObjByName(xValue);
0667: else {
0668: if (xType == null && xValue.equals("null"))
0669: par2Add = null;
0670: else if (xType == null)
0671: par2Add = xValue;
0672: else if (xType.equals("int"))
0673: par2Add = new Integer(xValue);
0674: else if (xType.equals("float"))
0675: par2Add = new Float(xValue);
0676: else if (xType.equals("double"))
0677: par2Add = new Double(xValue);
0678: else if (xType.equals("long"))
0679: par2Add = new Long(xValue);
0680: else if (xType.equals("boolean"))
0681: par2Add = new Boolean(xValue);
0682: else {
0683: Object param[] = { xValue };
0684: Class cparam[] = { ScXmlScript
0685: .pcmf_getClass("java.lang.String") };
0686: Class classOfObj = cparam[0];
0687: Constructor objConstr = classOfObj
0688: .getConstructor(cparam);
0689:
0690: par2Add = objConstr.newInstance(param);
0691: }
0692: ;
0693: }
0694: ;
0695:
0696: this .pem_parameter.add(par2Add);
0697:
0698: return;
0699: };
0700:
0701: public final void pcmf_setObjName(String xName) {
0702: this .pem_ObjName = xName;
0703: };
0704:
0705: public final void pcmf_setMethod(String xMethod) {
0706: this .pem_Method = xMethod;
0707: };
0708:
0709: public final void pcmf_setResult(String xResult) {
0710: this .pem_Result = xResult;
0711: };
0712: };
0713:
0714: // ==============================================================================
0715:
0716: // @@
0717:
0718: // ==============================================================================
0719:
0720: public class ScXmlScript implements IScExecutable {
0721: private Map pem_procs = new HashMap();
0722: static private XMLReader pem_xmlReader = new Piccolo();
0723: static private ScXmlSAXHandler pem_handler = new ScXmlSAXHandler();
0724:
0725: public static final byte SUBST_AMP[] = { 5, '&', 'a', 'm', 'p', ';' };
0726: public static final byte SUBST_LT[] = { 4, '&', 'l', 't', ';' };
0727: public static final byte SUBST_GT[] = { 4, '&', 'g', 't', ';' };
0728: public static final byte SUBST_Q1[] = { 6, '&', 'q', 'u', 'o', 't',
0729: ';' };
0730: public static final byte SUBST_Q2[] = { 6, '&', 'a', 'p', 'o', 's',
0731: ';' };
0732: public static final byte SUBST_CRLF[] = { 5, '&', '#', 'x', 'A',
0733: ';' };
0734: public static final byte SUBST_DOL[] = { 6, '&', '#', 'x', '2',
0735: '4', ';' };
0736:
0737: static {
0738: pem_xmlReader.setContentHandler(pem_handler);
0739: };
0740:
0741: public static final String XSCR_ENVELOP = "<?xml version=\"1.0\" encoding=\""
0742: + KeEnvironment.pcmf_getCharacterSet()
0743: + "\"?>{$00}<x>{$01}</x>";
0744: public static final String XSCR_PROC = "<p n=\"{$02}\">{$03}</p>";
0745: public static final String XSCR_DECL_E = "<d n=\"{$04}\" t=\"{$05}\" {$06}>{$07}</d>";
0746: public static final String XSCR_DECL_P = "<v v=\"{$08}\" o=\"{$09}\" {$10}/>";
0747: public static final String XSCR_CALL_E = "<c {$11} n=\"{$12}\" m=\"{$13}\">{$14}</c>";
0748: public static final String XSCR_CALL_P = "<v v=\"{$08}\" o=\"{$09}\" {$10}/>";
0749:
0750: public static final KeStringTemplate T_XSCR_ENVELOP = new KeStringTemplate(
0751: XSCR_ENVELOP);
0752: public static final KeStringTemplate T_XSCR_PROC = new KeStringTemplate(
0753: XSCR_PROC);
0754: public static final KeStringTemplate T_XSCR_DECL_E = new KeStringTemplate(
0755: XSCR_DECL_E);
0756: public static final KeStringTemplate T_XSCR_DECL_P = new KeStringTemplate(
0757: XSCR_DECL_P);
0758: public static final KeStringTemplate T_XSCR_CALL_E = new KeStringTemplate(
0759: XSCR_CALL_E);
0760: public static final KeStringTemplate T_XSCR_CALL_P = new KeStringTemplate(
0761: XSCR_CALL_P);
0762:
0763: private static HashMap pem_classes = new HashMap(1000);
0764:
0765: public void pcmf_parseString(String xSource) throws Exception {
0766: this .pem_procs.clear();
0767: try {
0768: synchronized (pem_xmlReader) {
0769: pem_handler.pcmf_setxScript(this );
0770: StringReader l_reader = new StringReader(xSource);
0771: InputSource l_source = new InputSource(l_reader);
0772: pem_xmlReader.parse(l_source);
0773: l_reader.close();
0774: }
0775: } catch (SAXParseException se) {
0776: KeLog.pcmf_log("ug2t", "SAX parser Exception at [line: "
0777: + se.getLineNumber() + "] [col: "
0778: + se.getColumnNumber() + "] [String/File: "
0779: + xSource + "]", this , KeLog.FATAL);
0780: }
0781: }
0782:
0783: public void pcmf_parseFile(String xSource) throws Exception {
0784: this .pem_procs.clear();
0785: try {
0786: synchronized (pem_xmlReader) {
0787: pem_handler.pcmf_setxScript(this );
0788: FileReader l_fr = new FileReader(KeEnvironment
0789: .pcmf_buildPath(xSource));
0790: InputSource l_source = new InputSource(l_fr);
0791: l_source.setEncoding(KeEnvironment
0792: .pcmf_getCharacterSet());
0793: pem_xmlReader.parse(l_source);
0794: l_fr.close();
0795: }
0796: } catch (SAXParseException se) {
0797: KeLog.pcmf_log("ug2t", "SAX parser Exception at [line: "
0798: + se.getLineNumber() + "] [col: "
0799: + se.getColumnNumber() + "] [String/File: "
0800: + xSource + "]", this , KeLog.FATAL);
0801: }
0802: }
0803:
0804: public void pcmf_parseBytes(byte[] xSource) throws Exception {
0805: this .pem_procs.clear();
0806: try {
0807: synchronized (pem_xmlReader) {
0808: pem_handler.pcmf_setxScript(this );
0809: ByteArrayInputStream l_stream = new ByteArrayInputStream(
0810: xSource);
0811: InputSource l_source = new InputSource(l_stream);
0812: l_source.setEncoding(KeEnvironment
0813: .pcmf_getCharacterSet());
0814: pem_xmlReader.parse(l_source);
0815: l_stream.close();
0816: }
0817: } catch (SAXParseException se) {
0818: KeLog.pcmf_log("ug2t", "SAX parser Exception at [line: "
0819: + se.getLineNumber() + "] [col: "
0820: + se.getColumnNumber() + "] [String/File: "
0821: + xSource + "]", this , KeLog.FATAL);
0822: }
0823: }
0824:
0825: public static Class pcmf_getClass(String xClass) throws Exception {
0826: Class l_res = (Class) pem_classes.get(xClass);
0827: if (l_res == null) {
0828: l_res = Class.forName(xClass);
0829: pem_classes.put(xClass, l_res);
0830: }
0831: return (l_res);
0832: }
0833:
0834: public ScXmlScript() {
0835: synchronized (pem_xmlReader) {
0836: pem_handler.pcmf_setxScript(this );
0837: }
0838: ;
0839:
0840: return;
0841: };
0842:
0843: public ScXmlScript(String xSource) throws Exception {
0844: try {
0845: synchronized (pem_xmlReader) {
0846: pem_handler.pcmf_setxScript(this );
0847: FileReader l_fr = new FileReader(KeEnvironment
0848: .pcmf_buildPath(xSource));
0849: InputSource l_source = new InputSource(l_fr);
0850: l_source.setEncoding(KeEnvironment
0851: .pcmf_getCharacterSet());
0852: pem_xmlReader.parse(l_source);
0853: l_fr.close();
0854: }
0855: ;
0856: } catch (SAXParseException se) {
0857: KeLog.pcmf_log("ug2t", "SAX parser Exception at [line: "
0858: + se.getLineNumber() + "] [col: "
0859: + se.getColumnNumber() + "] [file: "
0860: + KeEnvironment.pcmf_buildPath(xSource) + "]",
0861: this , KeLog.FATAL);
0862: }
0863:
0864: return;
0865: };
0866:
0867: public ScXmlScript(byte[] xSource) throws Exception {
0868: try {
0869: synchronized (pem_xmlReader) {
0870: pem_handler.pcmf_setxScript(this );
0871: ByteArrayInputStream l_stream = new ByteArrayInputStream(
0872: xSource);
0873: InputSource l_source = new InputSource(l_stream);
0874: l_source.setEncoding(KeEnvironment
0875: .pcmf_getCharacterSet());
0876: pem_xmlReader.parse(l_source);
0877: l_stream.close();
0878: }
0879: ;
0880: } catch (SAXParseException se) {
0881: KeLog.pcmf_log("ug2t",
0882: "SAX parser Exception at [line: "
0883: + se.getLineNumber()
0884: + "] [col: "
0885: + se.getColumnNumber()
0886: + "] [String: "
0887: + new InputSource(new ByteArrayInputStream(
0888: xSource)) + "]", this , KeLog.FATAL);
0889: }
0890:
0891: return;
0892: };
0893:
0894: public static String pcmf_filterSigns(String xString) {
0895: if (xString == null) {
0896: KeLog.pcmf_log("ug2t", "try to filter null string", null,
0897: KeLog.DEBUG);
0898: return (null);
0899: }
0900:
0901: byte l_target[] = new byte[xString.length() * 10];
0902: int l_tp = 0;
0903: int i = 0;
0904:
0905: for (; i < xString.length(); i++) {
0906: switch (xString.charAt(i)) {
0907: case '&':
0908: System.arraycopy(ScXmlScript.SUBST_AMP, 1, l_target,
0909: l_tp, ScXmlScript.SUBST_AMP[0]);
0910: l_tp += ScXmlScript.SUBST_AMP[0];
0911: break;
0912:
0913: case '<':
0914: System.arraycopy(ScXmlScript.SUBST_LT, 1, l_target,
0915: l_tp, ScXmlScript.SUBST_LT[0]);
0916: l_tp += ScXmlScript.SUBST_LT[0];
0917: break;
0918:
0919: case '>':
0920: System.arraycopy(ScXmlScript.SUBST_GT, 1, l_target,
0921: l_tp, ScXmlScript.SUBST_GT[0]);
0922: l_tp += ScXmlScript.SUBST_GT[0];
0923: break;
0924:
0925: case '\"':
0926: System.arraycopy(ScXmlScript.SUBST_Q1, 1, l_target,
0927: l_tp, ScXmlScript.SUBST_Q1[0]);
0928: l_tp += ScXmlScript.SUBST_Q1[0];
0929: break;
0930:
0931: case '\'':
0932: System.arraycopy(ScXmlScript.SUBST_Q2, 1, l_target,
0933: l_tp, ScXmlScript.SUBST_Q2[0]);
0934: l_tp += ScXmlScript.SUBST_Q2[0];
0935: break;
0936:
0937: case '\n':
0938: System.arraycopy(ScXmlScript.SUBST_CRLF, 1, l_target,
0939: l_tp, ScXmlScript.SUBST_CRLF[0]);
0940: l_tp += ScXmlScript.SUBST_CRLF[0];
0941: break;
0942:
0943: case '$':
0944: System.arraycopy(ScXmlScript.SUBST_DOL, 1, l_target,
0945: l_tp, ScXmlScript.SUBST_DOL[0]);
0946: l_tp += ScXmlScript.SUBST_DOL[0];
0947: break;
0948:
0949: case '\r':
0950: break;
0951:
0952: default:
0953: l_target[l_tp] = (byte) xString.charAt(i);
0954: l_tp += 1;
0955: }
0956: }
0957: return (new String(l_target, 0, l_tp));
0958: }
0959:
0960: public static String pcmf_filterSignsHTML(String xString) {
0961: byte l_target[] = new byte[xString.length() * 10];
0962: int l_tp = 0;
0963: int i = 0;
0964:
0965: for (; i < xString.length(); i++) {
0966: switch (xString.charAt(i)) {
0967: case '&':
0968: System.arraycopy(ScXmlScript.SUBST_AMP, 1, l_target,
0969: l_tp, ScXmlScript.SUBST_AMP[0]);
0970: l_tp += ScXmlScript.SUBST_AMP[0];
0971: break;
0972:
0973: case '<':
0974: System.arraycopy(ScXmlScript.SUBST_LT, 1, l_target,
0975: l_tp, ScXmlScript.SUBST_LT[0]);
0976: l_tp += ScXmlScript.SUBST_LT[0];
0977: break;
0978:
0979: case '>':
0980: System.arraycopy(ScXmlScript.SUBST_GT, 1, l_target,
0981: l_tp, ScXmlScript.SUBST_GT[0]);
0982: l_tp += ScXmlScript.SUBST_GT[0];
0983: break;
0984:
0985: case '\"':
0986: System.arraycopy(ScXmlScript.SUBST_Q1, 1, l_target,
0987: l_tp, ScXmlScript.SUBST_Q1[0]);
0988: l_tp += ScXmlScript.SUBST_Q1[0];
0989: break;
0990:
0991: case '\n':
0992: System.arraycopy(ScXmlScript.SUBST_CRLF, 1, l_target,
0993: l_tp, ScXmlScript.SUBST_CRLF[0]);
0994: l_tp += ScXmlScript.SUBST_CRLF[0];
0995: break;
0996:
0997: case '\r':
0998: break;
0999:
1000: default:
1001: l_target[l_tp] = (byte) xString.charAt(i);
1002: l_tp += 1;
1003: }
1004: }
1005: return (new String(l_target, 0, l_tp));
1006: }
1007:
1008: private static final KeStringTemplate T_XSCR_DTYPE = new KeStringTemplate(
1009: "<!DOCTYPE Parameter SYSTEM \"{$20}\">");
1010:
1011: public static String pcmf_extractLongProc(String xScript,
1012: String xProcName) {
1013: if (xProcName == null)
1014: xProcName = "Jmc_RMC";
1015:
1016: int l_pstart = xScript.indexOf(xProcName);
1017: if (l_pstart == -1)
1018: return (xScript);
1019:
1020: int l_start = l_pstart + xProcName.length() + 2;
1021: int l_end = xScript.indexOf("</Proc>", l_start);
1022:
1023: return (xScript.substring(l_start, l_end));
1024: }
1025:
1026: public static String pcmf_extractShortProc(String xScript,
1027: String xProcName) {
1028: if (xProcName == null)
1029: xProcName = "Jmc_RMC";
1030:
1031: int l_pstart = xScript.indexOf(xProcName);
1032: if (l_pstart == -1)
1033: return (xScript);
1034:
1035: int l_start = l_pstart + xProcName.length() + 2;
1036: int l_end = xScript.indexOf("</p>", l_start);
1037:
1038: return (xScript.substring(l_start, l_end));
1039: }
1040:
1041: public static void pcmf_createxScriptString(
1042: KeStringTemplateWrapper xString, String xDtd) {
1043: xString.pcm_string = new KeStringTemplate(
1044: ScXmlScript.T_XSCR_ENVELOP);
1045:
1046: if (xDtd == null)
1047: xString.pcm_string = KeTools.pcmf_stringSubst(
1048: xString.pcm_string, "$00", "");
1049: else {
1050: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1051: xString.pcm_string, "$00", new KeStringTemplate(
1052: T_XSCR_DTYPE));
1053: xString.pcm_string = KeTools.pcmf_stringSubst(
1054: xString.pcm_string, "$20", xDtd);
1055: }
1056: ;
1057:
1058: return;
1059: };
1060:
1061: public static void pcmf_endScript(KeStringTemplateWrapper xString) {
1062: xString.pcm_string = KeTools.pcmf_stringSubst(
1063: xString.pcm_string, "$01", "");
1064:
1065: return;
1066: };
1067:
1068: public static void pcmf_addProc(KeStringTemplateWrapper xString,
1069: String xProc) {
1070: if (xProc == null)
1071: xProc = "Jmc_RMC";
1072:
1073: xProc = pcmf_filterSigns(xProc);
1074:
1075: xString.pcm_string.pcmf_beginTR();
1076:
1077: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1078: xString.pcm_string, "$01", new KeStringTemplate(
1079: ScXmlScript.T_XSCR_PROC)
1080: .pcmf_stringAddVarEnd("$01"));
1081: xString.pcm_string = KeTools.pcmf_stringSubst(
1082: xString.pcm_string, "$02", xProc);
1083:
1084: xString.pcm_string.pcmf_endTR(true);
1085:
1086: return;
1087: };
1088:
1089: public static void pcmf_endProc(KeStringTemplateWrapper xString) {
1090: xString.pcm_string = KeTools.pcmf_stringSubst(
1091: xString.pcm_string, "$03", "");
1092: return;
1093: };
1094:
1095: private static final KeStringTemplate T_XSCR_OCTX = new KeStringTemplate(
1096: "c=\"{$40}\"");
1097:
1098: public static void pcmf_addDecl(KeStringTemplateWrapper xString,
1099: String xName, String xType, String xCtx) {
1100: if (xString.pcm_string.pcmf_isInTr()) {
1101: xString.pcm_string.pcmf_endTR(true);
1102: xString.pcm_string.pcmf_beginTR();
1103: } else
1104: xString.pcm_string.pcmf_beginTR();
1105:
1106: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1107: xString.pcm_string, "$03", new KeStringTemplate(
1108: ScXmlScript.T_XSCR_DECL_E)
1109: .pcmf_stringAddVarEnd("$03"));
1110: if (xCtx == null)
1111: xString.pcm_string = KeTools.pcmf_stringSubst(
1112: xString.pcm_string, "$06", "");
1113: else {
1114: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1115: xString.pcm_string, "$06", new KeStringTemplate(
1116: T_XSCR_OCTX));
1117: xString.pcm_string = KeTools.pcmf_stringSubst(
1118: xString.pcm_string, "$40", xCtx);
1119: }
1120: ;
1121: xString.pcm_string = KeTools.pcmf_stringSubst(
1122: xString.pcm_string, "$04", xName);
1123: xString.pcm_string = KeTools.pcmf_stringSubst(
1124: xString.pcm_string, "$05", xType);
1125:
1126: return;
1127: };
1128:
1129: public static void pcmf_endDecl(KeStringTemplateWrapper xString) {
1130: xString.pcm_string = KeTools.pcmf_stringSubst(
1131: xString.pcm_string, "$07", "");
1132:
1133: if (xString.pcm_string.pcmf_isInTr())
1134: xString.pcm_string.pcmf_endTR(true);
1135:
1136: return;
1137: };
1138:
1139: private static final KeStringTemplate T_XSCR_OTYPE = new KeStringTemplate(
1140: "t=\"{$50}\"");
1141:
1142: public static void pcmf_addDeclPar(KeStringTemplateWrapper xString,
1143: String xValue, String xIsObj, String xObjType) {
1144: xValue = pcmf_filterSigns(xValue);
1145:
1146: if (xString.pcm_string.pcmf_isInTr() == false)
1147: xString.pcm_string.pcmf_beginTR();
1148:
1149: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1150: xString.pcm_string, "$07", new KeStringTemplate(
1151: ScXmlScript.T_XSCR_DECL_P)
1152: .pcmf_stringAddVarEnd("$07"));
1153: if (xObjType == null)
1154: xString.pcm_string = KeTools.pcmf_stringSubst(
1155: xString.pcm_string, "$10", "");
1156: else {
1157: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1158: xString.pcm_string, "$10", new KeStringTemplate(
1159: T_XSCR_OTYPE));
1160: xString.pcm_string = KeTools.pcmf_stringSubst(
1161: xString.pcm_string, "$50", xObjType);
1162: }
1163: ;
1164: xString.pcm_string = KeTools.pcmf_stringSubst(
1165: xString.pcm_string, "$08", xValue);
1166: xString.pcm_string = KeTools.pcmf_stringSubst(
1167: xString.pcm_string, "$09", xIsObj);
1168:
1169: xString.pcm_string.pcmf_endTR(true);
1170:
1171: return;
1172: };
1173:
1174: public static void pcmf_createPBody(KeStringTemplateWrapper xString) {
1175: xString.pcm_string = new KeStringTemplate("{$03}");
1176:
1177: return;
1178: };
1179:
1180: public static void pcmf_endDeclPar(KeStringTemplateWrapper xString) {
1181: xString.pcm_string = KeTools.pcmf_stringSubst(
1182: xString.pcm_string, "$07", "");
1183:
1184: if (xString.pcm_string.pcmf_isInTr())
1185: xString.pcm_string.pcmf_endTR(true);
1186:
1187: return;
1188: };
1189:
1190: public static void pcmf_addPBody(KeStringTemplateWrapper xString,
1191: String xBody) {
1192: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1193: xString.pcm_string, "$03", xBody);
1194: xString.pcm_string.pcmf_stringAddVarEnd("$03");
1195:
1196: return;
1197: };
1198:
1199: public static void pcmf_addPBodyEnd(
1200: KeStringTemplateWrapper xString, String xBody) {
1201: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1202: xString.pcm_string, "$03", xBody);
1203:
1204: return;
1205: };
1206:
1207: private static final KeStringTemplate T_XSCR_RES = new KeStringTemplate(
1208: "result=\"{$RES}\"");
1209:
1210: public static void pcmf_addCall(KeStringTemplateWrapper xString,
1211: String xRes, String xObj, String xMethod) {
1212:
1213: if (xString.pcm_string.pcmf_isInTr()) {
1214: xString.pcm_string.pcmf_endTR(true);
1215: xString.pcm_string.pcmf_beginTR();
1216: } else
1217: xString.pcm_string.pcmf_beginTR();
1218:
1219: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1220: xString.pcm_string, "$03", new KeStringTemplate(
1221: ScXmlScript.T_XSCR_CALL_E)
1222: .pcmf_stringAddVarEnd("$03"));
1223:
1224: if (xRes == null)
1225: xString.pcm_string = KeTools.pcmf_stringSubst(
1226: xString.pcm_string, "$11", "");
1227: else {
1228: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1229: xString.pcm_string, "$11", new KeStringTemplate(
1230: T_XSCR_RES));
1231: xString.pcm_string = KeTools.pcmf_stringSubst(
1232: xString.pcm_string, "$RES", xRes);
1233: }
1234: ;
1235: xString.pcm_string = KeTools.pcmf_stringSubst(
1236: xString.pcm_string, "$12", xObj);
1237: xString.pcm_string = KeTools.pcmf_stringSubst(
1238: xString.pcm_string, "$13", xMethod);
1239:
1240: return;
1241: };
1242:
1243: public static void pcmf_endCall(KeStringTemplateWrapper xString) {
1244: xString.pcm_string = KeTools.pcmf_stringSubst(
1245: xString.pcm_string, "$14", "");
1246:
1247: if (xString.pcm_string.pcmf_isInTr())
1248: xString.pcm_string.pcmf_endTR(true);
1249:
1250: return;
1251: };
1252:
1253: public static void pcmf_addCallPar(KeStringTemplateWrapper xString,
1254: String xValue, String xIsObj, String xObjType) {
1255: xValue = pcmf_filterSigns(xValue);
1256:
1257: if (xString.pcm_string.pcmf_isInTr() == false)
1258: xString.pcm_string.pcmf_beginTR();
1259:
1260: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1261: xString.pcm_string, "$14", new KeStringTemplate(
1262: ScXmlScript.T_XSCR_CALL_P)
1263: .pcmf_stringAddVarEnd("$14"));
1264: if (xObjType == null)
1265: xString.pcm_string = KeTools.pcmf_stringSubst(
1266: xString.pcm_string, "$10", "");
1267: else {
1268: xString.pcm_string = KeTools.pcmf_stringSingleSubst(
1269: xString.pcm_string, "$10", new KeStringTemplate(
1270: T_XSCR_OTYPE));
1271: xString.pcm_string = KeTools.pcmf_stringSubst(
1272: xString.pcm_string, "$50", xObjType);
1273: }
1274: ;
1275: xString.pcm_string = KeTools.pcmf_stringSubst(
1276: xString.pcm_string, "$08", xValue);
1277: xString.pcm_string = KeTools.pcmf_stringSubst(
1278: xString.pcm_string, "$09", xIsObj);
1279:
1280: xString.pcm_string.pcmf_endTR(true);
1281:
1282: return;
1283: };
1284:
1285: public static void pcmf_endCallPar(KeStringTemplateWrapper xString) {
1286: xString.pcm_string = KeTools.pcmf_stringSubst(
1287: xString.pcm_string, "$14", "");
1288:
1289: if (xString.pcm_string.pcmf_isInTr())
1290: xString.pcm_string.pcmf_endTR(true);
1291:
1292: return;
1293: };
1294:
1295: public static void pcmf_endAll(KeStringTemplateWrapper xString) {
1296: ScXmlScript.pcmf_endDeclPar(xString);
1297: ScXmlScript.pcmf_endDecl(xString);
1298: ScXmlScript.pcmf_endCallPar(xString);
1299: ScXmlScript.pcmf_endCall(xString);
1300: ScXmlScript.pcmf_endProc(xString);
1301: ScXmlScript.pcmf_endScript(xString);
1302:
1303: return;
1304: };
1305:
1306: // ==========================================================
1307:
1308: public final void pcmf_addPrc(String xName, IScExecutable xProc) {
1309: this .pem_procs.put(xName, xProc);
1310:
1311: return;
1312: };
1313:
1314: public final Object pcmf_execProc(String xName) throws Exception {
1315: IScExecutable proc = null;
1316:
1317: proc = (IScExecutable) this .pem_procs.get(xName);
1318:
1319: return (proc.pcmf_exec(null, null));
1320: };
1321:
1322: public final Object pcmf_exec(ScXmlProcedure xCaller, Object xPar)
1323: throws Exception {
1324: IScExecutable proc = null;
1325:
1326: proc = (IScExecutable) this .pem_procs.get(xPar.toString());
1327:
1328: return (proc.pcmf_exec(xCaller, null));
1329: };
1330:
1331: public final Object pcmf_execObj(Object xObj) {
1332: IScExecutable proc = null;
1333: Object l_ret = null;
1334:
1335: try {
1336: proc = (IScExecutable) this .pem_procs.get(xObj.toString());
1337: l_ret = proc.pcmf_exec(null, null);
1338: } catch (Exception e) {
1339: KeLog.pcmf_logException("ug2t", this , e);
1340: }
1341: ;
1342:
1343: return (l_ret);
1344: };
1345:
1346: public final Object pcmf_addParam(String xParName, Attributes xAttr)
1347: throws Exception {
1348: IScExecutable newitem = null;
1349:
1350: if (xParName.equals("p") || xParName.equals("Proc")) {
1351: String pname = KeTools.pcmf_deRef(xAttr.getValue("n"));
1352: if (pname == null)
1353: pname = KeTools.pcmf_deRef(xAttr.getValue("name"));
1354:
1355: String preg = KeTools
1356: .pcmf_deRef(xAttr.getValue("register"));
1357:
1358: ScXmlProcedure proc = new ScXmlProcedure();
1359: if (preg != null && preg.equals("true")) {
1360: proc.pcmf_unRegister();
1361: proc.pcmf_register(pname);
1362: }
1363: ;
1364:
1365: this .pcmf_addPrc(pname, proc);
1366:
1367: newitem = proc;
1368:
1369: KeLog.pcmf_log("ug2t", "new xProc created: " + pname, this ,
1370: KeLog.TRACE);
1371: }
1372: ;
1373:
1374: return (newitem);
1375: };
1376:
1377: public final ScXmlProcedure pcmf_getProc(String xName) {
1378: return ((ScXmlProcedure) pem_procs.get(xName));
1379: };
1380:
1381: public void pcmf_delete() throws Exception {
1382: KeLog.pcmf_log("ug2t", "delete xScript: ", this , KeLog.TRACE);
1383: Iterator it = this .pem_procs.values().iterator();
1384:
1385: ScXmlProcedure l_proc = null;
1386: while (it.hasNext()) {
1387: l_proc = (ScXmlProcedure) it.next();
1388: l_proc.pcmf_delete();
1389: }
1390: ;
1391:
1392: return;
1393:
1394: };
1395:
1396: public void finalize() {
1397: try {
1398: KeLog.pcmf_log("ug2t", "finalize xScript: ", this ,
1399: KeLog.TRACE);
1400: this .pcmf_delete();
1401: } catch (Exception e) {
1402: KeLog.pcmf_logException("ug2t", this, e);
1403: }
1404: };
1405: };
|