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

📄 timercmdparser.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    String name = res.result;    // Resolve the FREQUENCY option    res = STAFUtil.resolveRequestVarAndCheckInt(        FREQUENCY, pResult.optionValue(FREQUENCY),        fTimer.sHandle, info.requestNumber);    if (res.rc != 0) return res;    int frequency = Integer.parseInt(res.result);        // Get optional parameter if specified    if (pResult.numInstances() > 3)    {        // If KEY option is specified, get its value        if (pResult.optionTimes(KEY) == 1)        {            // Resolve the KEY option            res = STAFUtil.resolveRequestVar(                pResult.optionValue(KEY), fTimer.sHandle, info.requestNumber);            if (res.rc != 0) return res;            key = res.result;        }        // If priority option exists get value        if (pResult.optionTimes(PRIORITY) == 1)        {            res = STAFUtil.resolveRequestVarAndCheckInt(                PRIORITY, pResult.optionValue(PRIORITY),                fTimer.sHandle, info.requestNumber);            if (res.rc != 0) return res;            priority = Integer.parseInt(res.result);        }        // If unregOnNoPath option exists get value        if (pResult.optionTimes(UNREGONNOPATH) == 1)        {            res = STAFUtil.resolveRequestVarAndCheckInt(                UNREGONNOPATH, pResult.optionValue(UNREGONNOPATH),                fTimer.sHandle, info.requestNumber);            if (res.rc != 0) return res;                        unregOnNoPath = Integer.parseInt(res.result);        }        // If unregOnNoHandle option exists get value        if (pResult.optionTimes(UNREGONNOHANDLE) == 1)        {            res = STAFUtil.resolveRequestVarAndCheckInt(                UNREGONNOHANDLE, pResult.optionValue(UNREGONNOHANDLE),                fTimer.sHandle, info.requestNumber);            if (res.rc != 0) return res;            unregOnNoHandle = Integer.parseInt(res.result);        }        // If byname option specified register byname        if (pResult.optionTimes(BYNAME) == 1)        {            byname = true;        }    }    // Call Register request handler    return fTimer.reqHandler.register(        name, info.endpoint, info.handle, info.handleName, key,        frequency, priority, unregOnNoPath, unregOnNoHandle, byname);}/****************************************************************************///// Method://   parseUnregister//// Description://   This method parses parameters for the Unregister command.//// Input://   STAFServiceInterfaceLevel30 request information//   (including the submitting machine name, the submitting handle name,//    the submitting handle#, a string containing any command//    options & option values).//// Exceptions Thrown://   none//// Notes://   private method//   Trust level checking is done here because we must know the machine the//   timer is running on and the machine submitting the request.///****************************************************************************/private STAFResult parseUnregister(STAFServiceInterfaceLevel30.RequestInfo info){    // Verify the requester has at least trust level 3    STAFResult trustResult = STAFUtil.validateTrust(        3, fTimer.sServiceName, "UNREGISTER", fTimer.localMachine, info);        if (trustResult.rc != STAFResult.Ok) return trustResult;    // Parse the request    STAFCommandParseResult pResult = unregisterParser.parse(info.request);        if (pResult.rc != 0)    {        return new STAFResult(pResult.rc, pResult.errorBuffer);    }    // Set default values    int reqdTrustLevel = 3;    boolean byname = false;    String fMachine = info.endpoint;    int fHandle = info.handle;    String fHandleName = info.handleName;    String key = "";    STAFResult res = new STAFResult();        // Resolve the TYPE option        res = STAFUtil.resolveRequestVar(        pResult.optionValue(TYPE), fTimer.sHandle, info.requestNumber);    if (res.rc != 0) return res;    String name = res.result;    // Get optional parameters if specified    if (pResult.numInstances() > 2)    {        if (pResult.optionTimes(MACHINE) == 1)        {            // Resolve the MACHINE option            res = STAFUtil.resolveRequestVar(                pResult.optionValue(MACHINE), fTimer.sHandle,                info.requestNumber);            if (res.rc != 0) return res;            fMachine = res.result;            if (pResult.optionTimes(HANDLE) == 1)            {                // Resolve the HANDLE option                res = STAFUtil.resolveRequestVarAndCheckInt(                    HANDLE, pResult.optionValue(HANDLE),                    fTimer.sHandle, info.requestNumber);                if (res.rc != 0) return res;                fHandle = Integer.parseInt(res.result);            }            else            {                // Resolve the NAME option                res = STAFUtil.resolveRequestVar(                    pResult.optionValue(NAME), fTimer.sHandle,                    info.requestNumber);                if (res.rc != 0) return res;                fHandleName = res.result;                byname = true;            }        }        if (pResult.optionTimes(BYNAME) == 1)        {            // User specified BYNAME            byname = true;        }        // If KEY option is specified, get its value        if (pResult.optionTimes(KEY) == 1)        {            // Resolve the KEY option            res = STAFUtil.resolveRequestVar(                pResult.optionValue(KEY), fTimer.sHandle,                info.requestNumber);            if (res.rc != 0) return res;            key = res.result;        }    }    // Create proper timer string for timer to unregister    String tString;    if (byname)        tString = TimerUtils.createTimerString(name, fMachine, fHandleName, key);    else        tString = TimerUtils.createTimerString(name, fMachine, fHandle, key);    // Get the timer object, if it exists    TimerObject to = fTimer.reqHandler.getTimerObject(tString);        if (to != null)    {        // Verify the requester has at least trust level 4 if different        // machine than the one that previously registered the timer        if (!info.endpoint.equalsIgnoreCase(to.getMachine()))        {            trustResult = STAFUtil.validateTrust(                4, fTimer.sServiceName, "UNREGISTER", fTimer.localMachine, info);                if (trustResult.rc != STAFResult.Ok) return trustResult;        }    }        /* Call UnRegister request handler */    return fTimer.reqHandler.unregister(tString);}/****************************************************************************///// Method://   parseUnwatch//// Description://   This method parses parameters for the Unwatch command.//// Input://   STAFServiceInterfaceLevel30 request information//   (including the submitting machine name, the submitting handle name,//    the submitting handle#, a string containing any command//    options & option values).//// Exceptions Thrown://   none//// Notes://   private method//   Trust level checking is done here because we must know the machine the//   timer is running on and the machine submitting the request.///****************************************************************************/private STAFResult parseUnwatch(STAFServiceInterfaceLevel30.RequestInfo info){    // Verify the requester has at least trust level 4    STAFResult trustResult = STAFUtil.validateTrust(        4, fTimer.sServiceName, "UNWATCH", fTimer.localMachine, info);    if (trustResult.rc != STAFResult.Ok) return trustResult;    // Parse the request    STAFCommandParseResult pResult = unwatchParser.parse(info.request);    if (pResult.rc != 0)    {        return new STAFResult(pResult.rc, pResult.errorBuffer);    }        // Resolve the MACHINE option    STAFResult res = STAFUtil.resolveRequestVar(        pResult.optionValue(MACHINE), fTimer.sHandle, info.requestNumber);    if (res.rc != 0) return res;    String machineToWatch = res.result;    return fTimer.reqHandler.unwatch(machineToWatch);}/****************************************************************************///// Method://   parseWatch//// Description://   This method parses parameters for the Watch command.//// Input://   STAFServiceInterfaceLevel30 request information//   (including the submitting machine name, the submitting handle name,//    the submitting handle#, a string containing any command//    options & option values).//// Exceptions Thrown://   none//// Notes://   private method//   Trust level checking is done here because we must know the machine the//   timer is running on and the machine submitting the request.///****************************************************************************/private STAFResult parseWatch(STAFServiceInterfaceLevel30.RequestInfo info){    // Verify the requester has at least trust level 3    STAFResult trustResult = STAFUtil.validateTrust(        3, fTimer.sServiceName, "WATCH", fTimer.localMachine, info);    if (trustResult.rc != STAFResult.Ok) return trustResult;    // Parse the request    STAFCommandParseResult pResult = watchParser.parse(info.request);    if (pResult.rc != 0)    {        return new STAFResult(pResult.rc, pResult.errorBuffer);    }    // Initialize the values;    int margin = 0;    STAFResult res;    // Resolve the MACHINE option    res = STAFUtil.resolveRequestVar(        pResult.optionValue(MACHINE), fTimer.sHandle, info.requestNumber);    if (res.rc != 0) return res;    String machineToWatch = res.result;    // Resolve the FREQUENCY option    res = STAFUtil.resolveRequestVarAndCheckInt(        FREQUENCY, pResult.optionValue(FREQUENCY),        fTimer.sHandle, info.requestNumber);    if (res.rc != 0) return res;    int frequency = Integer.parseInt(res.result);    if (pResult.optionTimes(MARGIN) == 1)    {        // Resolve the MARGIN option        res = STAFUtil.resolveRequestVarAndCheckInt(            MARGIN, pResult.optionValue(MARGIN),            fTimer.sHandle, info.requestNumber);        if (res.rc != 0) return res;        margin = Integer.parseInt(res.result);    }    return fTimer.reqHandler.watch(machineToWatch, frequency, margin);}}

⌨️ 快捷键说明

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