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.apache.commons.exec.util
Class StringUtils

    java.lang.Object
      org.apache.commons.exec.util.StringUtils

    public class StringUtils

extends Object

Supplement of commons-lang, the stringSubstitution() was in a simpler implementation available in an older commons-lang implementation. Furthermore a place to put reusable and/or ugly code. This class is not part of the public API and could change without warning.

Author:
  Siegfried Goeschl

Constructor Summary
`StringUtils()`

Method Summary
`static String` | `fixFileSeparatorChar(String arg)` Fixes the file sperator char for the target platform using the following replacement.
`static boolean` | `isQuoted(String argument)` Determines if this is a quoted argumented - either single or double quoted.
`static String` | `quoteArgument(String argument)` Put quotes around the given String if necessary.
`static String[]` | `split(String input, String splitChar)` Split a string into an array of strings based on a separator.
`static StringBuffer` | `stringSubstitution(String argStr, Map vars, boolean isLenient)` Perform a series of substitutions.
`static String` | `toString(String[] strings, String separator)` Concatenates an array of string using a separator.

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

Constructor Detail

### StringUtils

    public StringUtils()

Method Detail

### stringSubstitution

    public static StringBuffer stringSubstitution(String argStr,
                                                  Map vars,
                                                  boolean isLenient)

  Perform a series of substitutions. The substitions are performed by replacing ${variable} in the target string with the value of provided by the key "variable" in the provided hashtable.

  Parameters:
    `argStr` - the argument string to be processed
    `vars` - name/value pairs used for substitution
    `isLenient` - ignore a key not found in vars?
  Returns:
    String target string with replacements.

### split

    public static String[] split(String input,
                                 String splitChar)

  Split a string into an array of strings based on a separator.

  Parameters:
    `input` - what to split
    `splitChar` - what to split on
  Returns:
    the array of strings

### fixFileSeparatorChar

    public static String fixFileSeparatorChar(String arg)

  Fixes the file sperator char for the target platform using the following replacement.
  - '/' ==> File.separatorChar
  - '\\' ==> File.separatorChar

  Parameters:
    `arg` - the argument to fix
  Returns:
    the transformed argument

### toString

    public static String toString(String[] strings,
                                  String separator)

  Concatenates an array of string using a separator.

  Parameters:
    `strings` - the strings to concatenate
    `separator` - the separator between two strings
  Returns:
    the concatened strings

### quoteArgument

    public static String quoteArgument(String argument)

  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

    public static boolean isQuoted(String argument)

  Determines if this is a quoted argumented - either single or double quoted.

  Parameters:
    `argument` - the argument to check
  Returns:
    true when the argument is quoted

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

Copyright © 2001-2009 The Apache Software Foundation. All Rights Reserved.