public final class

StringHelper

extends Object
java.lang.Object
   ↳ org.hibernate.util.StringHelper

Summary

Constants
String WHITESPACE
Public Methods
static String[] add(String[] x, String sep, String[] y)
static boolean booleanValue(String tfString)
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)
static int countUnquoted(String string, char character)
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 boolean isEmpty(String string)
static boolean isNotEmpty(String string)
static boolean isQuoted(String name, Dialect dialect)
Determine if the given name is quoted.
static boolean isQuoted(String name)
Determine if the given string is quoted (wrapped by '`' characters at beginning and end).
static String join(String seperator, String[] strings)
static String join(String seperator, Iterator objects)
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 partiallyUnqualify(String name, String qualifierBase)
Partially unqualifies a qualified name.
static String qualifier(String qualifiedName)
static String[] qualify(String prefix, String[] names)
static String qualify(String prefix, String name)
static String quote(String name)
Return a representation of the given name ensuring quoting (wrapped with '`' characters).
static String repeat(String string, int times)
static String repeat(char character, int times)
static String replace(String template, String placeholder, String replacement)
static String replace(String beforePlaceholder, String afterPlaceholder, String placeholder, String replacement, boolean wholeWords, boolean encloseInParensIfNecessary)
static String replace(String template, String placeholder, String replacement, boolean wholeWords, boolean encloseInParensIfNecessary)
static String[] replace(String[] templates, String placeholder, String replacement)
static String replace(String template, String placeholder, String replacement, boolean wholeWords)
static String replaceOnce(String template, String placeholder, String replacement)
static String root(String qualifiedName)
static String[] split(String seperators, String list)
static String[] split(String seperators, String list, boolean include)
static String[] suffix(String[] columns, String suffix)
static String toLowerCase(String str)
static String toString(Object[] array)
static String toUpperCase(String str)
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)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String WHITESPACE

Constant Value: " "

Public Methods

public static String[] add (String[] x, String sep, String[] y)

public static boolean booleanValue (String tfString)

public static String collapse (String name)

Collapses a name. Mainly intended for use with classnames, where an example might serve best to explain. Imagine you have a class named 'org.hibernate.util.StringHelper'; calling collapse on that classname will result in 'o.h.u.StringHelper'.

Parameters
name The name to collapse.
Returns
  • The collapsed name.

public static String collapseQualifier (String qualifier, boolean includeDots)

Given a qualifier, collapse it.

Parameters
qualifier The qualifier to collapse.
includeDots Should we include the dots in the collapsed form?
Returns
  • The collapsed form.

public static String collapseQualifierBase (String name, String qualifierBase)

Cross between collapse(String) and partiallyUnqualify(String, String). Functions much like collapse(String) except that only the qualifierBase is collapsed. For example, with a base of 'org.hibernate' the name 'org.hibernate.util.StringHelper' would become 'o.h.util.StringHelper'.

Parameters
name The (potentially) qualified name.
qualifierBase The qualifier base.
Returns
  • The name itself if it does not begin with the qualifierBase, or the properly collapsed form otherwise.

public static int countUnquoted (String string, char character)

public static int firstIndexOfChar (String sqlString, String string, int startindex)

public static String generateAlias (String description)

public static String generateAlias (String description, int unique)

Generate a nice alias for the given class name or collection role name and unique integer. Subclasses of Loader do not have to use aliases of this form.

Parameters
description The base name (usually an entity-name or collection-role)
unique A uniquing value
Returns
  • an alias of the form foo1_

public static char getFirstNonWhitespaceCharacter (String str)

public static char getLastNonWhitespaceCharacter (String str)

public static boolean isEmpty (String string)

public static boolean isNotEmpty (String string)

public static boolean isQuoted (String name, Dialect dialect)

Determine if the given name is quoted. It is considered quoted if either:

  1. starts AND ends with backticks (`)
  2. starts with dialect-specified open-quote AND ends with dialect-specified close-quote

Parameters
name The name to check
dialect The dialect (to determine the "real" quoting chars).
Returns
  • True if quoted, false otherwise

public static boolean isQuoted (String name)

Determine if the given string is quoted (wrapped by '`' characters at beginning and end).

Parameters
name The name to check.
Returns
  • True if the given string starts and ends with '`'; false otherwise.

public static String join (String seperator, String[] strings)

public static String join (String seperator, Iterator objects)

public static int lastIndexOfLetter (String string)

public static int[] locateUnquoted (String string, char character)

public static String moveAndToBeginning (String filter)

public static String[] multiply (String string, Iterator placeholders, Iterator replacements)

public static String partiallyUnqualify (String name, String qualifierBase)

Partially unqualifies a qualified name. For example, with a base of 'org.hibernate' the name 'org.hibernate.util.StringHelper' would become 'util.StringHelper'.

Parameters
name The (potentially) qualified name.
qualifierBase The qualifier base.
Returns
  • The name itself, or the partially unqualified form if it begins with the qualifier base.

public static String qualifier (String qualifiedName)

public static String[] qualify (String prefix, String[] names)

public static String qualify (String prefix, String name)

public static String quote (String name)

Return a representation of the given name ensuring quoting (wrapped with '`' characters). If already wrapped return name.

Parameters
name The name to quote.
Returns
  • The quoted version.

public static String repeat (String string, int times)

public static String repeat (char character, int times)

public static String replace (String template, String placeholder, String replacement)

public static String replace (String beforePlaceholder, String afterPlaceholder, String placeholder, String replacement, boolean wholeWords, boolean encloseInParensIfNecessary)

public static String replace (String template, String placeholder, String replacement, boolean wholeWords, boolean encloseInParensIfNecessary)

public static String[] replace (String[] templates, String placeholder, String replacement)

public static String replace (String template, String placeholder, String replacement, boolean wholeWords)

public static String replaceOnce (String template, String placeholder, String replacement)

public static String root (String qualifiedName)

public static String[] split (String seperators, String list)

public static String[] split (String seperators, String list, boolean include)

public static String[] suffix (String[] columns, String suffix)

public static String toLowerCase (String str)

public static String toString (Object[] array)

public static String toUpperCase (String str)

public static String truncate (String string, int length)

public static String unqualify (String qualifiedName)

public static String unqualifyEntityName (String entityName)

public static String unquote (String name)

Return the unquoted version of name (stripping the start and end '`' characters if present).

Parameters
name The name to be unquoted.
Returns
  • The unquoted version.

public static String[] unquote (String[] names, Dialect dialect)

Return the unquoted version of name stripping the start and end quote characters.

Parameters
names The names to be unquoted.
dialect The dialect (to determine the "real" quoting chars).
Returns
  • The unquoted versions.

public static String unquote (String name, Dialect dialect)

Return the unquoted version of name stripping the start and end quote characters.

Parameters
name The name to be unquoted.
dialect The dialect (to determine the "real" quoting chars).
Returns
  • The unquoted version.

public static String unroot (String qualifiedName)