⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staxlogaction.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 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.*;import java.text.*;public class STAXLogAction implements STAXAction{    public STAXLogAction()    { /* Do Nothing */ }    public STAXLogAction(String message, String level, int logfile)    {         fUnevalMessage = message;        fMessage = message;        fUnevalLevel = level;        fLevel = level;        fLogfile = logfile;    }    public STAXLogAction(String message, String level, String messageAttr,                         String ifAttr, int logfile)    {         fUnevalMessage = message;        fMessage = message;        fUnevalLevel = level;        fLevel = level;        fUnevalMessageAttr = messageAttr;        fUnevalIf = ifAttr;        fLogfile = logfile;    }    public String getMessage() { return fMessage; }     public void setMessage(String message)    {        fUnevalMessage = message;        fMessage = message;    }    public String getLevel() { return fLevel; }    public void setLevel(String level)    {         fUnevalLevel = level;        fLevel = level;    }    public boolean getMessageAttr() { return fMessageAttr; }    public void setMessageAttr(String messageAttr)    {        fUnevalMessageAttr = messageAttr;    }    public boolean getIf() { return fIf; }    public void setIf(String ifValue)    {         fUnevalIf = ifValue;    }    public int getLogfile() { return fLogfile; }     public void setLogfile(int logfile) { fLogfile = logfile; }    public String getXMLInfo()    {        StringBuffer info = new StringBuffer("<log");        if (!fUnevalLevel.equals("'info'"))            info.append(" level=\"").append(fUnevalLevel).append("\"");        if (!fUnevalMessageAttr.equals("STAXMessageLog"))            info.append(" message=\"").append(fUnevalMessageAttr).append("\"");        if (!fUnevalIf.equals("1"))            info.append(" if=\"").append(fUnevalIf).append("\"");        info.append(">").append(fUnevalMessage).append("</log>");        return info.toString();    }     public String getInfo()    {        int msgLength = fMessage.length();        if (msgLength > 40)            return fMessage.substring(0, 40) + "...";        else            return fMessage;    }     public String getDetails()    {        return "Level:" + fLevel +               ";Message:" + fMessage +               ";MessageAttr:" + fMessageAttr +               ";If:" + fIf +               ";Logfile:" + fLogfile;    }     public void execute(STAXThread thread)    {                 fThread = thread;                try        {            fIf = thread.pyBoolEval(fUnevalIf);                        if (!fIf)            {   // Ignore log element if "if" attribute evaluates to FALSE                fThread.popAction();                return;            }            fMessage = thread.pyStringEval(fUnevalMessage);            fLevel = thread.pyStringEval(fUnevalLevel);            fMessageAttr = thread.pyBoolEval(fUnevalMessageAttr);        }        catch (STAXPythonEvaluationException e)        {            fThread.popAction();            fThread.setSignalMsgVar("STAXPythonEvalMsg", getXMLInfo(), e);            fThread.raiseSignal("STAXPythonEvaluationError");            return;        }                if (fMessageAttr)        {            // Send a message to the STAXMonitor (via an event)            STAXTimestamp timestamp = new STAXTimestamp();            HashMap messageMap = new HashMap();            messageMap.put("messagetext", timestamp.getTimestampString() +                 " " + STAFUtil.maskPrivateData(fMessage));            fThread.getJob().generateEvent(                STAXMessageActionFactory.STAX_MESSAGE, messageMap);        }        // Log the message in the STAX Job User log        STAFResult result = fThread.getJob().log(fLogfile, fLevel, fMessage);        if (result.rc != 0 && result.rc != 2)        {             fThread.popAction();            String msg = getXMLInfo() + "\n" +                "\n  RC=" + result.rc +                "\n  Result=" + result.result;            fThread.setSignalMsgVar("STAXLogMsg", msg);            fThread.raiseSignal("STAXLogError");            return;        }                  fThread.popAction();    }    public void handleCondition(STAXThread thread, STAXCondition cond)    {        thread.popAction();    }    public STAXAction cloneAction()    {        STAXLogAction clone = new STAXLogAction();        clone.fUnevalMessage = fUnevalMessage;        clone.fMessage = fMessage;        clone.fUnevalLevel = fUnevalLevel;        clone.fLevel = fLevel;        clone.fUnevalMessageAttr = fUnevalMessageAttr;        clone.fMessageAttr = fMessageAttr;        clone.fUnevalIf = fUnevalIf;        clone.fIf = fIf;        clone.fLogfile = fLogfile;        return clone;    }       STAXThread fThread = null;        private String fUnevalMessage = new String();    private String fUnevalLevel = new String("'info'");    private String fUnevalMessageAttr = "STAXMessageLog";    private String fUnevalIf = "1";    private String fMessage = new String();    private String fLevel = new String();    private boolean fMessageAttr = false;    private boolean fIf = true;    private int fLogfile;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -