liquibase.util
Class StringUtils

java.lang.Object
  extended by liquibase.util.StringUtils

public class StringUtils
extends Object

Various utility methods for working with strings.


Nested Class Summary
static interface StringUtils.StringUtilsFormatter<Type>
           
static class StringUtils.ToStringFormatter
           
 
Constructor Summary
StringUtils()
           
 
Method Summary
static String escapeHtml(String str)
           
static boolean hasLowerCase(String string)
           
static boolean hasUpperCase(String string)
           
static String indent(String string)
           
static String indent(String string, int padding)
           
static boolean isAscii(char ch)
           
static boolean isAscii(String string)
           
protected static boolean isDelimiter(String piece, String previousPiece, String endDelimiter)
           
static boolean isEmpty(String value)
          Null-safe check if string is empty.
static boolean isNotEmpty(String value)
          Null-safe check if string is not empty
static boolean isWhitespace(CharSequence string)
           
static String join(Collection<String> collection, String delimiter)
           
static String join(Collection<String> collection, String delimiter, boolean sorted)
           
static String join(Collection collection, String delimiter, StringUtils.StringUtilsFormatter formatter)
           
static String join(Collection collection, String delimiter, StringUtils.StringUtilsFormatter formatter, boolean sorted)
           
static String join(int[] array, String delimiter)
           
static String join(Integer[] array, String delimiter)
           
static String join(Map map, String delimiter)
           
static String join(Map map, String delimiter, StringUtils.StringUtilsFormatter formatter)
           
static String join(Object[] array, String delimiter, StringUtils.StringUtilsFormatter formatter)
           
static String join(String[] array, String delimiter)
           
static String limitSize(String string, int maxLength)
           
static String lowerCaseFirst(String string)
           
static String pad(String value, int length)
           
static String[] processMutliLineSQL(String multiLineSQL, boolean stripComments, boolean splitStatements, String endDelimiter)
          Removes any comments from multiple line SQL using stripComments(String) and then extracts each individual statement using splitSQL(String, String).
static String repeat(String string, int times)
           
static List<String> splitAndTrim(String s, String regex)
           
static String[] splitSQL(String multiLineSQL, String endDelimiter)
          Splits a (possible) multi-line SQL statement along ;'s and "go"'s.
static String standardizeLineEndings(String string)
           
static boolean startsWith(String value, String startsWith)
          Checks if value starts with startsWith.
static String stripComments(String multiLineSQL)
          Searches through a String which contains SQL code and strips out any comments that are between \/**\/ or anything that matches SP--SP\n (to support the ANSI standard commenting of -- at the end of a line).
static String trimToEmpty(String string)
           
static String trimToNull(String string)
           
static String upperCaseFirst(String string)
           
 
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

trimToEmpty

public static String trimToEmpty(String string)

trimToNull

public static String trimToNull(String string)

processMutliLineSQL

public static String[] processMutliLineSQL(String multiLineSQL,
                                           boolean stripComments,
                                           boolean splitStatements,
                                           String endDelimiter)
Removes any comments from multiple line SQL using stripComments(String) and then extracts each individual statement using splitSQL(String, String).

Parameters:
multiLineSQL - A String containing all the SQL statements
stripComments - If true then comments will be stripped, if false then they will be left in the code

isDelimiter

protected static boolean isDelimiter(String piece,
                                     String previousPiece,
                                     String endDelimiter)

splitSQL

public static String[] splitSQL(String multiLineSQL,
                                String endDelimiter)
Splits a (possible) multi-line SQL statement along ;'s and "go"'s.


stripComments

public static String stripComments(String multiLineSQL)
Searches through a String which contains SQL code and strips out any comments that are between \/**\/ or anything that matches SP--SP\n (to support the ANSI standard commenting of -- at the end of a line).

Returns:
The String without the comments in

join

public static String join(Object[] array,
                          String delimiter,
                          StringUtils.StringUtilsFormatter formatter)

join

public static String join(String[] array,
                          String delimiter)

join

public static String join(Collection<String> collection,
                          String delimiter)

join

public static String join(Collection collection,
                          String delimiter,
                          StringUtils.StringUtilsFormatter formatter)

join

public static String join(Collection collection,
                          String delimiter,
                          StringUtils.StringUtilsFormatter formatter,
                          boolean sorted)

join

public static String join(Collection<String> collection,
                          String delimiter,
                          boolean sorted)

join

public static String join(Map map,
                          String delimiter)

join

public static String join(Map map,
                          String delimiter,
                          StringUtils.StringUtilsFormatter formatter)

splitAndTrim

public static List<String> splitAndTrim(String s,
                                        String regex)

repeat

public static String repeat(String string,
                            int times)

join

public static String join(Integer[] array,
                          String delimiter)

join

public static String join(int[] array,
                          String delimiter)

indent

public static String indent(String string)

indent

public static String indent(String string,
                            int padding)

lowerCaseFirst

public static String lowerCaseFirst(String string)

upperCaseFirst

public static String upperCaseFirst(String string)

hasUpperCase

public static boolean hasUpperCase(String string)

hasLowerCase

public static boolean hasLowerCase(String string)

standardizeLineEndings

public static String standardizeLineEndings(String string)

isAscii

public static boolean isAscii(String string)

isAscii

public static boolean isAscii(char ch)

escapeHtml

public static String escapeHtml(String str)

pad

public static String pad(String value,
                         int length)

isEmpty

public static boolean isEmpty(String value)
Null-safe check if string is empty.

Parameters:
value - String to be checked
Returns:
true if String is null or empty

isNotEmpty

public static boolean isNotEmpty(String value)
Null-safe check if string is not empty

Parameters:
value - String to be checked
Returns:
true if string is not null and not empty (length > 0)

startsWith

public static boolean startsWith(String value,
                                 String startsWith)
Checks if value starts with startsWith.

Parameters:
value -
startsWith -
Returns:
true if value starts with startsWith, otherwise false. If any of arguments is null returns false

isWhitespace

public static boolean isWhitespace(CharSequence string)

limitSize

public static String limitSize(String string,
                               int maxLength)


Copyright © 2016 Liquibase.org. All rights reserved.