hudson.Util.loadProperties()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(176)

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

Util.loadProperties介绍

[英]Loads a key/value pair string as Properties
[中]将键/值对字符串作为属性加载

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties} with masking.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to resolve variables in properties string.
 * @param propsToMask
 *      Set containing key names to mark as masked in the argument list. Key
 *      names that do not exist in the set will be added unmasked.
 * @since 1.378
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver<String> vr, Set<String> propsToMask) throws IOException {
  if(properties==null)    return this;
  properties = Util.replaceMacro(properties, propertiesGeneratingResolver(vr));
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), entry.getValue().toString(), (propsToMask == null) ? false : propsToMask.contains(entry.getKey()));
  }
  return this;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties}.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to be performed on the values.
 * @since 1.262
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr) throws IOException {
  if(properties==null)    return this;
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), Util.replaceMacro(entry.getValue().toString(),vr), false);
  }
  return this;
}

代码示例来源:origin: org.jenkins-ci.plugins/database-mysql

public FormValidation doCheckProperties(@QueryParameter String properties) throws IOException {
    try {
      if (validPropertyNames==null) {
        // this computation depends on the implementation details of MySQL JDBC connector
        GroovyShell gs = new GroovyShell(getClass().getClassLoader());
        validPropertyNames = (Set<String>)gs.evaluate(new InputStreamReader(MySQLDatabase.class.getResourceAsStream("validate.groovy")));
      }
      Properties props = Util.loadProperties(properties);
      for (Map.Entry e : props.entrySet()) {
        String key = e.getKey().toString();
        if (!validPropertyNames.contains(key))
          return FormValidation.error("Unrecognized property: "+key);
      }
      return FormValidation.ok();
    } catch (Throwable e) {
      return FormValidation.warning(e,"Failed to validate the connection properties");
    }
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given
 * string using {@link Properties} with masking.
 *
 * @param prefix The '-D' portion of the example. Defaults to -D if null.
 * @param properties The persisted form of {@link Properties}. For example,
 * "abc=def\nghi=jkl". Can be null, in which case this method becomes no-op.
 * @param vr {@link VariableResolver} to be performed on the values.
 * @param propsToMask Set containing key names to mark as masked in the
 * argument list. Key names that do not exist in the set will be added
 * unmasked.
 * @since 1.378
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr, Set<String> propsToMask) throws IOException {
  if (properties == null) {
    return this;
  }
  for (Entry<Object, Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String) entry.getKey(), Util.replaceMacro(entry.getValue().toString(), vr), (propsToMask == null) ? false : propsToMask.contains((String) entry.getKey()));
  }
  return this;
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties}.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to be performed on the values.
 * @since 1.262
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr) throws IOException {
  if(properties==null)    return this;
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), Util.replaceMacro(entry.getValue().toString(),vr), false);
  }
  return this;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties}.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to be performed on the values.
 * @since 1.262
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr) throws IOException {
  if(properties==null)    return this;
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), Util.replaceMacro(entry.getValue().toString(),vr), false);
  }
  return this;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given
 * string using {@link Properties}.
 *
 * @param prefix The '-D' portion of the example. Defaults to -D if null.
 * @param properties The persisted form of {@link Properties}. For example,
 * "abc=def\nghi=jkl". Can be null, in which case this method becomes no-op.
 * @param vr {@link VariableResolver} to be performed on the values.
 * @since 1.262
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr) throws IOException {
  if (properties == null) {
    return this;
  }
  for (Entry<Object, Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String) entry.getKey(), Util.replaceMacro(entry.getValue().toString(), vr), false);
  }
  return this;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties} with masking.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to be performed on the values.
 * @param propsToMask
 *      Set containing key names to mark as masked in the argument list. Key
 *      names that do not exist in the set will be added unmasked.
 * @since 1.378
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr, Set<String> propsToMask) throws IOException {
  if(properties==null)    return this;
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), Util.replaceMacro(entry.getValue().toString(),vr), (propsToMask == null) ? false : propsToMask.contains((String)entry.getKey()));
  }
  return this;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties} with masking.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to be performed on the values.
 * @param propsToMask
 *      Set containing key names to mark as masked in the argument list. Key
 *      names that do not exist in the set will be added unmasked.
 * @since 1.378
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr, Set<String> propsToMask) throws IOException {
  if(properties==null)    return this;
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), Util.replaceMacro(entry.getValue().toString(),vr), (propsToMask == null) ? false : propsToMask.contains((String)entry.getKey()));
  }
  return this;
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties} with masking.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to be performed on the values.
 * @param propsToMask
 *      Set containing key names to mark as masked in the argument list. Key
 *      names that do not exist in the set will be added unmasked.
 * @since 1.378
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver vr, Set<String> propsToMask) throws IOException {
  if(properties==null)    return this;
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), Util.replaceMacro(entry.getValue().toString(),vr), (propsToMask == null) ? false : propsToMask.contains((String)entry.getKey()));
  }
  return this;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Adds key value pairs as "-Dkey=value -Dkey=value ..." by parsing a given string using {@link Properties} with masking.
 *
 * @param prefix
 *      The '-D' portion of the example. Defaults to -D if null.
 * @param properties
 *      The persisted form of {@link Properties}. For example, "abc=def\nghi=jkl". Can be null, in which
 *      case this method becomes no-op.
 * @param vr
 *      {@link VariableResolver} to resolve variables in properties string.
 * @param propsToMask
 *      Set containing key names to mark as masked in the argument list. Key
 *      names that do not exist in the set will be added unmasked.
 * @since 1.378
 */
public ArgumentListBuilder addKeyValuePairsFromPropertyString(String prefix, String properties, VariableResolver<String> vr, Set<String> propsToMask) throws IOException {
  if(properties==null)    return this;
  properties = Util.replaceMacro(properties, propertiesGeneratingResolver(vr));
  for (Entry<Object,Object> entry : Util.loadProperties(properties).entrySet()) {
    addKeyValuePair(prefix, (String)entry.getKey(), entry.getValue().toString(), (propsToMask == null) ? false : propsToMask.contains(entry.getKey()));
  }
  return this;
}

相关文章