Package com.brightcove.player.util
Class StringUtil
java.lang.Object
com.brightcove.player.util.StringUtil
Some assorted utility methods for dealing with Strings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFormat string used for long time expressions which include hours.static final StringFormat string used for short time expressions which are less than an hour.static final StringFormat string used for short time expressions which are less than ten minutes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDetermines if given string is empty or null.static StringJoins the Strings in the given array together into a single String using the specified separator String.static StringJoins the Strings in the given List together into a single String using the specified separator String.static CharSequencereplaceAll(CharSequence template, String[] sources, CharSequence[] destinations) This method is based on Android'sTextUtils.replace(CharSequence, String[], CharSequence[])and extends its functionality by replacing all instances of each String specified in the sources parameter with the associated destination CharSequence.static StringstringForTime(long milliseconds) Formats the given time duration value (in milliseconds) as a time string in one of the following formats: HH:MM:SS where the timeframe is greater than 1 hour MM:SS where the timeframe is less than an hour M:SS where the timeframe is less than ten minutes
-
Field Details
-
LONG_TIME_FORMAT
Format string used for long time expressions which include hours.- See Also:
-
SHORT_TIME_FORMAT
Format string used for short time expressions which are less than an hour.- See Also:
-
SHORTER_TIME_FORMAT
Format string used for short time expressions which are less than ten minutes.- See Also:
-
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
isEmpty
Determines if given string is empty or null.- Parameters:
str- the String to evaluate- Returns:
- true if the String is null or contains only whitespace, false otherwise
-
join
Joins the Strings in the given List together into a single String using the specified separator String.- Parameters:
stringsToJoin- the List of Strings to joinseparator- the String to be inserted between each element of the array- Returns:
- the concatenated String
-
stringForTime
Formats the given time duration value (in milliseconds) as a time string in one of the following formats:- HH:MM:SS where the timeframe is greater than 1 hour
- MM:SS where the timeframe is less than an hour
- M:SS where the timeframe is less than ten minutes
- Parameters:
milliseconds- the time duration to format, in milliseconds- Returns:
- the formatted string expression for the given time duration
-
join
Joins the Strings in the given array together into a single String using the specified separator String.- Parameters:
stringsToJoin- the array of Strings to joinseparator- the String to be inserted between each element of the array- Returns:
- the concatenated String
-
replaceAll
public static CharSequence replaceAll(CharSequence template, String[] sources, CharSequence[] destinations) This method is based on Android'sTextUtils.replace(CharSequence, String[], CharSequence[])and extends its functionality by replacing all instances of each String specified in the sources parameter with the associated destination CharSequence. It is important to note that this exists for CharSequences (which are not necessarily Strings) that haveSpannedportions and for which the relevant spans must be maintained. If we were to useString.replaceAll(String, String)in cases such as these, the span information would be lost.- Parameters:
template- the CharSequence on which we should perform replacementssources- an Array of Strings to find and replace in templatedestinations- an Array of CharSequences corresponding to the sources strings which will serve as replacements- Returns:
- the CharSequence with all replacements applied
- See Also:
-
TextUtils.replace(CharSequence, String[], CharSequence[])
-