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

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

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

Settings.getProperties介绍

[英]Immutable map of the properties that have non-default values. The default values defined by PropertyDefinitions are ignored, so the returned values are not the effective values. Basically only the non-empty results of #getRawString(String) are returned.

Values are not decrypted if they are encrypted with a secret key.
[中]具有非默认值的属性的不可变映射。将忽略PropertyDefinitions定义的默认值,因此返回的值不是有效值。基本上只返回#getRawString(String)的非空结果。
如果值是用密钥加密的,则不会解密。

代码示例

代码示例来源:origin: SonarSource/sonarqube

public List<String> getKeysStartingWith(String prefix) {
 return getProperties().keySet().stream()
  .filter(key -> StringUtils.startsWith(key, prefix))
  .collect(Collectors.toList());
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * Only returns the currently loaded properties.
 *
 * <p>
 * On the Web Server, global properties are loaded lazily when requested by name. Therefor,
 * this will return only global properties which have been requested using
 * {@link #get(String)} at least once prior to this call.
 */
@Override
public Map<String, String> getProperties() {
 // order is important. local properties override parent properties.
 ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
 builder.putAll(parentSettings.getProperties());
 builder.putAll(localProperties);
 return builder.build();
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("Settings");
 PropertyDefinitions definitions = settings.getDefinitions();
 TreeMap<String, String> orderedProps = new TreeMap<>(settings.getProperties());
 for (Map.Entry<String, String> prop : orderedProps.entrySet()) {
  String key = prop.getKey();
  String value = obfuscateValue(definitions, key, prop.getValue());
  setAttribute(protobuf, key, value);
 }
 return protobuf.build();
}

代码示例来源:origin: SonarSource/sonarqube

props.load(input);
settings.addProperties(props);
for (Map.Entry<String, String> entry : settings.getProperties().entrySet()) {
 String interpolatedValue = StrSubstitutor.replace(entry.getValue(), System.getenv(), "${", "}");
 settings.setProperty(entry.getKey(), interpolatedValue);

代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api

public List<String> getKeysStartingWith(String prefix) {
 return getProperties().keySet().stream()
  .filter(key -> StringUtils.startsWith(key, prefix))
  .collect(Collectors.toList());
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

/**
 * Only returns the currently loaded properties.
 *
 * <p>
 * On the Web Server, global properties are loaded lazily when requested by name. Therefor,
 * this will return only global properties which have been requested using
 * {@link #get(String)} at least once prior to this call.
 */
@Override
public Map<String, String> getProperties() {
 // order is important. local properties override parent properties.
 ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
 builder.putAll(parentSettings.getProperties());
 builder.putAll(localProperties);
 return builder.build();
}

代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api

public HttpDownloader(Settings settings, @Nullable Integer readTimeout) {
 this.readTimeout = readTimeout;
 downloader = new BaseHttpDownloader(settings.getProperties(), null);
}

代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api

public HttpDownloader(Server server, Settings settings, @Nullable Integer readTimeout) {
 this.readTimeout = readTimeout;
 downloader = new BaseHttpDownloader(settings.getProperties(), server.getVersion());
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

public void dumpSettings(ProjectDefinition moduleDefinition, Settings settings) {
 if (mode.isIssues()) {
  return;
 }
 File analysisLog = writer.getFileStructure().analysisLog();
 try (BufferedWriter fileWriter = Files.newBufferedWriter(analysisLog.toPath(), StandardCharsets.UTF_8, StandardOpenOption.WRITE, StandardOpenOption.APPEND)) {
  fileWriter.append(String.format("Settings for module: %s", moduleDefinition.getKey())).append('\n');
  Map<String, String> moduleSettings = settings.getProperties();
  for (String prop : new TreeSet<>(moduleSettings.keySet())) {
   if (isSystemProp(prop) || isEnvVariable(prop) || !isSqProp(prop)) {
    continue;
   }
   fileWriter.append(String.format("  - %s=%s", prop, sensitive(prop) ? "******" : moduleSettings.get(prop))).append('\n');
  }
 } catch (IOException e) {
  throw new IllegalStateException("Unable to write analysis log", e);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
public ProtobufSystemInfo.Section toProtobuf() {
 ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
 protobuf.setName("Settings");
 PropertyDefinitions definitions = settings.getDefinitions();
 TreeMap<String, String> orderedProps = new TreeMap<>(settings.getProperties());
 for (Map.Entry<String, String> prop : orderedProps.entrySet()) {
  String key = prop.getKey();
  String value = obfuscateValue(definitions, key, prop.getValue());
  setAttribute(protobuf, key, value);
 }
 return protobuf.build();
}

相关文章