Tabnine Logo
StringUtil.substituteWithProperties
Code IndexAdd Tabnine to your IDE (free)

How to use
substituteWithProperties
method
in
com.cloudhopper.commons.util.StringUtil

Best Java code snippets using com.cloudhopper.commons.util.StringUtil.substituteWithProperties (Showing top 3 results out of 315)

origin: com.cloudhopper/ch-commons-util

/**
 * Searches the string for occurrences of the pattern $ENV{key} and
 * attempts to replace this pattern with a value from the System environment
 * obtained using the 'key'.  For example, including "$ENV{USERNAME}" in
 * a string and calling this method would then attempt to replace the entire
 * pattern with the value of the environment variable "USERNAME". The System
 * environment is obtained in Java with a call to System.getenv().  An environment variable is typically
 * defined in the Linux shell or Windows property tabs.  NOTE: A Java System
 * property is not the same as an environment variable.
 * @param string0 The string to perform substitution on such as "Hello $ENV{USERNAME}".
 *      This string may be null, empty, or contain one or more substitutions.
 * @return A string with all occurrences of keys substituted with their
 *      values obtained from the System environment.  Can be null if the
 *      original string was null.
 * @throws SubstitutionException Thrown if a starting string was found, but the
 *      ending string was not.  Also, thrown if a key value was empty such
 *      as using "$ENV{}".  Finally, thrown if the property key was not
 *      found in the properties object (could not be replaced).
 * @see #substituteWithProperties(java.lang.String, java.lang.String, java.lang.String, java.util.Properties) 
 */
public static String substituteWithEnvironment(String string0) throws SubstitutionException {
  // turn environment into properties
  Properties envProps = new Properties();
  // add all system environment vars to the properties
  envProps.putAll(System.getenv());
  // delegate to other method using the default syntax $ENV{<key>}
  return substituteWithProperties(string0, "$ENV{", "}", envProps);
}
origin: org.restcomm.smpp/ch-commons-util

/**
 * Searches the string for occurrences of the pattern $ENV{key} and
 * attempts to replace this pattern with a value from the System environment
 * obtained using the 'key'.  For example, including "$ENV{USERNAME}" in
 * a string and calling this method would then attempt to replace the entire
 * pattern with the value of the environment variable "USERNAME". The System
 * environment is obtained in Java with a call to System.getenv().  An environment variable is typically
 * defined in the Linux shell or Windows property tabs.  NOTE: A Java System
 * property is not the same as an environment variable.
 * @param string0 The string to perform substitution on such as "Hello $ENV{USERNAME}".
 *      This string may be null, empty, or contain one or more substitutions.
 * @return A string with all occurrences of keys substituted with their
 *      values obtained from the System environment.  Can be null if the
 *      original string was null.
 * @throws SubstitutionException Thrown if a starting string was found, but the
 *      ending string was not.  Also, thrown if a key value was empty such
 *      as using "$ENV{}".  Finally, thrown if the property key was not
 *      found in the properties object (could not be replaced).
 * @see #substituteWithProperties(java.lang.String, java.lang.String, java.lang.String, java.util.Properties) 
 */
public static String substituteWithEnvironment(String string0) throws SubstitutionException {
  // turn environment into properties
  Properties envProps = new Properties();
  // add all system environment vars to the properties
  envProps.putAll(System.getenv());
  // delegate to other method using the default syntax $ENV{<key>}
  return substituteWithProperties(string0, "$ENV{", "}", envProps);
}
origin: org.restcomm.smpp/ch-commons-xbean

/**
 * Creates an InputStream containing the document resulting from replacing template
 * parameters in the given InputStream source.
 * @param source The source stream
 * @param props The properties
 * @param startStr The String that marks the start of a replacement key such as "${"
 * @param endStr The String that marks the end of a replacement key such as "}"
 * @return An InputStream containing the resulting document.
 */
static public InputStream replaceProperties(InputStream source, Properties props, String startStr, String endStr) throws IOException, SubstitutionException {
String template = streamToString(source);
String replaced = StringUtil.substituteWithProperties(template, startStr, endStr, props);
System.err.println(template);
System.err.println(replaced);
return new ByteArrayInputStream(replaced.getBytes());
}
com.cloudhopper.commons.utilStringUtilsubstituteWithProperties

Javadoc

Searches string for occurrences of a pattern, extracts out a key name between the startStr and endStr tokens, then attempts to replace the property value into the string. This method is useful for merging property values into configuration strings/settings. For examle, the system environment Map could be converted into a Properties object then have its values merged into a String so that users can access environment variables.

Popular methods of StringUtil

  • isEmpty
    Checks if the string is an empty value which is true if the string is null or if the string represen
  • toStringWithNullAsEmpty
    Returns the value from calling "toString()" on the object, but is a safe version that gracefully han
  • SQLToUpperCase
    Convert string to uppercase Always use the java.util.ENGLISH locale
  • capitalize
    Safely capitalizes a string by converting the first character to upper case. Handles null, empty, an
  • compressQuotes
    Compress 2 adjacent (single or double) quotes into a single (s or d) quote when found in the middle
  • containsOnlyDigits
    Checks if a string contains only digits.
  • getAsciiBytes
    Get 7-bit ASCII character array from input String. The lower 7 bits of each character in the input s
  • getAsciiString
  • indexOf
    Finds the first occurrence of the targetString in the array of strings. Returns -1 if an occurrence
  • isEqual
    Checks if both strings are equal to each other. Safely handles the case where either string may be n
  • isPrintableChar
    Return true if the character is printable in ASCII. Not using Character.isLetterOrDigit(); applies t
  • isSafeChar
    Returns true if the char is considered a "safe" char. Please see documentation for isSafeString().
  • isPrintableChar,
  • isSafeChar,
  • quoteString,
  • readToString,
  • substituteWithEnvironment

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • getApplicationContext (Context)
  • onCreateOptionsMenu (Activity)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JFileChooser (javax.swing)
  • JFrame (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now