org.keycloak.common.util

## Class StringPropertyReplacer

- java.lang.Object
- - org.keycloak.common.util.StringPropertyReplacer

-     public final class StringPropertyReplacer
      extends Object

  A utility class for replacing properties in strings.
  Version:
    `$Revision: 2898 $`
  Author:
    Jason Dillon, Scott Stark, Claudio Vesco, Adrian Brock, Dimitris Andreadis

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `StringPropertyReplacer.PropertyResolver`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `NEWLINE` New line string constant

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringPropertyReplacer()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `replaceProperties(String string)` Go through the input string and replace any occurance of ${p} with the System.getProperty(p) value.
    `static String` | `replaceProperties(String string, Properties props)` Go through the input string and replace any occurance of ${p} with the props.getProperty(p) value.
    `static String` | `replaceProperties(String string, StringPropertyReplacer.PropertyResolver resolver)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NEWLINE

          public static final String NEWLINE

      New line string constant

  - ### Constructor Detail

    - #### StringPropertyReplacer

          public StringPropertyReplacer()

  - ### Method Detail

    - #### replaceProperties

          public static String replaceProperties(String string)

      Go through the input string and replace any occurance of ${p} with the System.getProperty(p) value. If there is no such property p defined, then the ${p} reference will remain unchanged. If the property reference is of the form ${p:v} and there is no such property p, then the default value v will be returned. If the property reference is of the form ${p1,p2} or ${p1,p2:v} then the primary and the secondary properties will be tried in turn, before returning either the unchanged input, or the default value. The property ${/} is replaced with System.getProperty("file.separator") value and the property ${:} is replaced with System.getProperty("path.separator").
      Parameters:
        `string` - - the string with possible ${} references
      Returns:
        the input string with all property references replaced if any. If there are no valid references the input string will be returned.

    - #### replaceProperties

          public static String replaceProperties(String string,
                                                 Properties props)

      Go through the input string and replace any occurance of ${p} with the props.getProperty(p) value. If there is no such property p defined, then the ${p} reference will remain unchanged. If the property reference is of the form ${p:v} and there is no such property p, then the default value v will be returned. If the property reference is of the form ${p1,p2} or ${p1,p2:v} then the primary and the secondary properties will be tried in turn, before returning either the unchanged input, or the default value. The property ${/} is replaced with System.getProperty("file.separator") value and the property ${:} is replaced with System.getProperty("path.separator").
      Parameters:
        `string` - - the string with possible ${} references
        `props` - - the source for ${x} property ref values, null means use System.getProperty()
      Returns:
        the input string with all property references replaced if any. If there are no valid references the input string will be returned.

    - #### replaceProperties

          public static String replaceProperties(String string,
                                                 StringPropertyReplacer.PropertyResolver resolver)

Copyright © 2021 JBoss by Red Hat. All rights reserved.