📄 staxcatchaction.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;public class STAXCatchAction implements STAXAction{ private static final int INIT = 0; private static final int CALLED_ACTION = 1; private static final int COMPLETE = 2; private static final String INIT_STRING = "INIT"; private static final String CALLED_ACTION_STRING = "CALLED_ACTION"; private static final String COMPLETE_STRING = "COMPLETE"; private static final String STATE_UNKNOWN_STRING = "UNKNOWN"; private STAXCatchAction() { /* Do Nothing */ } public STAXCatchAction(String exceptionName, String varName, String typeVarName, STAXAction action) { fExceptionName = exceptionName; fVarName = varName; fTypeVarName = typeVarName; fAction = action; } public String getCatchableExceptionName() { return fExceptionName; } public void setException(STAXExceptionCondition cond) { fThrownException = cond; } public String getStateAsString() { switch (fState) { case INIT: return INIT_STRING; case CALLED_ACTION: return CALLED_ACTION_STRING; case COMPLETE: return COMPLETE_STRING; default: return STATE_UNKNOWN_STRING; } } public String getInfo() { return fExceptionName; } public String getDetails() { return "State:" + getStateAsString() + ";ExceptionName:" + fExceptionName + ";VarName:" + fVarName + ";TypeVarName:" + fTypeVarName + ";Action:" + fAction + ";ExceptionCondition:" + fThrownException; } public void execute(STAXThread thread) { if (fState == INIT) { if (fVarName != null) thread.pySetVar(fVarName, fThrownException.getData()); if (fTypeVarName != null) thread.pySetVar(fTypeVarName, fThrownException.getName()); thread.pushAction(fAction.cloneAction()); fState = CALLED_ACTION; } else { fState = COMPLETE; thread.popAction(); } } public void handleCondition(STAXThread thread, STAXCondition cond) { fState = COMPLETE; thread.popAction(); if (cond instanceof STAXRethrowExceptionCondition) { thread.removeCondition(cond); thread.addCondition(fThrownException); } } public STAXAction cloneAction() { return new STAXCatchAction(fExceptionName, fVarName, fTypeVarName, fAction); } private int fState = INIT; private String fExceptionName; private String fVarName; private String fTypeVarName; private STAXAction fAction; private STAXExceptionCondition fThrownException;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -