本文整理了Java中org.sonar.api.config.Settings.getStringArrayBySeparator()
方法的一些代码示例,展示了Settings.getStringArrayBySeparator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getStringArrayBySeparator()
方法的具体详情如下:
包路径:org.sonar.api.config.Settings
类名称:Settings
方法名:getStringArrayBySeparator
[英]Value is split and trimmed.
[中]值被拆分和修剪。
代码示例来源:origin: SonarSource/sonarqube
/**
* Value is split by comma and trimmed. Never returns null.
* <br>
* Examples :
* <ul>
* <li>"one,two,three " -> ["one", "two", "three"]</li>
* <li>" one, two, three " -> ["one", "two", "three"]</li>
* <li>"one, , three" -> ["one", "", "three"]</li>
* </ul>
*/
public String[] getStringArray(String key) {
String effectiveKey = definitions.validKey(key);
Optional<PropertyDefinition> def = getDefinition(effectiveKey);
if ((def.isPresent()) && (def.get().multiValues())) {
String value = getString(key);
if (value == null) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
List<String> values = new ArrayList<>();
for (String v : Splitter.on(",").trimResults().split(value)) {
values.add(v.replace("%2C", ","));
}
return values.toArray(new String[values.size()]);
}
return getStringArrayBySeparator(key, ",");
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
/**
* Value is split by comma and trimmed. Never returns null.
* <p/>
* Examples :
* <ul>
* <li>"one,two,three " -> ["one", "two", "three"]</li>
* <li>" one, two, three " -> ["one", "two", "three"]</li>
* <li>"one, , three" -> ["one", "", "three"]</li>
* </ul>
*/
public String[] getStringArray(String key) {
PropertyDefinition property = getDefinitions().get(key);
if ((null != property) && (property.multiValues())) {
String value = getString(key);
if (value == null) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
List<String> values = Lists.newArrayList();
for (String v : Splitter.on(",").trimResults().split(value)) {
values.add(v.replace("%2C", ","));
}
return values.toArray(new String[values.size()]);
}
return getStringArrayBySeparator(key, ",");
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
/**
* Value is split by comma and trimmed. Never returns null.
* <br>
* Examples :
* <ul>
* <li>"one,two,three " -> ["one", "two", "three"]</li>
* <li>" one, two, three " -> ["one", "two", "three"]</li>
* <li>"one, , three" -> ["one", "", "three"]</li>
* </ul>
*/
public String[] getStringArray(String key) {
String effectiveKey = definitions.validKey(key);
Optional<PropertyDefinition> def = getDefinition(effectiveKey);
if ((def.isPresent()) && (def.get().multiValues())) {
String value = getString(key);
if (value == null) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
List<String> values = new ArrayList<>();
for (String v : Splitter.on(",").trimResults().split(value)) {
values.add(v.replace("%2C", ","));
}
return values.toArray(new String[values.size()]);
}
return getStringArrayBySeparator(key, ",");
}
内容来源于网络,如有侵权,请联系作者删除!