com.izforge.izpack.util
Class StringTool

java.lang.Object
  extended bycom.izforge.izpack.util.StringTool

public class StringTool
extends java.lang.Object

A extended Java Implementation of Pythons string.replace()

Author:
marc.eppelmann@gmx.de

Constructor Summary
StringTool()
          Default Constructor
 
Method Summary
static java.lang.String getPlatformEncoding()
           
static void main(java.lang.String[] args)
          Standalone callable Test method
static java.lang.String normalizePath(java.lang.String destination)
          Normalizes a mixed Windows/Unix Path.
static java.lang.String normalizePath(java.lang.String destination, java.lang.String fileSeparator)
          Normalizes a Windows or Unix Path.
static java.lang.String replace(java.lang.String value, java.lang.String from, java.lang.String to)
          Replaces from with to in given String: value
static java.lang.String replace(java.lang.String value, java.lang.String from, java.lang.String to, boolean aCaseSensitiveFlag)
          Replaces from with to in given String: value
static boolean startsWith(java.lang.String str, java.lang.String prefix)
          True if a given string starts with the another given String
static boolean startsWithIgnoreCase(java.lang.String str, java.lang.String prefix)
          The same as startsWith but ignores the case.
static java.lang.String stringArrayListToString(java.util.ArrayList aStringList)
          Transforms a (Array)List of Strings into a printable Stringlist
static java.lang.String stringArrayToSpaceSeparatedString(java.lang.String[] args)
          Converts an String Array to a space separated String w/o any check
static java.lang.String UTF16()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTool

public StringTool()
Default Constructor

Method Detail

main

public static void main(java.lang.String[] args)
Standalone callable Test method

Parameters:
args - Commandline Args

replace

public static java.lang.String replace(java.lang.String value,
                                       java.lang.String from,
                                       java.lang.String to)
Replaces from with to in given String: value

Parameters:
value - original String
from - Search Pattern
to - Replace with this
Returns:
the replaced String

replace

public static java.lang.String replace(java.lang.String value,
                                       java.lang.String from,
                                       java.lang.String to,
                                       boolean aCaseSensitiveFlag)
Replaces from with to in given String: value

Parameters:
value - original String
from - Search Pattern
to - Replace with this
aCaseSensitiveFlag - set to true be case sensitive.
Returns:
the replaced String

normalizePath

public static java.lang.String normalizePath(java.lang.String destination,
                                             java.lang.String fileSeparator)
Normalizes a Windows or Unix Path. Reason: Javas File accepts / or \ for Pathes. Batches or ShellScripts does it not! TODO: implement support for MAC < MacOSX

Parameters:
destination -
fileSeparator - a target-system fileseparator
Returns:
the normalized path

normalizePath

public static java.lang.String normalizePath(java.lang.String destination)
Normalizes a mixed Windows/Unix Path. Does Only work for Windows or Unix Pathes Reason: Java.File accepts / or \ for Pathes. Batches or ShellScripts does it not!

Parameters:
destination - accepted mixed form by java.File like "C:/a/mixed\path\accepted/by\Java"
Returns:
the normalized Path

stringArrayToSpaceSeparatedString

public static java.lang.String stringArrayToSpaceSeparatedString(java.lang.String[] args)
Converts an String Array to a space separated String w/o any check

Parameters:
args - The StringArray
Returns:
the space separated result.

getPlatformEncoding

public static java.lang.String getPlatformEncoding()

UTF16

public static java.lang.String UTF16()

stringArrayListToString

public static java.lang.String stringArrayListToString(java.util.ArrayList aStringList)
Transforms a (Array)List of Strings into a printable Stringlist

Parameters:
aStringList -
Returns:
a printable list

startsWith

public static boolean startsWith(java.lang.String str,
                                 java.lang.String prefix)
True if a given string starts with the another given String

Parameters:
str - The String to search in
prefix - The string to search for
Returns:
True if str starts with prefix

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(java.lang.String str,
                                           java.lang.String prefix)
The same as startsWith but ignores the case.

Parameters:
str - The String to search in
prefix - The string to search for
Returns:
rue if str starts with prefix