Class UnicodeString
- java.lang.Object
-
- jetbrains.buildServer.serverSide.db.UnicodeString
-
- All Implemented Interfaces:
Serializable
,CharSequence
,Comparable<UnicodeString>
public final class UnicodeString extends Object implements Serializable, Comparable<UnicodeString>, CharSequence
A simple wrapper forString
that marks the stringa as a Unicode string. When passing this string via JDBC, thePreparedStatement.setNString(int, java.lang.String)
orPreparedStatement.setNClob(int, java.sql.NClob)
is used. This class is immutable.- Since:
- 9.0
- Author:
- Leonid Bushuev from JetBrains
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description UnicodeString(String string)
Wraps a string to mark it as Unicode.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description char
charAt(int index)
static int
compare(UnicodeString str1, UnicodeString str2)
Safely compares two unicode strings.int
compareTo(UnicodeString that)
boolean
equals(Object that)
byte[]
getBytes()
static byte[]
getBytes(String string)
int
hashCode()
int
length()
CharSequence
subSequence(int start, int end)
UnicodeString
substring(int beginIndex)
UnicodeString
substring(int beginIndex, int endIndex)
String
toString()
static UnicodeString
unicode(String string)
Wraps a string to mark it as Unicode.static UnicodeString
unicode(String string, int limitLength)
Wraps a string to mark it as Unicode.static UnicodeString
unicodeOrNull(String string)
Wraps a string to mark it as Unicode.static UnicodeString
unicodeOrNull(String string, int limitLength)
Wraps a string to mark it as Unicode.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Field Detail
-
string
@NotNull public final String string
Underlying wrapped string. Not null.
-
-
Constructor Detail
-
UnicodeString
public UnicodeString(@NotNull String string)
Wraps a string to mark it as Unicode.- Parameters:
string
- the string to wrap.
-
-
Method Detail
-
unicode
@NotNull public static UnicodeString unicode(@NotNull String string)
Wraps a string to mark it as Unicode.- Parameters:
string
- the string to wrap.- Returns:
- wrapped string.
-
unicode
@NotNull public static UnicodeString unicode(@NotNull String string, int limitLength)
Wraps a string to mark it as Unicode.- Parameters:
string
- the string to wrap.limitLength
- the maximum possible length of the string; the string tail can be truncated.- Returns:
- wrapped string.
-
unicodeOrNull
@Nullable @Contract("null -> null; !null -> !null") public static UnicodeString unicodeOrNull(@Nullable String string)
Wraps a string to mark it as Unicode.- Parameters:
string
- the string to wrap.- Returns:
- wrapped string.
-
unicodeOrNull
@Nullable @Contract("null,_ -> null; !null,_ -> !null") public static UnicodeString unicodeOrNull(@Nullable String string, int limitLength)
Wraps a string to mark it as Unicode.- Parameters:
string
- the string to wrap.limitLength
- the maximum possible length of the string; the string tail can be truncated.- Returns:
- wrapped string.
-
length
public int length()
- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAt
in interfaceCharSequence
-
subSequence
public CharSequence subSequence(int start, int end)
- Specified by:
subSequence
in interfaceCharSequence
-
compareTo
public final int compareTo(@NotNull UnicodeString that)
- Specified by:
compareTo
in interfaceComparable<UnicodeString>
-
toString
@NotNull public final String toString()
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
substring
@NotNull public final UnicodeString substring(int beginIndex)
-
substring
@NotNull public final UnicodeString substring(int beginIndex, int endIndex)
-
getBytes
@NotNull public final byte[] getBytes()
-
getBytes
@NotNull public static byte[] getBytes(@NotNull String string)
-
compare
public static int compare(@Nullable UnicodeString str1, @Nullable UnicodeString str2)
Safely compares two unicode strings. Nulls are allowed.- Parameters:
str1
- first string.str2
- second string.- Returns:
- result
-
-