org.sonar.api.config.Settings.getStringArrayBySeparator()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.sonar.api.config.Settings.getStringArrayBySeparator()方法的一些代码示例,展示了Settings.getStringArrayBySeparator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getStringArrayBySeparator()方法的具体详情如下:
包路径:org.sonar.api.config.Settings
类名称:Settings
方法名:getStringArrayBySeparator

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 " -&gt; ["one", "two", "three"]</li>
 * <li>"  one, two, three " -&gt; ["one", "two", "three"]</li>
 * <li>"one, , three" -&gt; ["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 " -&gt; ["one", "two", "three"]</li>
 * <li>"  one, two, three " -&gt; ["one", "two", "three"]</li>
 * <li>"one, , three" -&gt; ["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, ",");
}

相关文章