Class StringUtilRt
- java.lang.Object
-
- jetbrains.buildServer.vcs.patches.diff.StringUtilRt
-
public class StringUtilRt extends Object
Stripped-down version ofcom.intellij.openapi.util.text.StringUtil
. Intended to use by external (out-of-IDE-process) runners and helpers so it should not contain any library dependencies.- Since:
- 12.0
-
-
Constructor Summary
Constructors Constructor Description StringUtilRt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
charsEqualIgnoreCase(char a, char b)
static CharSequence
convertLineSeparators(CharSequence text, String newSeparator)
static String
convertLineSeparators(String text)
Converts line separators to"\n"
static String
convertLineSeparators(String text, boolean keepCarriageReturn)
static String
convertLineSeparators(String text, String newSeparator)
static String
convertLineSeparators(String text, String newSeparator, int[] offsetsToKeep)
static String
convertLineSeparators(String text, String newSeparator, int[] offsetsToKeep, boolean keepCarriageReturn)
static boolean
endsWith(CharSequence text, CharSequence suffix)
static boolean
endsWithChar(CharSequence s, char suffix)
static boolean
endsWithIgnoreCase(CharSequence text, CharSequence suffix)
static boolean
equal(CharSequence s1, CharSequence s2, boolean caseSensitive)
static String
formatFileSize(long fileSize)
static String
formatFileSize(long fileSize, String unitSeparator)
static String
getShortName(Class aClass)
static String
getShortName(String fqName)
static String
getShortName(String fqName, char separator)
static boolean
isEmpty(CharSequence cs)
static boolean
isEmptyOrSpaces(CharSequence s)
static boolean
isQuotedString(String s)
static int
lastIndexOf(CharSequence s, char c, int start, int end)
Allows to retrieve index of last occurrence of the given symbols at[start; end)
sub-sequence of the given text.static String
notNullize(String s)
static String
notNullize(String s, String defaultValue)
static double
parseDouble(String string, double defaultValue)
static int
parseInt(String string, int defaultValue)
static long
parseLong(String string, long defaultValue)
static List<String>
splitHonorQuotes(String s, char separator)
static boolean
startsWithIgnoreCase(String str, String prefix)
static char
toLowerCase(char a)
static char
toUpperCase(char a)
static String
unquoteString(String s)
static String
unquoteString(String s, char quotationChar)
-
-
-
Method Detail
-
equal
@Contract("null,!null,_ -> false; !null,null,_ -> false; null,null,_ -> true") public static boolean equal(@Nullable CharSequence s1, @Nullable CharSequence s2, boolean caseSensitive)
-
charsEqualIgnoreCase
public static boolean charsEqualIgnoreCase(char a, char b)
-
toUpperCase
public static char toUpperCase(char a)
-
toLowerCase
public static char toLowerCase(char a)
-
convertLineSeparators
@NotNull public static String convertLineSeparators(@NotNull String text)
Converts line separators to"\n"
-
convertLineSeparators
@NotNull public static String convertLineSeparators(@NotNull String text, boolean keepCarriageReturn)
-
convertLineSeparators
@NotNull public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator)
-
convertLineSeparators
@NotNull public static CharSequence convertLineSeparators(@NotNull CharSequence text, @NotNull String newSeparator)
-
convertLineSeparators
@NotNull public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep)
-
convertLineSeparators
@NotNull public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep, boolean keepCarriageReturn)
-
parseInt
public static int parseInt(@Nullable String string, int defaultValue)
-
parseLong
public static long parseLong(@Nullable String string, long defaultValue)
-
parseDouble
public static double parseDouble(@Nullable String string, double defaultValue)
-
endsWithChar
public static boolean endsWithChar(@Nullable CharSequence s, char suffix)
-
endsWith
public static boolean endsWith(@NotNull CharSequence text, @NotNull CharSequence suffix)
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(@NotNull String str, @NotNull String prefix)
-
endsWithIgnoreCase
public static boolean endsWithIgnoreCase(@NotNull CharSequence text, @NotNull CharSequence suffix)
-
lastIndexOf
public static int lastIndexOf(@NotNull CharSequence s, char c, int start, int end)
Allows to retrieve index of last occurrence of the given symbols at[start; end)
sub-sequence of the given text.- Parameters:
s
- target textc
- target symbol which last occurrence we want to checkstart
- start offset of the target text (inclusive)end
- end offset of the target text (exclusive)- Returns:
- index of the last occurrence of the given symbol at the target sub-sequence of the given text if any;
-1
otherwise
-
isEmpty
public static boolean isEmpty(@Nullable CharSequence cs)
-
isEmptyOrSpaces
public static boolean isEmptyOrSpaces(@Nullable CharSequence s)
-
notNullize
@NotNull public static String notNullize(@Nullable String s, @NotNull String defaultValue)
-
splitHonorQuotes
@NotNull public static List<String> splitHonorQuotes(@NotNull String s, char separator)
-
formatFileSize
@NotNull public static String formatFileSize(long fileSize)
-
formatFileSize
@NotNull public static String formatFileSize(long fileSize, @NotNull String unitSeparator)
-
isQuotedString
public static boolean isQuotedString(@NotNull String s)
-
-