📄 staxfunctionaction.java
字号:
/****************************************************************************//* Software Testing Automation Framework (STAF) *//* (C) Copyright IBM Corp. 2002 *//* *//* This software is licensed under the Common Public License (CPL) V1.0. *//*****************************************************************************/package com.ibm.staf.service.stax;import com.ibm.staf.*;import java.util.Arrays;import java.util.ArrayList;import java.util.ListIterator;import java.util.List;import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.LinkedList;import java.util.Hashtable;import java.util.Map;import java.util.Iterator;import org.python.util.PythonInterpreter;import org.python.core.*;public class STAXFunctionAction implements STAXAction{ static final int INIT = 0; static final int FUNCTION_CALLED = 1; static final int COMPLETE = 2; static final String INIT_STRING = "INIT"; static final String FUNCTION_CALLED_STRING = "FUNCTION_CALLED"; static final String COMPLETE_STRING = "COMPLETE"; static final String STATE_UNKNOWN_STRING = "UNKNOWN"; // Function Argument Definitions public static final int FUNCTION_DEFINES_NO_ARGS = 0; public static final int FUNCTION_ALLOWS_NO_ARGS = 1; public static final int FUNCTION_DEFINES_ONE_ARG = 2; public static final int FUNCTION_DEFINES_LIST_ARGS = 3; public static final int FUNCTION_DEFINES_MAP_ARGS = 4; public static final String FUNCTION_DEFINES_NO_ARGS_STRING = "FUNCTION_DEFINES_NO_ARGS"; public static final String FUNCTION_ALLOWS_NO_ARGS_STRING = "FUNCTION_ALLOWS_NO_ARGS"; public static final String FUNCTION_DEFINES_ONE_ARG_STRING = "FUNCTION_DEFINES_ONE_ARG"; public static final String FUNCTION_DEFINES_LIST_ARGS_STRING = "FUNCTION_DEFINES_LIST_ARGS"; public static final String FUNCTION_DEFINES_MAP_ARGS_STRING = "FUNCTION_DEFINES_MAP_ARGS"; public static final String FUNCTION_DEFINES_UNKNOWN_ARGS_STRING = "FUNCTION_DEFINES_UNKNOWN_ARGS"; // Types of Function Arguments public static final int ARG_REQUIRED = 1; public static final int ARG_OPTIONAL = 2; public static final int ARG_OTHER = 3; public static final String ARG_REQUIRED_STRING = "ARG_REQUIRED"; public static final String ARG_OPTIONAL_STRING = "ARG_OPTIONAL"; public static final String ARG_OTHER_STRING = "ARG_OTHER"; public STAXFunctionAction() { /* Do Nothing */ } public STAXFunctionAction(String name, String prolog, String epilog, String scope, String requires, STAXAction action) { fName = name; fProlog = prolog; fEpilog = epilog; fScope = scope; fRequires = requires; fAction = action; } public String getName() { return fName; } public void setName(String name) { fName = name; } public String getProlog() { return fProlog; } public void setProlog(String prolog) { fProlog = prolog; } public String getEpilog() { return fEpilog; } public void setEpilog(String epilog) { fEpilog = epilog; } public String getScope() { return fScope; } public void setScope(String scope) { fScope = scope; } public STAXAction getAction() { return fAction; } public void setAction(STAXAction action) { fAction = action; } public int getArgDefinition() { return fArgDefinition; } public void setArgDefinition(int def) { fArgDefinition = def; } public ArrayList getArgList() { return fArgList; } public void addArg(STAXFunctionArgument arg) { fArgList.add(arg); } public PyObject getCallArgs() { return fCallArgPyObject; } public void setCallArgs(PyObject args) { fCallArgPyObject = args; } public String getCallXMLInfo() { return fCallXMLInfo; } public void setCallXMLInfo(String info) { fCallXMLInfo = info; } public String getRequires() { return fRequires; } public void setRequires(String requires) { fRequires = requires; } public String getStateAsString() { switch (fState) { case INIT: return INIT_STRING; case FUNCTION_CALLED: return FUNCTION_CALLED_STRING; case COMPLETE: return COMPLETE_STRING; default: return STATE_UNKNOWN_STRING; } } public String getArgDefinitionAsString() { switch (fArgDefinition) { case FUNCTION_DEFINES_NO_ARGS: return FUNCTION_DEFINES_NO_ARGS_STRING; case FUNCTION_ALLOWS_NO_ARGS: return FUNCTION_ALLOWS_NO_ARGS_STRING; case FUNCTION_DEFINES_ONE_ARG: return FUNCTION_DEFINES_ONE_ARG_STRING; case FUNCTION_DEFINES_LIST_ARGS: return FUNCTION_DEFINES_LIST_ARGS_STRING; case FUNCTION_DEFINES_MAP_ARGS: return FUNCTION_DEFINES_MAP_ARGS_STRING; default: return FUNCTION_DEFINES_UNKNOWN_ARGS_STRING; } } public String getArgTypeAsString(int type) { switch (type) { case ARG_REQUIRED: return ARG_REQUIRED_STRING; case ARG_OPTIONAL: return ARG_OPTIONAL_STRING; case ARG_OTHER: return ARG_OTHER_STRING; default: return ARG_OTHER_STRING; } } public Map getArgumentInfo(STAFMapClassDefinition functionInfoMapClass, STAFMapClassDefinition argInfoMapClass, STAFMapClassDefinition argPropertyInfoMapClass, STAFMapClassDefinition argPropertyDataInfoMapClass) { Map functionMap = functionInfoMapClass.createInstance(); functionMap.put("functionName", fName); functionMap.put("prolog", fProlog); functionMap.put("epilog", fEpilog); functionMap.put("argDefinition", this.getArgDefinitionAsString()); List argOutputList = new ArrayList(); for (int i = 0; i < fArgList.size(); i++) { STAXFunctionArgument arg = (STAXFunctionArgument)fArgList.get(i); Map argMap = argInfoMapClass.createInstance(); argMap.put("argName", arg.getName()); argMap.put("description", arg.getDescription()); if (arg.getPrivate() == true) argMap.put("private", "Yes"); else argMap.put("private", "No"); List argPropertyOutputList = new ArrayList(); LinkedList properties = arg.getProperties(); Iterator iter = properties.iterator(); while (iter.hasNext()) { Map propertyMap = argPropertyInfoMapClass.createInstance(); STAXFunctionArgumentProperty property = (STAXFunctionArgumentProperty)iter.next(); propertyMap.put("propertyName", property.getName()); if (property.getDescription().equals("")) { propertyMap.put("propertyDescription", "<None>"); } else { propertyMap.put("propertyDescription", property.getDescription()); } if (property.getValue().equals("")) { propertyMap.put("propertyValue", "<None>"); } else { propertyMap.put("propertyValue", property.getValue()); } List argPropertyDataOutputList = handlePropertyData(property.getData(), argPropertyDataInfoMapClass); propertyMap.put("propertyData", argPropertyDataOutputList); argPropertyOutputList.add(propertyMap); } argMap.put("properties", argPropertyOutputList); int argType = arg.getType(); if (argType == ARG_REQUIRED) { argMap.put("type", ARG_REQUIRED_STRING); } else if (argType == ARG_OPTIONAL) { argMap.put("type", ARG_OPTIONAL_STRING); argMap.put("defaultValue", arg.getDefaultValue()); } else { argMap.put("type", ARG_OTHER_STRING); } argOutputList.add(argMap); } functionMap.put("argList", argOutputList); return functionMap; } public List handlePropertyData(LinkedList data, STAFMapClassDefinition argPropertyDataInfoMapClass) { List argPropertyDataOutputList = new ArrayList(); Iterator iter = data.iterator(); while (iter.hasNext()) { Map propertyDataMap = argPropertyDataInfoMapClass.createInstance(); STAXFunctionArgumentPropertyData propertyData = (STAXFunctionArgumentPropertyData)iter.next(); propertyDataMap.put("dataType", propertyData.getType()); if (propertyData.getValue().equals("")) { propertyDataMap.put("dataValue", "<None>"); } else { propertyDataMap.put("dataValue", propertyData.getValue()); } LinkedList dataData = propertyData.getData(); List argDataDataOutputList = new ArrayList(); if (!(dataData.isEmpty())) { argDataDataOutputList = handlePropertyData(dataData, argPropertyDataInfoMapClass); } propertyDataMap.put("dataData", argDataDataOutputList);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -