public class

StringUtils

extends Object
java.lang.Object
   ↳ com.neomades.util.StringUtils

Class Overview

String Utilities.

Summary

Public Constructors
StringUtils()
Public Methods
static boolean isNullOrEmpty(String element)
Return true if the string is null or ""
static String neverEmpty(String element)
Converts "" to null
static String neverNull(String element)
Converts null element to empty string ""
static String replace(String original, String replaced, String by)
Replaces replaced string occurrences from original by the parameter by.
static String replaceAll(String original, String replaced, String by)
Replaces replaced string occurrences from original that matches the given regular expression by.
static String[] split(String string, String separator)
Splits a string into substrings, based on a separator string.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public StringUtils ()

Public Methods

public static boolean isNullOrEmpty (String element)

Return true if the string is null or ""

Returns
  • true if the string is null or ""

public static String neverEmpty (String element)

Converts "" to null

Returns
  • null or non empty string

public static String neverNull (String element)

Converts null element to empty string ""

Returns
  • null element to empty string ""

public static String replace (String original, String replaced, String by)

Replaces replaced string occurrences from original by the parameter by. This method returns a new string resulting from replacing all occurrences of replaced in this string original with by.

Parameters
original the string to modify
replaced the old character set
by the new character set
Returns
  • a new string with the replace result (the original string is not modified)
Throws
NullPointerException if one of the parameter string is null

public static String replaceAll (String original, String replaced, String by)

Replaces replaced string occurrences from original that matches the given regular expression by.

Parameters
original the string to modify
replaced the regular expression to replace
by the new character set
Returns
  • a new string with the replace result (the original string is not modified)
Throws
NullPointerException if one of the parameter string is null

public static String[] split (String string, String separator)

Splits a string into substrings, based on a separator string.

Cross Platform Considerations

In Android and iOS this method may return different results when the separator is the empty string "".

These limitations will be fixed in a future release, and the method will behave the same for all platforms.

Parameters
string the string to split (if null, the method will return null)
separator the separator string to use for splitting (must not be null)
Returns
  • an array containing split fragments of the original string based on the separator
Throws
NullPointerException if separator is null