📄 staximportaction.java
字号:
} } } } // process required functions for (int rf = 0; rf < fRequiredFunctions.size(); rf++) { addRequiredFunctions((String)fRequiredFunctions.elementAt(rf)); } // handle any non-"*" functions that were not found for (int im = 0; im < importList.size(); im++) { if ((importList.elementAt(im).toString()).indexOf("*") == -1) { if (!(fFunctionMap.containsKey(importList.elementAt(im).toString())) && !(excludeList.contains(importList.elementAt(im)))) { fFunctionListDoesNotExist.add( importList.elementAt(im).toString()); } } } STAXResult += "["; STAXResult += "None"; STAXResult += ","; STAXResult += createListString(fFunctionListImportedRequested) + ","; STAXResult += createListString(fFunctionListImportedRequired) + ","; STAXResult += createListString(fFunctionListExistingRequested) + ","; STAXResult += createListString(fFunctionListExistingRequired) + ","; STAXResult += createListString( fFunctionListNotRequestedNotRequired) + ","; STAXResult += createListString(fFunctionListDoesNotExist); STAXResult += "]"; PyObject resultObject = fThread.pyObjectEval(STAXResult); fThread.pySetVar("STAXResult", resultObject); } catch (STAXPythonEvaluationException ex) { fThread.popAction(); fThread.setSignalMsgVar("STAXPythonEvalMsg", getXMLInfo(), ex); fThread.raiseSignal("STAXPythonEvaluationError"); return; } catch (STAXXMLParseException ex) { handleParserException(ex); return; } catch (STAXException ex) { handleParserException(ex); return; } catch (SAXNotRecognizedException ex) { handleParserException(ex); return; } catch (SAXNotSupportedException ex) { handleParserException(ex); return; } // do something fThread.popAction(); } public void handleParserException(Exception ex) { fThread.popAction(); // Create a PyList containing "STAXXMLParseError" and the // parser exception string. PyList errorData = new PyList(); errorData.append(new PyString("STAXXMLParseError")); errorData.append(new PyString(fFile + ": " + ex.toString())); if (fMode.equals(kError)) { String errorDataStr = "[STAXXMLParseError, r'" + fFile + ": " + ex.toString().replace('\n', ' ') + "']"; try { PyObject signalData = fThread.pyObjectEval(errorDataStr); fThread.pySetVar("STAXSignalData", signalData); } catch (STAXPythonEvaluationException e) { // XXX: Should never happen System.out.println("fThread.pyObjectEval failed for: " + errorDataStr + "\n" + e.toString()); fThread.pySetVar("STAXSignalData", errorData); } fThread.setSignalMsgVar("STAXImportErrorMsg", errorData.toString()); fThread.raiseSignal("STAXImportError"); } else { // Create STAXResult as a list with errorData as its first // element and with empty lists for its next 6 elements: // STAXResult = [ errorData,[],[],[],[],[],[] ] PyList resultList = new PyList(); PyList emptyList = new PyList(); resultList.append(errorData); for (int i = 1; i < 7; ++i) resultList.append(emptyList); fThread.pySetVar("STAXResult", resultList); } } public String createListString(ArrayList list) { String listString = "["; Iterator listIter = list.iterator(); while (listIter.hasNext()) { if (listString.equals("[")) { listString += "'" + listIter.next() + "'"; } else { listString += ",'" + listIter.next() + "'"; } } listString += "]"; return listString; } public void addRequiredFunctions(String currentFunction) { if (!(fThread.getJob().functionExists(currentFunction))) { STAXFunctionAction function = (STAXFunctionAction)fFunctionMap.get(currentFunction); fThread.getJob().addFunction(function); fFunctionListImportedRequired.add(currentFunction); fFunctionListNotRequestedNotRequired.remove(currentFunction); StringTokenizer requiredFunctions = new StringTokenizer(function.getRequires(), " "); while (requiredFunctions.hasMoreElements()) { addRequiredFunctions((String)requiredFunctions.nextElement()); } } else { if (!(fFunctionListExistingRequired.contains(currentFunction)) && !(fFunctionListImportedRequired.contains(currentFunction))) { fFunctionListExistingRequired.add(currentFunction); } } } public void handleCondition(STAXThread thread, STAXCondition cond) { thread.popAction(); } public STAXAction cloneAction() { STAXImportAction clone = new STAXImportAction(); clone.fUnevalMachine = fUnevalMachine; clone.fMachine = fMachine; clone.fUnevalFile = fUnevalFile; clone.fFile = fFile; clone.fUnevalMode = fUnevalMode; clone.fMode = fMode; clone.fUnevalImportInclude = fUnevalImportInclude; clone.fUnevalImportExclude = fUnevalImportExclude; clone.fImportInclude = fImportInclude; clone.fImportExclude = fImportExclude; return clone; } private boolean grepMatch(String targetString, String matchString) throws STAXPythonEvaluationException { return fThread.pyBoolEval("re.match('" + matchString + "', '" + targetString + "')"); } private boolean checkForMatch(HashMap functionMap, String function, Vector excludeList) throws STAXPythonEvaluationException { boolean excludeMatch = false; boolean included = false; for (int ex = 0; ex < excludeList.size(); ex++) { if (grepMatch(function, excludeList.elementAt(ex).toString())) { excludeMatch = true; } } if (!excludeMatch) { handleFunctionImport(functionMap, function); included = true; } else { if (!(fFunctionListNotRequestedNotRequired.contains(function))) { fFunctionListNotRequestedNotRequired.add(function); } } return included; } private void handleFunctionImport(HashMap functionMap, String functionToImport) { STAXFunctionAction function = (STAXFunctionAction)functionMap.get(functionToImport); StringTokenizer requiredFunctions = new StringTokenizer(function.getRequires(), " "); while (requiredFunctions.hasMoreElements()) { fRequiredFunctions.add(requiredFunctions.nextElement()); } if (!(fThread.getJob().functionExists(functionToImport))) { // add the function fThread.getJob().addFunction(function); fFunctionListImportedRequested.add(functionToImport); } else { // function already exists or has already been imported fFunctionListExistingRequested.add(functionToImport); } } STAXThread fThread = null; private String fUnevalMachine = new String(); private String fMachine = new String(); private String fUnevalFile = new String(); private String fFile = new String(); private String fUnevalMode = new String(); private String fMode = new String(); private String fUnevalImportInclude = new String(); private String fUnevalImportExclude = new String(); private String fImportInclude = new String(); private String fImportExclude = new String(); private ArrayList fFunctionListDoesNotExist; private ArrayList fFunctionListNotRequestedNotRequired; private ArrayList fFunctionListImportedRequested; private ArrayList fFunctionListImportedRequired; private ArrayList fFunctionListExistingRequested; private ArrayList fFunctionListExistingRequired; private Vector fRequiredFunctions = new Vector(); private HashMap fFunctionMap;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -