Class ApacheCommonsLangUtil
- java.lang.Object
-
- co.aikar.commands.apachecommonslang.ApacheCommonsLangUtil
-
public class ApacheCommonsLangUtil extends Object
Select methods copied from Apache Commons to avoid importing entire lib No changes to logic
-
-
Field Summary
Fields Modifier and Type Field Description static StringEMPTYThe empty String"".static intINDEX_NOT_FOUNDThe index value when an element is not found in a list or array:-1.
-
Constructor Summary
Constructors Constructor Description ApacheCommonsLangUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]addAll(T[] array1, T... array2)Adds all the elements of the given arrays into a new array.static Stringcapitalize(String str)Capitalizes all the whitespace separated words in a String.static Stringcapitalize(String str, char... delimiters)Capitalizes all the delimiter separated words in a String.static StringcapitalizeFully(String str)Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.static StringcapitalizeFully(String str, char... delimiters)Converts all the delimiter separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.static <T> T[]clone(T[] array)Shallow clones an array returning a typecast result and handlingnull.static intindexOf(Object[] array, Object objectToFind)Finds the index of the given object in the array.static intindexOf(Object[] array, Object objectToFind, int startIndex)Finds the index of the given object in the array starting at the given index.static booleanisDelimiter(char ch, char[] delimiters)Is the character a delimiter.static booleanisNumeric(CharSequence cs)Checks if the CharSequence contains only Unicode digits.static Stringjoin(byte[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(byte[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(char[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(char[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(double[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(double[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(float[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(float[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(int[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(int[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(long[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(long[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(short[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(short[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(Iterable<?> iterable, char separator)Joins the elements of the providedIterableinto a single String containing the provided elements.static Stringjoin(Iterable<?> iterable, String separator)Joins the elements of the providedIterableinto a single String containing the provided elements.static Stringjoin(Object[] array, char separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(Object[] array, char separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(Object[] array, String separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(Object[] array, String separator, int startIndex, int endIndex)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(Iterator<?> iterator, char separator)Joins the elements of the providedIteratorinto a single String containing the provided elements.static Stringjoin(Iterator<?> iterator, String separator)Joins the elements of the providedIteratorinto a single String containing the provided elements.static <T> Stringjoin(T... elements)Joins the elements of the provided array into a single String containing the provided list of elements.static booleanstartsWith(CharSequence str, CharSequence prefix)Check if a CharSequence starts with a specified prefix.static booleanstartsWithIgnoreCase(CharSequence str, CharSequence prefix)Case insensitive check if a CharSequence starts with a specified prefix.
-
-
-
Field Detail
-
EMPTY
public static final String EMPTY
The empty String"".- Since:
- 2.0
- See Also:
- Constant Field Values
-
INDEX_NOT_FOUND
public static final int INDEX_NOT_FOUND
The index value when an element is not found in a list or array:-1. This value is returned by methods in this class and can also be used in comparisons with values returned by various method fromList.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ApacheCommonsLangUtil
public ApacheCommonsLangUtil()
-
-
Method Detail
-
clone
public static <T> T[] clone(T[] array)
Shallow clones an array returning a typecast result and handling
null.The objects in the array are not cloned, thus there is no special handling for multi-dimensional arrays.
This method returns
nullfor anullinput array.- Type Parameters:
T- the component type of the array- Parameters:
array- the array to shallow clone, may benull- Returns:
- the cloned array,
nullifnullinput
-
addAll
public static <T> T[] addAll(T[] array1, T... array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of
array1followed by all of the elementsarray2. When an array is returned, it is always a new array.ArrayUtils.addAll(null, null) = null ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = [] ArrayUtils.addAll([null], [null]) = [null, null] ArrayUtils.addAll(["a", "b", "c"], ["1", "2", "3"]) = ["a", "b", "c", "1", "2", "3"]
- Type Parameters:
T- the component type of the array- Parameters:
array1- the first array whose elements are added to the new array, may benullarray2- the second array whose elements are added to the new array, may benull- Returns:
- The new array,
nullif both arrays arenull. The type of the new array is the type of the first array, unless the first array is null, in which case the type is the same as the second array. - Throws:
IllegalArgumentException- if the array types are incompatible- Since:
- 2.1
-
capitalizeFully
public static String capitalizeFully(String str)
Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.
Whitespace is defined by
Character.isWhitespace(char). Anullinput String returnsnull. Capitalization uses the Unicode title case, normally equivalent to upper case.WordUtils.capitalizeFully(null) = null WordUtils.capitalizeFully("") = "" WordUtils.capitalizeFully("i am FINE") = "I Am Fine"- Parameters:
str- the String to capitalize, may be null- Returns:
- capitalized String,
nullif null String input
-
capitalizeFully
public static String capitalizeFully(String str, char... delimiters)
Converts all the delimiter separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.
The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized.
A
nullinput String returnsnull. Capitalization uses the Unicode title case, normally equivalent to upper case.WordUtils.capitalizeFully(null, *) = null WordUtils.capitalizeFully("", *) = "" WordUtils.capitalizeFully(*, null) = * WordUtils.capitalizeFully(*, new char[0]) = * WordUtils.capitalizeFully("i aM.fine", {'.'}) = "I am.Fine"- Parameters:
str- the String to capitalize, may be nulldelimiters- set of characters to determine capitalization, null means whitespace- Returns:
- capitalized String,
nullif null String input - Since:
- 2.1
-
capitalize
public static String capitalize(String str)
Capitalizes all the whitespace separated words in a String. Only the first character of each word is changed. To convert the rest of each word to lowercase at the same time, use
capitalizeFully(String).Whitespace is defined by
Character.isWhitespace(char). Anullinput String returnsnull. Capitalization uses the Unicode title case, normally equivalent to upper case.WordUtils.capitalize(null) = null WordUtils.capitalize("") = "" WordUtils.capitalize("i am FINE") = "I Am FINE"- Parameters:
str- the String to capitalize, may be null- Returns:
- capitalized String,
nullif null String input - See Also:
capitalizeFully(String)
-
capitalize
public static String capitalize(String str, char... delimiters)
Capitalizes all the delimiter separated words in a String. Only the first character of each word is changed. To convert the rest of each word to lowercase at the same time, use
capitalizeFully(String, char[]).The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized.
A
nullinput String returnsnull. Capitalization uses the Unicode title case, normally equivalent to upper case.WordUtils.capitalize(null, *) = null WordUtils.capitalize("", *) = "" WordUtils.capitalize(*, new char[0]) = * WordUtils.capitalize("i am fine", null) = "I Am Fine" WordUtils.capitalize("i aM.fine", {'.'}) = "I aM.Fine"- Parameters:
str- the String to capitalize, may be nulldelimiters- set of characters to determine capitalization, null means whitespace- Returns:
- capitalized String,
nullif null String input - Since:
- 2.1
- See Also:
capitalizeFully(String)
-
isDelimiter
public static boolean isDelimiter(char ch, char[] delimiters)
Is the character a delimiter.- Parameters:
ch- the character to checkdelimiters- the delimiters- Returns:
- true if it is a delimiter
-
join
@SafeVarargs public static <T> String join(T... elements)
Joins the elements of the provided array into a single String containing the provided list of elements.
No separator is added to the joined String. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null) = null StringUtils.join([]) = "" StringUtils.join([null]) = "" StringUtils.join(["a", "b", "c"]) = "abc" StringUtils.join([null, "", "a"]) = "a"
- Type Parameters:
T- the specific type of values to join together- Parameters:
elements- the values to join together, may be null- Returns:
- the joined String,
nullif null array input - Since:
- 2.0, 3.0 Changed signature to use varargs
-
join
public static String join(Object[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], ';') = "a;b;c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join([null, "", "a"], ';') = ";;a"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 2.0
-
join
public static String join(long[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(int[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(short[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(byte[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(char[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(float[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(double[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(Object[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], ';') = "a;b;c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join([null, "", "a"], ';') = ";;a"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 2.0
-
join
public static String join(long[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(int[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(byte[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(short[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(char[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(double[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(float[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to usestartIndex- the first index to start joining from. It is an error to pass in an end index past the end of the arrayendIndex- the index to stop joining from (exclusive). It is an error to pass in an end index past the end of the array- Returns:
- the joined String,
nullif null array input - Since:
- 3.2
-
join
public static String join(Object[] array, String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. A
nullseparator is the same as an empty String (""). Null objects or empty strings within the array are represented by empty strings.StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], "--") = "a--b--c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join(["a", "b", "c"], "") = "abc" StringUtils.join([null, "", "a"], ',') = ",,a"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use, null treated as ""- Returns:
- the joined String,
nullif null array input
-
join
public static String join(Object[] array, String separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. A
nullseparator is the same as an empty String (""). Null objects or empty strings within the array are represented by empty strings.StringUtils.join(null, *, *, *) = null StringUtils.join([], *, *, *) = "" StringUtils.join([null], *, *, *) = "" StringUtils.join(["a", "b", "c"], "--", 0, 3) = "a--b--c" StringUtils.join(["a", "b", "c"], "--", 1, 3) = "b--c" StringUtils.join(["a", "b", "c"], "--", 2, 3) = "c" StringUtils.join(["a", "b", "c"], "--", 2, 2) = "" StringUtils.join(["a", "b", "c"], null, 0, 3) = "abc" StringUtils.join(["a", "b", "c"], "", 0, 3) = "abc" StringUtils.join([null, "", "a"], ',', 0, 3) = ",,a"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use, null treated as ""startIndex- the first index to start joining from.endIndex- the index to stop joining from (exclusive).- Returns:
- the joined String,
nullif null array input; or the empty string ifendIndex - startIndex <= 0. The number of joined entries is given byendIndex - startIndex - Throws:
ArrayIndexOutOfBoundsException- ife
startIndex < 0or
startIndex >= array.length()or
endIndex < 0or
endIndex > array.length()
-
join
public static String join(Iterator<?> iterator, char separator)
Joins the elements of the provided
Iteratorinto a single String containing the provided elements.No delimiter is added before or after the list. Null objects or empty strings within the iteration are represented by empty strings.
See the examples here:
join(Object[],char).- Parameters:
iterator- theIteratorof values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null iterator input - Since:
- 2.0
-
join
public static String join(Iterator<?> iterator, String separator)
Joins the elements of the provided
Iteratorinto a single String containing the provided elements.No delimiter is added before or after the list. A
nullseparator is the same as an empty String ("").See the examples here:
join(Object[],String).- Parameters:
iterator- theIteratorof values to join together, may be nullseparator- the separator character to use, null treated as ""- Returns:
- the joined String,
nullif null iterator input
-
join
public static String join(Iterable<?> iterable, char separator)
Joins the elements of the provided
Iterableinto a single String containing the provided elements.No delimiter is added before or after the list. Null objects or empty strings within the iteration are represented by empty strings.
See the examples here:
join(Object[],char).- Parameters:
iterable- theIterableproviding the values to join together, may be nullseparator- the separator character to use- Returns:
- the joined String,
nullif null iterator input - Since:
- 2.3
-
join
public static String join(Iterable<?> iterable, String separator)
Joins the elements of the provided
Iterableinto a single String containing the provided elements.No delimiter is added before or after the list. A
nullseparator is the same as an empty String ("").See the examples here:
join(Object[],String).- Parameters:
iterable- theIterableproviding the values to join together, may be nullseparator- the separator character to use, null treated as ""- Returns:
- the joined String,
nullif null iterator input - Since:
- 2.3
-
isNumeric
public static boolean isNumeric(CharSequence cs)
Checks if the CharSequence contains only Unicode digits. A decimal point is not a Unicode digit and returns false.
nullwill returnfalse. An empty CharSequence (length()=0) will returnfalse.Note that the method does not allow for a leading sign, either positive or negative. Also, if a String passes the numeric test, it may still generate a NumberFormatException when parsed by Integer.parseInt or Long.parseLong, e.g. if the value is outside the range for int or long respectively.
StringUtils.isNumeric(null) = false StringUtils.isNumeric("") = false StringUtils.isNumeric(" ") = false StringUtils.isNumeric("123") = true StringUtils.isNumeric("१२३") = true StringUtils.isNumeric("12 3") = false StringUtils.isNumeric("ab2c") = false StringUtils.isNumeric("12-3") = false StringUtils.isNumeric("12.3") = false StringUtils.isNumeric("-123") = false StringUtils.isNumeric("+123") = false- Parameters:
cs- the CharSequence to check, may be null- Returns:
trueif only contains digits, and is non-null- Since:
- 3.0 Changed signature from isNumeric(String) to isNumeric(CharSequence), 3.0 Changed "" to return false and not true
-
startsWith
public static boolean startsWith(CharSequence str, CharSequence prefix)
Check if a CharSequence starts with a specified prefix.
nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case sensitive.StringUtils.startsWith(null, null) = true StringUtils.startsWith(null, "abc") = false StringUtils.startsWith("abcdef", null) = false StringUtils.startsWith("abcdef", "abc") = true StringUtils.startsWith("ABCDEF", "abc") = false- Parameters:
str- the CharSequence to check, may be nullprefix- the prefix to find, may be null- Returns:
trueif the CharSequence starts with the prefix, case sensitive, or bothnull- Since:
- 2.4, 3.0 Changed signature from startsWith(String, String) to startsWith(CharSequence, CharSequence)
- See Also:
String.startsWith(String)
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(CharSequence str, CharSequence prefix)
Case insensitive check if a CharSequence starts with a specified prefix.
nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case insensitive.StringUtils.startsWithIgnoreCase(null, null) = true StringUtils.startsWithIgnoreCase(null, "abc") = false StringUtils.startsWithIgnoreCase("abcdef", null) = false StringUtils.startsWithIgnoreCase("abcdef", "abc") = true StringUtils.startsWithIgnoreCase("ABCDEF", "abc") = true- Parameters:
str- the CharSequence to check, may be nullprefix- the prefix to find, may be null- Returns:
trueif the CharSequence starts with the prefix, case insensitive, or bothnull- Since:
- 2.4, 3.0 Changed signature from startsWithIgnoreCase(String, String) to startsWithIgnoreCase(CharSequence, CharSequence)
- See Also:
String.startsWith(String)
-
indexOf
public static int indexOf(Object[] array, Object objectToFind)
Finds the index of the given object in the array.
This method returns
INDEX_NOT_FOUND(-1) for anullinput array.- Parameters:
array- the array to search through for the object, may benullobjectToFind- the object to find, may benull- Returns:
- the index of the object within the array,
INDEX_NOT_FOUND(-1) if not found ornullarray input
-
indexOf
public static int indexOf(Object[] array, Object objectToFind, int startIndex)
Finds the index of the given object in the array starting at the given index.
This method returns
INDEX_NOT_FOUND(-1) for anullinput array.A negative startIndex is treated as zero. A startIndex larger than the array length will return
INDEX_NOT_FOUND(-1).- Parameters:
array- the array to search through for the object, may benullobjectToFind- the object to find, may benullstartIndex- the index to start searching at- Returns:
- the index of the object within the array starting at the index,
INDEX_NOT_FOUND(-1) if not found ornullarray input
-
-