本文整理汇总了Java中com.typesafe.config.ConfigUtil.quoteString方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigUtil.quoteString方法的具体用法?Java ConfigUtil.quoteString怎么用?Java ConfigUtil.quoteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.ConfigUtil
的用法示例。
在下文中一共展示了ConfigUtil.quoteString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalExtractURIQueryParams
import com.typesafe.config.ConfigUtil; //导入方法依赖的package包/类
private void internalExtractURIQueryParams(String paramName, String url, List expected, int maxParams) throws Exception {
String fileName = "test-morphlines/extractURIQueryParameters";
String overridesStr = "queryParam : " + ConfigUtil.quoteString(paramName);
if (maxParams >= 0) {
fileName += "WithMaxParameters";
overridesStr += "\nmaxParameters : " + maxParams;
}
Config override = ConfigFactory.parseString(overridesStr);
morphline = createMorphline(fileName, override);
Record record = new Record();
record.put("in", url);
Record expectedRecord = new Record();
expectedRecord.put("in", url);
expectedRecord.getFields().putAll("out", expected);
processAndVerifySuccess(record, expectedRecord);
}
示例2: setStringToConfig
import com.typesafe.config.ConfigUtil; //导入方法依赖的package包/类
/**
* Sets the String value for current configuration's variable to config.
*
* @param key
* The name of settings section.
* @param subKey
* The name of needed variable.
* @param value
* The value to set.
*/
private static void setStringToConfig(String key, String subKey, String newValue,
boolean hideValue) {
String fullPath = MAINKEY + "." + key + "." + subKey;
if (getString(key, subKey).equals(newValue)) {
String messageToLog = hideValue
? String.format("Setting secret configuration value. Key: %s.%s", key, subKey)
: String.format("Configuration value unchanged. Key: %s.%s Value: %s", key,
subKey, newValue);
logger.info(messageToLog);
return;
}
String processedNewValue = ConfigUtil.quoteString(newValue);
// Lets make new Config object with just a single variable.
// Also lets preserve the comments from the original Config.
ConfigOrigin or = conf.getValue(fullPath).origin();
StringBuilder toParse = new StringBuilder();
for (String comment : or.comments()) {
toParse.append("#").append(comment).append("\n");
}
toParse.append(fullPath).append("=").append(processedNewValue);
Config newLittleConfig = ConfigFactory.parseString(toParse.toString());
// Now we have our little Config with the single variable and old comments.
// Let's merge it with the old Config.
conf = newLittleConfig.withFallback(conf);
if (!hideValue) {
logger.info(String.format("Configuration update in RAM. Key: %s.%s Value: %s", key, subKey, newValue));
}
needsSave = true;
}
示例3: toJson
import com.typesafe.config.ConfigUtil; //导入方法依赖的package包/类
private String toJson(Object key) {
String str = key == null ? "" : key.toString();
str = ConfigUtil.quoteString(str);
return str;
}