當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtil.replace方法代碼示例

本文整理匯總了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;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:19,代碼來源:BDDDefinitionHelper.java

示例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;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:30,代碼來源:TestStepListener.java

示例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);
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:8,代碼來源:BDDStepMatcherFactory.java

示例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;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:14,代碼來源:BDDDefinitionHelper.java

示例5: convertParam

import com.qmetry.qaf.automation.util.StringUtil; //導入方法依賴的package包/類
private String convertParam(String currLine) {

		return StringUtil.replace(StringUtil.replace(currLine, ">", "}", -1), "<", "${",
				-1);
	}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:6,代碼來源:GherkinFileParser.java


注:本文中的com.qmetry.qaf.automation.util.StringUtil.replace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。