Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.pentaho.di.core.util
Class StringUtil

    java.lang.Object
      org.pentaho.di.core.util.StringUtil

    public class StringUtil

extends Object

A collection of utilities to manipulate strings.

Author:
  wdeclerc

Field Summary
`static String` | `CRLF`
`static String` | `HEX_CLOSE`
`static String` | `HEX_OPEN`
`static String` | `INDENTCHARS`
`static String[]` | `SYSTEM_PROPERTIES`
`static String` | `UNIX_CLOSE`
`static String` | `UNIX_OPEN`
`static String` | `WINDOWS_CLOSE`
`static String` | `WINDOWS_OPEN`

Constructor Summary
`StringUtil()`

Method Summary
`static String` | `environmentSubstitute(String aString, Map<String,String> systemProperties)` Substitutes variables in `aString` with the environment values in the system properties
`static String` | `generateRandomString(int length, String prefix, String postfix, boolean uppercase)`
`static String` | `getFormattedDateTime(Date date)` Giving back a date/time string in the format following the rule from the most to the least significant
`static String` | `getFormattedDateTime(Date date, boolean milliseconds)` Giving back a date/time string in the format following the rule from the most to the least significant
`static String` | `getFormattedDateTimeNow()` Giving back the actual time as a date/time string in the format following the rule from the most to the least significant
`static String` | `getFormattedDateTimeNow(boolean milliseconds)` Giving back the actual time as a date/time string in the format following the rule from the most to the least significant
`static String` | `getIndent(int indentLevel)`
`static void` | `getUsedVariables(String aString, List<String> list, boolean includeSystemVariables)`
`static String` | `initCap(String st)`
`static boolean` | `isEmpty(String string)` Check if the string supplied is empty.
`static boolean` | `isEmpty(StringBuffer string)` Check if the stringBuffer supplied is empty.
`static boolean` | `isSystemVariable(String aString)`
`static Date` | `str2dat(String arg0, String arg1, String val)`
`static double` | `str2num(String pattern, String decimal, String grouping, String currency, String value)`
`static String` | `substitute(String aString, Map<String,String> variablesValues, String open, String close)` Substitutes variables in `aString`.
`static String` | `substitute(String aString, Map<String,String> variablesValues, String open, String close, int recursion)` Substitutes variables in `aString`.
`static String` | `substituteHex(String aString)` Substitutes hex values in `aString` and convert them to operating system char equivalents in the return string.
`static String` | `substituteUnix(String aString, Map<String,String> variables)` Substitutes variables in `aString`.
`static String` | `substituteWindows(String aString, Map<String,String> variables)` Substitutes variables in `aString`.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### UNIX_OPEN

    public static final String UNIX_OPEN

See Also:
  Constant Field Values

### UNIX_CLOSE

    public static final String UNIX_CLOSE

See Also:
  Constant Field Values

### WINDOWS_OPEN

    public static final String WINDOWS_OPEN

See Also:
  Constant Field Values

### WINDOWS_CLOSE

    public static final String WINDOWS_CLOSE

See Also:
  Constant Field Values

### HEX_OPEN

    public static final String HEX_OPEN

See Also:
  Constant Field Values

### HEX_CLOSE

    public static final String HEX_CLOSE

See Also:
  Constant Field Values

### CRLF

    public static final String CRLF

See Also:
  Constant Field Values

### INDENTCHARS

    public static final String INDENTCHARS

See Also:
  Constant Field Values

### SYSTEM_PROPERTIES

    public static final String[] SYSTEM_PROPERTIES

Constructor Detail

### StringUtil

    public StringUtil()

Method Detail

### substitute

    public static String substitute(String aString,
                                    Map<String,String> variablesValues,
                                    String open,
                                    String close)

  Substitutes variables in `aString`. Variable names are delimited by open and close strings. The values are retrieved from the given map.

  Parameters:
    `aString` - the string on which to apply the substitution.
    `variablesValues` - a map containg the variable values. The keys are the variable names, the values are the variable values.
    `open` - the open delimiter for variables.
    `close` - the close delimiter for variables.
  Returns:
    the string with the substitution applied.

### substitute

    public static String substitute(String aString,
                                    Map<String,String> variablesValues,
                                    String open,
                                    String close,
                                    int recursion)

  Substitutes variables in `aString`. Variable names are delimited by open and close strings. The values are retrieved from the given map.

  Parameters:
    `aString` - the string on which to apply the substitution.
    `variablesValues` - a map containg the variable values. The keys are the variable names, the values are the variable values.
    `open` - the open delimiter for variables.
    `close` - the close delimiter for variables.
    `recursion` - the number of recursion (internal counter to avoid endless loops)
  Returns:
    the string with the substitution applied.

### substituteHex

    public static String substituteHex(String aString)

  Substitutes hex values in `aString` and convert them to operating system char equivalents in the return string. Format is $[01] or $[6F,FF,00,1F] Example: "This is a hex encoded six digits number 123456 in this string: $[31,32,33,34,35,36]"

  Parameters:
    `aString` - the string on which to apply the substitution.
  Returns:
    the string with the substitution applied.

### environmentSubstitute

    public static final String environmentSubstitute(String aString,
                                                     Map<String,String> systemProperties)

  Substitutes variables in `aString` with the environment values in the system properties

  Parameters:
    `aString` - the string on which to apply the substitution.
    `systemProperties` - the system properties to use
  Returns:
    the string with the substitution applied.

### substituteUnix

    public static String substituteUnix(String aString,
                                        Map<String,String> variables)

  Substitutes variables in `aString`. Variables are of the form "${}", following the usin convention. The values are retrieved from the given map.

  Parameters:
    `aString` - the string on which to apply the substitution.
    `variables` - a map containg the variable values. The keys are the variable names, the values are the variable values.
  Returns:
    the string with the substitution applied.

### substituteWindows

    public static String substituteWindows(String aString,
                                           Map<String,String> variables)

  Substitutes variables in `aString`. Variables are of the form "%%%%", following the windows convention. The values are retrieved from the given map.

  Parameters:
    `aString` - the string on which to apply the substitution.
    `variables` - a map containg the variable values. The keys are the variable names, the values are the variable values.
  Returns:
    the string with the substitution applied.

### isSystemVariable

    public static boolean isSystemVariable(String aString)

### getUsedVariables

    public static void getUsedVariables(String aString,
                                        List<String> list,
                                        boolean includeSystemVariables)

### generateRandomString

    public static final String generateRandomString(int length,
                                                    String prefix,
                                                    String postfix,
                                                    boolean uppercase)

### initCap

    public static String initCap(String st)

### str2num

    public static double str2num(String pattern,
                                 String decimal,
                                 String grouping,
                                 String currency,
                                 String value)
                          throws KettleValueException

  Throws:
    `KettleValueException`

### isEmpty

    public static final boolean isEmpty(String string)

  Check if the string supplied is empty. A String is empty when it is null or when the length is 0

  Parameters:
    `string` - The string to check
  Returns:
    true if the string supplied is empty

### isEmpty

    public static final boolean isEmpty(StringBuffer string)

  Check if the stringBuffer supplied is empty. A StringBuffer is empty when it is null or when the length is 0

  Parameters:
    `string` - The stringBuffer to check
  Returns:
    true if the stringBuffer supplied is empty

### str2dat

    public static Date str2dat(String arg0,
                               String arg1,
                               String val)
                        throws KettleValueException

  Throws:
    `KettleValueException`

### getIndent

    public static String getIndent(int indentLevel)

### getFormattedDateTime

    public static String getFormattedDateTime(Date date)

  Giving back a date/time string in the format following the rule from the most to the least significant

  Parameters:
    `date` - the date to convert
  Returns:
    a string in the form yyyddMM_hhmmss

### getFormattedDateTime

    public static String getFormattedDateTime(Date date,
                                              boolean milliseconds)

  Giving back a date/time string in the format following the rule from the most to the least significant

  Parameters:
    `date` - the date to convert
    `milliseconds` - true when milliseconds should be added
  Returns:
    a string in the form yyyddMM_hhmmssSSS (milliseconds will be optional)

### getFormattedDateTimeNow

    public static String getFormattedDateTimeNow()

  Giving back the actual time as a date/time string in the format following the rule from the most to the least significant

  Returns:
    a string in the form yyyddMM_hhmmss

### getFormattedDateTimeNow

    public static String getFormattedDateTimeNow(boolean milliseconds)

  Giving back the actual time as a date/time string in the format following the rule from the most to the least significant

  Parameters:
    `milliseconds` - true when milliseconds should be added
  Returns:
    a string in the form yyyddMM_hhmmssSSS (milliseconds will be optional)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD