本文整理汇总了Java中com.qmetry.qaf.automation.util.StringUtil.replace方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.replace方法的具体用法?Java StringUtil.replace怎么用?Java StringUtil.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.qmetry.qaf.automation.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: quoteParams
import com.qmetry.qaf.automation.util.StringUtil; //导入方法依赖的package包/类
public static String quoteParams(String call) {
String exp = "(\\s|^)\\$\\{[\\w\\.]*}(\\s|$)";
Pattern p = Pattern.compile(exp);
Matcher matcher = p.matcher(call);
String resultString = new String(call);
while (matcher.find()) {
for (int i = 0; i <= matcher.groupCount(); i++) {
String unQuatedparam = (matcher.group(i));
if (StringUtil.isNotBlank(unQuatedparam)) {
String quatedparam =
unQuatedparam.replace("${", "'${").replace("}", "}'");
resultString = new String(StringUtil.replace(new String(resultString),
unQuatedparam, quatedparam));
}
}
}
return resultString;
}
示例2: processArgs
import com.qmetry.qaf.automation.util.StringUtil; //导入方法依赖的package包/类
private String processArgs(String description, Object... actualArgs) {
if (null == actualArgs || actualArgs.length <= 0)
return description;
List<String> args = BDDDefinitionHelper.getArgNames(description);
if (args.isEmpty() || args.size() != actualArgs.length)
return description;
try {
for (int i = 0; i < actualArgs.length; i++) {
if ((actualArgs[i] instanceof String)) {
if (description.indexOf("$") >= 0) {
// If argument is already replaced
// like COMMENT: {0} replaced with COMMENT: '${uname}'
description = StringUtil.replace(description, "$" + args.get(i),
getParam((String) actualArgs[i]), 1);
} else {
// If argument is not processed
description = StringUtil.replace(description, args.get(i),
"'" + getParam((String) actualArgs[i]) + "'", 1);
}
} else {
description = StringUtil.replace(description, args.get(i),
"'" + String.valueOf(actualArgs[i]) + "'", 1);
}
}
} catch (Exception e) {
// ignore
}
return description;
}
示例3: getPattern
import com.qmetry.qaf.automation.util.StringUtil; //导入方法依赖的package包/类
private Pattern getPattern(String stepDescription) {
if (stepDescription.endsWith(":$")) {
String exp = "(.+)";
stepDescription = StringUtil.replace(stepDescription, ":$", ":" + exp + "$", 1);
}
return Pattern.compile(stepDescription, Pattern.CASE_INSENSITIVE);
}
示例4: format
import com.qmetry.qaf.automation.util.StringUtil; //导入方法依赖的package包/类
public static String format(String def, Object... objects) {
if (null == objects || objects.length <= 0)
return def;
List<String> args = getArgNames(def);
if (args.isEmpty() || args.size() != objects.length)
return def;
for (int i = 0; i < args.size(); i++) {
def = StringUtil.replace(def, args.get(i), "'" + String.valueOf(objects[i]) + "'", 1);
}
return def;
}
示例5: convertParam
import com.qmetry.qaf.automation.util.StringUtil; //导入方法依赖的package包/类
private String convertParam(String currLine) {
return StringUtil.replace(StringUtil.replace(currLine, ">", "}", -1), "<", "${",
-1);
}