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

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

本文整理了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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

相关文章