本文整理了Java中org.sonar.api.config.Settings.getStringArray()
方法的一些代码示例,展示了Settings.getStringArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getStringArray()
方法的具体详情如下:
包路径:org.sonar.api.config.Settings
类名称:Settings
方法名:getStringArray
[英]Value is split by comma and trimmed. Never returns null.
Examples :
代码示例来源:origin: SonarSource/sonarqube
@Override
public String[] getStringArray(String key) {
return settings.getStringArray(key);
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public String[] getFileSuffixes() {
return Arrays.stream(settings.getStringArray(FILE_SUFFIXES_KEY)).filter(s -> s != null && !s.trim().isEmpty()).toArray(String[]::new);
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void should_load_values_of_deprecated_key() {
Settings settings = new MapSettings(definitions);
settings.setProperty("oldKey", "a,b");
assertThat(settings.getStringArray("newKey")).containsOnly("a", "b");
assertThat(settings.getStringArray("oldKey")).containsOnly("a", "b");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void should_support_deprecated_props_with_multi_values() {
Settings settings = new MapSettings(definitions);
settings.setProperty("new_multi_values", new String[] {" A ", " B "});
assertThat(settings.getStringArray("new_multi_values")).isEqualTo(new String[] {"A", "B"});
assertThat(settings.getStringArray("old_multi_values")).isEqualTo(new String[] {"A", "B"});
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void getStringArray() {
Settings settings = new MapSettings(definitions);
String[] array = settings.getStringArray("array");
assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void getStringArray_no_value() {
Settings settings = new MapSettings();
String[] array = settings.getStringArray("array");
assertThat(array).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void setStringArray() {
Settings settings = new MapSettings(definitions);
settings.setProperty("multi_values", new String[] {"A", "B"});
String[] array = settings.getStringArray("multi_values");
assertThat(array).isEqualTo(new String[] {"A", "B"});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void setStringArrayEscapeCommas() {
Settings settings = new MapSettings(definitions);
settings.setProperty("multi_values", new String[] {"A,B", "C,D"});
String[] array = settings.getStringArray("multi_values");
assertThat(array).isEqualTo(new String[] {"A,B", "C,D"});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void setStringArrayWithEmptyValues() {
Settings settings = new MapSettings(definitions);
settings.setProperty("multi_values", new String[] {"A,B", "", "C,D"});
String[] array = settings.getStringArray("multi_values");
assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void setStringArrayTrimValues() {
Settings settings = new MapSettings(definitions);
settings.setProperty("multi_values", new String[] {" A ", " B "});
String[] array = settings.getStringArray("multi_values");
assertThat(array).isEqualTo(new String[] {"A", "B"});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldKeepEmptyValuesWhenSplitting() {
Settings settings = new MapSettings();
settings.setProperty("foo", " one, , two");
String[] array = settings.getStringArray("foo");
assertThat(array).isEqualTo(new String[] {"one", "", "two"});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void setStringArrayWithNullValues() {
Settings settings = new MapSettings(definitions);
settings.setProperty("multi_values", new String[] {"A,B", null, "C,D"});
String[] array = settings.getStringArray("multi_values");
assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void shouldTrimArray() {
Settings settings = new MapSettings();
settings.setProperty("foo", " one, two, three ");
String[] array = settings.getStringArray("foo");
assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
}
代码示例来源:origin: racodond/sonar-css-plugin
@Override
public String[] getFileSuffixes() {
String[] suffixes = settings.getStringArray(Plugin.LESS_FILE_SUFFIXES_KEY);
if (suffixes == null || suffixes.length == 0) {
suffixes = StringUtils.split(Plugin.LESS_FILE_SUFFIXES_DEFAULT_VALUE, ",");
}
return suffixes;
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
private String[] inclusions(String propertyKey) {
String[] patterns = sanitize(settings.getStringArray(propertyKey));
List<String> list = Lists.newArrayList();
for (String pattern : patterns) {
if (!"**/*".equals(pattern) && !"file:**/*".equals(pattern)) {
list.add(pattern);
}
}
return list.toArray(new String[list.size()]);
}
代码示例来源:origin: octo-technology/sonar-objective-c
public String[] getFileSuffixes() {
String[] suffixes = filterEmptyStrings(settings.getStringArray(ObjectiveCPlugin.FILE_SUFFIXES_KEY));
if (suffixes == null || suffixes.length == 0) {
suffixes = StringUtils.split(ObjectiveCPlugin.FILE_SUFFIXES_DEFVALUE, ",");
}
return suffixes;
}
代码示例来源:origin: org.codehaus.sonar-plugins.xml/sonar-xml-plugin
/**
* {@inheritDoc}
*/
public String[] getFileSuffixes() {
String[] suffixes = filterEmptyStrings(settings.getStringArray(XmlPlugin.FILE_SUFFIXES_KEY));
if (suffixes.length == 0) {
suffixes = Xml.DEFAULT_SUFFIXES;
}
return suffixes;
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
private String[] exclusions(String globalExclusionsProperty, String exclusionsProperty) {
String[] globalExclusions = settings.getStringArray(globalExclusionsProperty);
String[] exclusions = settings.getStringArray(exclusionsProperty);
return sanitize(ObjectArrays.concat(globalExclusions, exclusions, String.class));
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch
@VisibleForTesting
final void initPatterns() {
Builder<WildcardPattern> builder = ImmutableList.builder();
for (String pattern : settings.getStringArray(CoreProperties.PROJECT_COVERAGE_EXCLUSIONS_PROPERTY)) {
builder.add(WildcardPattern.create(pattern));
}
resourcePatterns = builder.build();
log("Excluded sources for coverage: ", resourcePatterns);
}
代码示例来源:origin: org.sonarsource.sonar-plugins.javascript/javascript-squid
public TypeVisitor(@Nullable Settings settings) {
if (settings == null) {
jQueryHelper = new JQuery(JQuery.JQUERY_OBJECT_ALIASES_DEFAULT_VALUE.split(", "));
} else {
jQueryHelper = new JQuery(settings.getStringArray(JQuery.JQUERY_OBJECT_ALIASES));
}
}
内容来源于网络,如有侵权,请联系作者删除!