前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >JMeter5.1核心类ReplaceStringWithFunctions源码分析

JMeter5.1核心类ReplaceStringWithFunctions源码分析

原创
作者头像
天堂小说
发布2021-12-03 16:53:07
4520
发布2021-12-03 16:53:07
举报
文章被收录于专栏:JMeter源码分析JMeter源码分析

概述

ReplaceStringWithFunctions,顾名思义,是将字符串转换为function。

ReplaceStringWithFunctions类继承AbstractTransformer类。

AbstractTransformer类有两个成员变量

代码语言:txt
复制
    // 参数替换的处理类
    private CompoundVariable masterFunction;
    // 存放变量的类
    private Map<String, String> variables

ReplaceStringWithFunctions源码分析

构造函数

代码语言:txt
复制
    public ReplaceStringWithFunctions(CompoundVariable masterFunction, Map<String, String> variables) {
        super();
        // 调用父类的两个方法
        setMasterFunction(masterFunction);
        setVariables(variables);
    }

transformValue

执行变量和内置函数转换功能

代码语言:txt
复制
    public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
        JMeterProperty newValue = prop;
        // 清除CompoundVariable类的数据
        getMasterFunction().clear();
        // 参数替换操作
        getMasterFunction().setParameters(prop.getStringValue());
        // 包含变量参数或者内置函数
        if (getMasterFunction().hasFunction()) {
            newValue = new FunctionProperty(prop.getName(), getMasterFunction().getFunction());
        }
        return newValue;
    }

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
目录
  • 概述
  • ReplaceStringWithFunctions源码分析
    • 构造函数
      • transformValue
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档