Top Description Fields Constructors Methods
com.oracle.bmc.util.internal

public final Enum StringUtils

extends Enum<StringUtils>
Class Inheritance
Imports
java.util.Collection, .Map, .Random, java.util.regex.Pattern, java.util.stream.Collectors

String manipulation utilities.

Field Summary

Modifier and TypeField and Description
private static final Random

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the string contains the search string, or false if either is null
contains
(String
string
s
,
String
substring to search for
searchStr
)

Return true if the string contains the search string, or false if either is null.

public static boolean

Returns:

true if the string contains the search string, or false if either is null
containsIgnoreCase
(String
string
s
,
String
substring to search for
searchStr
)

Return true if the string contains the search string, ignoring case, or false if either is null.

public static boolean

Returns:

true if equals, ignoring case
equalsIgnoreCase
(String
first string
s1
,
String
second string
s2
)

Null-safe case-insensitive equals.

public static boolean

Returns:

true if all of the strings are blank
isAllBlank
(String...
strings to check
strings
)

Returns true if all of the strings passed in are blank, as determined by isBlank.

public static boolean

Returns:

true if any of the strings are blank
isAnyBlank
(String...
strings to check
strings
)

Returns true if any of the strings passed in are blank, as determined by isBlank.

public static boolean

Returns:

true if this string is either null or just whitespace.
isBlank
(String
the string
s
)

Return true if this string is either null or just whitespace.

public static boolean

Returns:

true if empty
isEmpty
(String
string to check
s
)

Returns true if the string is empty.

public static boolean

Returns:

true if none of the strings are blank
isNoneBlank
(String...
strings to check
strings
)

Returns true if none of the strings passed in are blank, as determined by isBlank.

public static boolean

Returns:

true if this string is not null and not just whitespace.
isNotBlank
(String
the string
s
)

Return true if this string is not null and not just whitespace.

public static boolean

Returns:

true if not empty
isNotEmpty
(String
string to check
s
)

Returns true if the string is not empty.

public static String

Returns:

joined string
join
(Collection<?>
collection of objects
objects
,
String
delimiter between the objects
delimiter
)

Join the collection of objects to a string.

public static String

Returns:

first s
left
(String
string
s
,
int
number of characters
length
)

Return the first length characters of the string.

public static int

Returns:

length of string or 0 if string is null
length
(String
string
s
)

Return the length of the string, or 0 if the string is null.

public static String

Returns:

the random string
random
(int
length in characters
length
,
String
string with allowed characters
allowed
)

Returns a string of the requested length, made up of characters from the allowed string.

public static String

Returns:

the random string
randomAlphabetic
(int
minimum length (inclusive)
minLengthInclusive
,
int
maximum length (exclusive)
maxLengthExclusive
)

Returns a string of random alphabetic characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.

public static String

Returns:

the random string
randomAlphabetic
(int
length in characters
length
)

Returns a string of random alphabetic characters of the requested length.

public static String

Returns:

the random string
randomPrint
(int
minimum length (inclusive)
minLengthInclusive
,
int
maximum length (exclusive)
maxLengthExclusive
)

Returns a string of random printable characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.

public static String

Returns:

the random string
randomPrint
(int
length in characters
length
)

Returns a string of random printable characters of the requested length.

public static String

Returns:

repeated substring
repeat
(String
substring
substring
,
int
number of times to occur
count
)

Repeat the substring count times.

public static String

Returns:

replaced string
replace
(String
template string
template
,
Map<String, String>
map from key to replacement value
replacements
,
String
prefix of the placeholder
prefix
,
String
suffix of the placeholder
suffix
)

Replace the placeholders in the template with the values in the replacement mapping.

public static String

Returns:

string in uppercase, or null if it was null
upperCase
(String
string to convert to uppercase
s
)

Returns the string in uppercase, or null if it was null

public static StringUtils
public static StringUtils[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

RANDOMback to summary
private static final Random RANDOM

Constructor Detail

StringUtilsback to summary
private StringUtils()

Method Detail

containsback to summary
public static boolean contains(String s, String searchStr)

Return true if the string contains the search string, or false if either is null.

Parameters
s:String

string

searchStr:String

substring to search for

Returns:boolean

true if the string contains the search string, or false if either is null

containsIgnoreCaseback to summary
public static boolean containsIgnoreCase(String s, String searchStr)

Return true if the string contains the search string, ignoring case, or false if either is null.

Parameters
s:String

string

searchStr:String

substring to search for

Returns:boolean

true if the string contains the search string, or false if either is null

equalsIgnoreCaseback to summary
public static boolean equalsIgnoreCase(String s1, String s2)

Null-safe case-insensitive equals.

Parameters
s1:String

first string

s2:String

second string

Returns:boolean

true if equals, ignoring case

isAllBlankback to summary
public static boolean isAllBlank(String... strings)

Returns true if all of the strings passed in are blank, as determined by isBlank.

Parameters
strings:String[]

strings to check

Returns:boolean

true if all of the strings are blank

isAnyBlankback to summary
public static boolean isAnyBlank(String... strings)

Returns true if any of the strings passed in are blank, as determined by isBlank.

Parameters
strings:String[]

strings to check

Returns:boolean

true if any of the strings are blank

isBlankback to summary
public static boolean isBlank(String s)

Return true if this string is either null or just whitespace.

Parameters
s:String

the string

Returns:boolean

true if this string is either null or just whitespace.

isEmptyback to summary
public static boolean isEmpty(String s)

Returns true if the string is empty.

Parameters
s:String

string to check

Returns:boolean

true if empty

isNoneBlankback to summary
public static boolean isNoneBlank(String... strings)

Returns true if none of the strings passed in are blank, as determined by isBlank.

Parameters
strings:String[]

strings to check

Returns:boolean

true if none of the strings are blank

isNotBlankback to summary
public static boolean isNotBlank(String s)

Return true if this string is not null and not just whitespace.

Parameters
s:String

the string

Returns:boolean

true if this string is not null and not just whitespace.

isNotEmptyback to summary
public static boolean isNotEmpty(String s)

Returns true if the string is not empty.

Parameters
s:String

string to check

Returns:boolean

true if not empty

joinback to summary
public static String join(Collection<?> objects, String delimiter)

Join the collection of objects to a string.

Objects that are null are represented by the empty string.

Parameters
objects:Collection<?>

collection of objects

delimiter:String

delimiter between the objects

Returns:String

joined string

leftback to summary
public static String left(String s, int length)

Return the first length characters of the string.

Parameters
s:String

string

length:int

number of characters

Returns:String

first s

lengthback to summary
public static int length(String s)

Return the length of the string, or 0 if the string is null.

Parameters
s:String

string

Returns:int

length of string or 0 if string is null

randomback to summary
public static String random(int length, String allowed)

Returns a string of the requested length, made up of characters from the allowed string.

Parameters
length:int

length in characters

allowed:String

string with allowed characters

Returns:String

the random string

randomAlphabeticback to summary
public static String randomAlphabetic(int minLengthInclusive, int maxLengthExclusive)

Returns a string of random alphabetic characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.

The characters range from 'A' - 'Z' or from 'a' - 'z' (all inclusive).

Parameters
minLengthInclusive:int

minimum length (inclusive)

maxLengthExclusive:int

maximum length (exclusive)

Returns:String

the random string

randomAlphabeticback to summary
public static String randomAlphabetic(int length)

Returns a string of random alphabetic characters of the requested length.

The characters range from 'A' - 'Z' or from 'a' - 'z' (all inclusive).

Parameters
length:int

length in characters

Returns:String

the random string

randomPrintback to summary
public static String randomPrint(int minLengthInclusive, int maxLengthExclusive)

Returns a string of random printable characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.

The characters have ASCII codes ranging from 32 to 125 (both inclusive) and include spaces.

Parameters
minLengthInclusive:int

minimum length (inclusive)

maxLengthExclusive:int

maximum length (exclusive)

Returns:String

the random string

randomPrintback to summary
public static String randomPrint(int length)

Returns a string of random printable characters of the requested length.

The characters have ASCII codes ranging from 32 to 125 (both inclusive) and include spaces.

Parameters
length:int

length in characters

Returns:String

the random string

repeatback to summary
public static String repeat(String substring, int count)

Repeat the substring count times.

Parameters
substring:String

substring

count:int

number of times to occur

Returns:String

repeated substring

replaceback to summary
public static String replace(String template, Map<String, String> replacements, String prefix, String suffix)

Replace the placeholders in the template with the values in the replacement mapping.

Parameters
template:String

template string

replacements:Map<String, String>

map from key to replacement value

prefix:String

prefix of the placeholder

suffix:String

suffix of the placeholder

Returns:String

replaced string

upperCaseback to summary
public static String upperCase(String s)

Returns the string in uppercase, or null if it was null

Parameters
s:String

string to convert to uppercase

Returns:String

string in uppercase, or null if it was null

valueOfback to summary
public static StringUtils valueOf(String name)
valuesback to summary
public static StringUtils[] values()