Class StringUtils
java.lang.Object
org.apache.commons.exec.util.StringUtils
Supplement of commons-lang, the stringSubstitution() was in a simpler
implementation available in an older commons-lang implementation.
This class is not part of the public API and could change without
warning.
- Version:
- $Id: StringUtils.java 1636204 2014-11-02 22:30:31Z ggregory $
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFixes the file separator char for the target platform using the following replacement.static booleanDetermines if this is a quoted argument - either single or double quoted.static StringquoteArgument(String argument) Put quotes around the given String if necessary.static String[]Split a string into an array of strings based on a separator.static StringBufferstringSubstitution(String argStr, Map<? super String, ?> vars, boolean isLenient) Perform a series of substitutions.static StringConcatenates an array of string using a separator.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
stringSubstitution
public static StringBuffer stringSubstitution(String argStr, Map<? super String, ?> vars, boolean isLenient) Perform a series of substitutions.The substitutions are performed by replacing ${variable} in the target string with the value of provided by the key "variable" in the provided hash table.
A key consists of the following characters:
- letter
- digit
- dot character
- hyphen character
- plus character
- underscore character
- Parameters:
argStr- the argument string to be processedvars- name/value pairs used for substitutionisLenient- ignore a key not found in vars or throw a RuntimeException?- Returns:
- String target string with replacements.
-
split
-
fixFileSeparatorChar
Fixes the file separator char for the target platform using the following replacement.- '/' → File.separatorChar
- '\\' → File.separatorChar
- Parameters:
arg- the argument to fix- Returns:
- the transformed argument
-
toString
-
quoteArgument
Put quotes around the given String if necessary.If the argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single quotes - else surround the argument by double quotes.
- Parameters:
argument- the argument to be quoted- Returns:
- the quoted argument
- Throws:
IllegalArgumentException- If argument contains both types of quotes
-
isQuoted
-