public final class StringHelper extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
StringHelper.Renderer<T> |
Modifier and Type | Field and Description |
---|---|
static String |
BATCH_ID_PLACEHOLDER |
static String[] |
EMPTY_STRINGS |
static String |
WHITESPACE |
Modifier and Type | Method and Description |
---|---|
static String[] |
add(String[] x,
String sep,
String[] y) |
static boolean |
booleanValue(String tfString) |
static StringBuilder |
buildBatchFetchRestrictionFragment(String alias,
String[] columnNames,
Dialect dialect) |
static String |
collapse(String name)
Collapses a name.
|
static String |
collapseQualifier(String qualifier,
boolean includeDots)
Given a qualifier, collapse it.
|
static String |
collapseQualifierBase(String name,
String qualifierBase)
Cross between
collapse(java.lang.String) and partiallyUnqualify(java.lang.String, java.lang.String) . |
static int |
countUnquoted(String string,
char character) |
static String |
expandBatchIdPlaceholder(String sql,
Serializable[] ids,
String alias,
String[] keyColumnNames,
Dialect dialect) |
static int |
firstIndexOfChar(String sqlString,
BitSet keys,
int startindex) |
static int |
firstIndexOfChar(String sqlString,
String string,
int startindex) |
static String |
generateAlias(String description) |
static String |
generateAlias(String description,
int unique)
Generate a nice alias for the given class name or collection role name and unique integer.
|
static char |
getFirstNonWhitespaceCharacter(String str) |
static char |
getLastNonWhitespaceCharacter(String str) |
static String |
getNonEmptyOrConjunctionIfBothNonEmpty(String firstExpression,
String secondExpression) |
static int |
indexOfIdentifierWord(String str,
String word)
Used to find the ordinal parameters (e.g.
|
static boolean |
isEmpty(String string) |
static boolean |
isEmptyOrWhiteSpace(String string) |
static boolean |
isNotEmpty(String string) |
static boolean |
isQuoted(String name)
Determine if the given string is quoted (wrapped by '`' characters at beginning and end).
|
static boolean |
isQuoted(String name,
Dialect dialect)
Determine if the given name is quoted.
|
static <T> String |
join(Collection<T> values,
StringHelper.Renderer<T> renderer) |
static String |
join(String seperator,
Iterator<?> objects) |
static <T> String |
join(T[] values,
StringHelper.Renderer<T> renderer) |
static String |
joinWithQualifierAndSuffix(String[] values,
String qualifier,
String suffix,
String deliminator) |
static int |
lastIndexOfLetter(String string) |
static int[] |
locateUnquoted(String string,
char character) |
static String |
moveAndToBeginning(String filter) |
static String[] |
multiply(String string,
Iterator placeholders,
Iterator replacements) |
static String |
nullIfEmpty(String value) |
static List<String> |
parseCommaSeparatedString(String incomingString) |
static String |
partiallyUnqualify(String name,
String qualifierBase)
Partially unqualifies a qualified name.
|
static String |
qualifier(String qualifiedName) |
static String |
qualify(String prefix,
String name) |
static String[] |
qualify(String prefix,
String[] names) |
static String |
qualifyConditionally(String prefix,
String name) |
static String[] |
qualifyIfNot(String prefix,
String[] names) |
static String |
quote(String name)
Return a representation of the given name ensuring quoting (wrapped with '`' characters).
|
static String |
repeat(char character,
int times) |
static String |
repeat(String string,
int times) |
static String |
repeat(String string,
int times,
String deliminator) |
static String[] |
replace(String[] templates,
String placeholder,
String replacement) |
static String |
replace(String template,
String placeholder,
String replacement) |
static String |
replace(String template,
String placeholder,
String replacement,
boolean wholeWords) |
static String |
replace(String template,
String placeholder,
String replacement,
boolean wholeWords,
boolean encloseInParensIfNecessary) |
static String |
replace(String beforePlaceholder,
String afterPlaceholder,
String placeholder,
String replacement,
boolean wholeWords,
boolean encloseInParensIfNecessary) |
static String |
replaceOnce(String template,
String placeholder,
String replacement) |
static String |
root(String qualifiedName) |
static String[] |
split(String separators,
String list) |
static String[] |
split(String separators,
String list,
boolean include) |
static String[] |
splitTrimmingTokens(String separators,
String list,
boolean include) |
static String[] |
suffix(String[] columns,
String suffix) |
static String[] |
toArrayElement(String s)
Takes a String s and returns a new String[1] with s as the only element.
|
static String |
toString(Object[] array) |
static String |
truncate(String string,
int length) |
static String |
unqualify(String qualifiedName) |
static String |
unqualifyEntityName(String entityName) |
static String |
unquote(String name)
Return the unquoted version of name (stripping the start and end '`' characters if present).
|
static String[] |
unquote(String[] names,
Dialect dialect)
Return the unquoted version of name stripping the start and end quote characters.
|
static String |
unquote(String name,
Dialect dialect)
Return the unquoted version of name stripping the start and end quote characters.
|
static String |
unroot(String qualifiedName) |
public static final String WHITESPACE
public static final String[] EMPTY_STRINGS
public static final String BATCH_ID_PLACEHOLDER
public static int lastIndexOfLetter(String string)
public static String joinWithQualifierAndSuffix(String[] values, String qualifier, String suffix, String deliminator)
public static String repeat(char character, int times)
public static String replace(String template, String placeholder, String replacement, boolean wholeWords)
public static String replace(String template, String placeholder, String replacement, boolean wholeWords, boolean encloseInParensIfNecessary)
public static String replace(String beforePlaceholder, String afterPlaceholder, String placeholder, String replacement, boolean wholeWords, boolean encloseInParensIfNecessary)
public static int indexOfIdentifierWord(String str, String word)
public static char getLastNonWhitespaceCharacter(String str)
public static char getFirstNonWhitespaceCharacter(String str)
public static String replaceOnce(String template, String placeholder, String replacement)
public static String[] splitTrimmingTokens(String separators, String list, boolean include)
public static String collapse(String name)
name
- The name to collapse.public static String collapseQualifier(String qualifier, boolean includeDots)
qualifier
- The qualifier to collapse.includeDots
- Should we include the dots in the collapsed form?public static String partiallyUnqualify(String name, String qualifierBase)
name
- The (potentially) qualified name.qualifierBase
- The qualifier base.public static String collapseQualifierBase(String name, String qualifierBase)
collapse(java.lang.String)
and partiallyUnqualify(java.lang.String, java.lang.String)
. Functions much like collapse(java.lang.String)
except that only the qualifierBase is collapsed. For example, with a base of 'org.hibernate' the name
'org.hibernate.internal.util.StringHelper' would become 'o.h.util.StringHelper'.name
- The (potentially) qualified name.qualifierBase
- The qualifier base.public static boolean booleanValue(String tfString)
public static String[] multiply(String string, Iterator placeholders, Iterator replacements)
public static int countUnquoted(String string, char character)
public static int[] locateUnquoted(String string, char character)
public static boolean isNotEmpty(String string)
public static boolean isEmpty(String string)
public static boolean isEmptyOrWhiteSpace(String string)
public static int firstIndexOfChar(String sqlString, String string, int startindex)
public static String generateAlias(String description, int unique)
description
- The base name (usually an entity-name or collection-role)unique
- A uniquing valuepublic static boolean isQuoted(String name)
name
- The name to check.public static String quote(String name)
name
- The name to quote.public static String unquote(String name)
name
- The name to be unquoted.public static boolean isQuoted(String name, Dialect dialect)
open-quote
AND ends with dialect-specified close-quote
name
- The name to checkdialect
- The dialect (to determine the "real" quoting chars).public static String unquote(String name, Dialect dialect)
name
- The name to be unquoted.dialect
- The dialect (to determine the "real" quoting chars).public static String[] unquote(String[] names, Dialect dialect)
names
- The names to be unquoted.dialect
- The dialect (to determine the "real" quoting chars).public static StringBuilder buildBatchFetchRestrictionFragment(String alias, String[] columnNames, Dialect dialect)
public static String expandBatchIdPlaceholder(String sql, Serializable[] ids, String alias, String[] keyColumnNames, Dialect dialect)
public static String[] toArrayElement(String s)
s
- public static List<String> parseCommaSeparatedString(String incomingString)
public static <T> String join(Collection<T> values, StringHelper.Renderer<T> renderer)
public static <T> String join(T[] values, StringHelper.Renderer<T> renderer)
public static String getNonEmptyOrConjunctionIfBothNonEmpty(String firstExpression, String secondExpression)
firstExpression
- the first expressionsecondExpression
- the second expressionfirstExpression
and secondExpression
are both non-empty,
then "( " + firstExpression
+ " ) and ( " + secondExpression
+ " )" is returned;
if firstExpression
is non-empty and secondExpression
is empty,
then firstExpression
is returned;
if firstExpression
is empty and secondExpression
is non-empty,
then secondExpression
is returned;
if both firstExpression
and secondExpression
are empty, then null is returned.Copyright © 2019 JBoss by Red Hat. All rights reserved.