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 forStringthat 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 charcharAt(int index)static intcompare(UnicodeString str1, UnicodeString str2)Safely compares two unicode strings.intcompareTo(UnicodeString that)booleanequals(Object that)byte[]getBytes()static byte[]getBytes(String string)inthashCode()intlength()CharSequencesubSequence(int start, int end)UnicodeStringsubstring(int beginIndex)UnicodeStringsubstring(int beginIndex, int endIndex)StringtoString()static UnicodeStringunicode(String string)Wraps a string to mark it as Unicode.static UnicodeStringunicode(String string, int limitLength)Wraps a string to mark it as Unicode.static UnicodeStringunicodeOrNull(String string)Wraps a string to mark it as Unicode.static UnicodeStringunicodeOrNull(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:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfaceCharSequence
-
subSequence
public CharSequence subSequence(int start, int end)
- Specified by:
subSequencein interfaceCharSequence
-
compareTo
public final int compareTo(@NotNull UnicodeString that)- Specified by:
compareToin interfaceComparable<UnicodeString>
-
toString
@NotNull public final String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin 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
-
-