public class TextTools extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
TextTools.ConstantStringReplacementGenerator |
static interface |
TextTools.StringReplacementGenerator |
| Constructor and Description |
|---|
TextTools() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isAlphaNumeric(char c)
Returns true if the char c is alpha numeric i.e it belongs to one of the following ranges [0,9], [A,Z] or [a,z]
|
static String |
replace(String string,
String pattern,
String replacement)
Replace occurence in a string.
|
static String |
replaceAllInstancesOfBoundedString(String initial,
String prefix,
String suffix,
String replacement)
Same as replaceBoundedString(initial, prefix, suffix, replacement, true, false).
|
static String |
replaceAllInstancesOfBoundedString(String initial,
String prefix,
String suffix,
TextTools.StringReplacementGenerator generator) |
static String |
replaceBoundedString(String initial,
String prefix,
String suffix,
String replacement,
boolean replaceIfBoundedStringEmpty,
boolean keepBoundaries) |
static String |
replaceBoundedString(String initial,
String prefix,
String suffix,
String replacement,
boolean replaceIfBoundedStringEmpty,
boolean keepBoundaries,
boolean suffixIsOptional) |
static String |
replaceBoundedString(String initial,
String prefix,
String suffix,
TextTools.StringReplacementGenerator generator,
boolean replaceIfBoundedStringEmpty,
boolean keepBoundaries) |
static String |
replaceBoundedString(String initial,
String prefix,
String suffix,
TextTools.StringReplacementGenerator generator,
boolean replaceIfBoundedStringEmpty,
boolean keepBoundaries,
boolean suffixIsOptional)
Replace instances of Strings delimited by the given prefix and suffix (hence, bounded) by a replacement String
computed by the specified StringReplacementGenerator based on the current bounded String match.
|
static char |
toHex(int z)
Returns the hexadecimal value of the provided numeric value.
|
public static boolean isAlphaNumeric(char c)
c - the char to testpublic static char toHex(int z)
throws IllegalArgumentException
z - the numeric value to convertIllegalArgumentException - if the value is not between 0 and 15public static String replace(String string, String pattern, String replacement)
string - the source stringpattern - the replaced patternreplacement - the replacement textpublic static String replaceAllInstancesOfBoundedString(String initial, String prefix, String suffix, String replacement)
initial - prefix - suffix - replacement - public static String replaceAllInstancesOfBoundedString(String initial, String prefix, String suffix, TextTools.StringReplacementGenerator generator)
public static String replaceBoundedString(String initial, String prefix, String suffix, String replacement, boolean replaceIfBoundedStringEmpty, boolean keepBoundaries)
public static String replaceBoundedString(String initial, String prefix, String suffix, String replacement, boolean replaceIfBoundedStringEmpty, boolean keepBoundaries, boolean suffixIsOptional)
public static String replaceBoundedString(String initial, String prefix, String suffix, TextTools.StringReplacementGenerator generator, boolean replaceIfBoundedStringEmpty, boolean keepBoundaries)
public static String replaceBoundedString(String initial, String prefix, String suffix, TextTools.StringReplacementGenerator generator, boolean replaceIfBoundedStringEmpty, boolean keepBoundaries, boolean suffixIsOptional)
replaceIfBoundedStringEmpty to false. It is also possible to keep the boundaries (prefix
and suffix) after the substitution by setting keepBoundaries to true. initial - the String in which we want to replace bounded Stringsprefix - the prefix used identify the beginning of the String targeted for replacementsuffix - the suffix used to identify the end of the String targeted for replacementgenerator - the StringReplacementGeneraot generating replacements based on the current
bounded String matchreplaceIfBoundedStringEmpty - true to allow replacement of empty Strings (in essence, insertion
of the replacement String between the prefix and suffix)keepBoundaries - true to keep the prefix and suffix markers in the resulting
StringsuffixIsOptional - whether or not the suffix is optionalCopyright © 2025 JBoss by Red Hat. All Rights Reserved.