sk.baka.tools
Class StrUtils

java.lang.Object
  extended by sk.baka.tools.StrUtils

public final class StrUtils
extends Object

Contains various Strings utilities.

Author:
Martin Vysny

Method Summary
static boolean isBlank(String str)
          Checks if given string is blank (null or whitespace-only).
static boolean isEmpty(String msg)
          Returns true if given string is null or zero-sized.
static List<String> split(String str, String delimiters)
          Splits given string and returns a list of splitted trimmed strings.
static String truncate(String string, int maxLength, boolean start)
          Truncates given string if its length exceeds maximum length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isBlank

public static boolean isBlank(String str)
Checks if given string is blank (null or whitespace-only).

Parameters:
str - the string to check
Returns:
true if the string is blank.

split

public static List<String> split(String str,
                                 String delimiters)
Splits given string and returns a list of splitted trimmed strings.

Parameters:
str - the strings to split, may be null.
delimiters - the delimiters
Returns:
a list of trimmed tokens, never null, may be empty.

isEmpty

public static boolean isEmpty(String msg)
Returns true if given string is null or zero-sized.

Parameters:
msg - the string to check
Returns:
true if null or zero-sized, false otherwise.

truncate

public static String truncate(String string,
                              int maxLength,
                              boolean start)
Truncates given string if its length exceeds maximum length.

Parameters:
string - the string to truncate
maxLength - the maximum length
start - if true then leading characters are truncated, otherwise trailing characters are truncated
Returns:
truncated string


Copyright © 2009-2010. All Rights Reserved.