private static String ensureEnds(@NotNull String s, final char endsWith) { return StringUtilRt.endsWithChar(s, endsWith) ? s : s + endsWith; } }
@NotNull public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep, boolean keepCarriageReturn) { return StringUtilRt.convertLineSeparators(text, newSeparator, offsetsToKeep, keepCarriageReturn); }
@NotNull @Contract(pure = true) public static String getShortName(@NotNull String fqName, char separator) { return StringUtilRt.getShortName(fqName, separator); }
@Contract(pure = true) public static int parseInt(final String string, final int defaultValue) { return StringUtilRt.parseInt(string, defaultValue); }
@Contract(pure = true) public static boolean charsEqualIgnoreCase(char a, char b) { return StringUtilRt.charsEqualIgnoreCase(a, b); }
@Contract(pure = true) public static boolean parseBoolean(String string, final boolean defaultValue) { return StringUtilRt.parseBoolean(string, defaultValue); }
/** * Allows to retrieve index of last occurrence of the given symbols at <code>[start; end)</code> sub-sequence of the given text. * * @param s target text * @param c target symbol which last occurrence we want to check * @param start start offset of the target text (inclusive) * @param end end offset of the target text (exclusive) * @return index of the last occurrence of the given symbol at the target sub-sequence of the given text if any; * <code>-1</code> otherwise */ @Contract(pure = true) public static int lastIndexOf(@NotNull CharSequence s, char c, int start, int end) { return StringUtilRt.lastIndexOf(s, c, start, end); }
@Contract(pure = true) public static double parseDouble(final String string, final double defaultValue) { return StringUtilRt.parseDouble(string, defaultValue); }
@Contract(pure = true) public static <E extends Enum<E>> E parseEnum(String string, E defaultValue, Class<E> clazz) { return StringUtilRt.parseEnum(string, defaultValue, clazz); }
@Contract(pure = true) public static boolean endsWithIgnoreCase(@NonNls @NotNull String str, @NonNls @NotNull String suffix) { return StringUtilRt.endsWithIgnoreCase(str, suffix); }
public static CsvTableEditorState create(@NotNull Element element, @NotNull Project project, @NotNull VirtualFile file) { CsvTableEditorState state = new CsvTableEditorState(); Attribute attribute = element.getAttribute("showInfoPanel"); state.setShowInfoPanel( attribute == null ? CsvEditorSettingsExternalizable.getInstance().showTableEditorInfoPanel() : Boolean.parseBoolean(attribute.getValue()) ); attribute = element.getAttribute("fixedHeaders"); state.setFixedHeaders( attribute == null ? false : Boolean.parseBoolean(attribute.getValue()) ); state.setRowLines( StringUtilRt.parseInt(element.getAttributeValue("rowLines"), CsvEditorSettingsExternalizable.getInstance().getTableEditorRowHeight()) ); List<Element> columnWidthElements = element.getChildren("column"); int[] columnWidths = new int[columnWidthElements.size()]; for (int i = 0; i < columnWidthElements.size(); ++i) { Element columnElement = columnWidthElements.get(i); int index = StringUtilRt.parseInt(columnElement.getAttributeValue("index"), i); columnWidths[index] = StringUtilRt.parseInt(columnElement.getAttributeValue("width"), INITIAL_COLUMN_WIDTH); } state.setColumnWidths(columnWidths); return state; }
public static boolean equal(@Nullable CharSequence s1, @Nullable CharSequence s2, boolean caseSensitive) { if (s1 == s2) return true; if (s1 == null || s2 == null) return false; // Algorithm from String.regionMatches() if (s1.length() != s2.length()) return false; int to = 0; int po = 0; int len = s1.length(); while (len-- > 0) { char c1 = s1.charAt(to++); char c2 = s2.charAt(po++); if (c1 == c2) { continue; } if (!caseSensitive && StringUtilRt.charsEqualIgnoreCase(c1, c2)) continue; return false; } return true; }
@NotNull public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep) { return convertLineSeparators(text, newSeparator, offsetsToKeep, false); }
@Contract(pure = true) public static boolean endsWithChar(@Nullable CharSequence s, char suffix) { return StringUtilRt.endsWithChar(s, suffix); }
@NotNull @Contract(pure = true) public static String getShortName(@NotNull Class aClass) { return StringUtilRt.getShortName(aClass); }
@Contract(pure = true) public static boolean endsWithIgnoreCase(@NonNls @NotNull CharSequence text, @NonNls @NotNull CharSequence suffix) { int l1 = text.length(); int l2 = suffix.length(); if (l1 < l2) return false; for (int i = l1 - 1; i >= l1 - l2; i--) { if (!charsEqualIgnoreCase(text.charAt(i), suffix.charAt(i + l2 - l1))) { return false; } } return true; }
@NotNull public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator, @Nullable int[] offsetsToKeep) { return StringUtilRt.convertLineSeparators(text, newSeparator, offsetsToKeep); }
@NotNull @Contract(pure = true) public static String getShortName(@NotNull String fqName) { return StringUtilRt.getShortName(fqName); }
@NotNull @Contract(pure = true) public static String convertLineSeparators(@NotNull String text, @NotNull String newSeparator) { return StringUtilRt.convertLineSeparators(text, newSeparator); }
@NotNull @Contract(pure = true) public static String getShortName(@NotNull Class aClass) { return getShortName(aClass.getName()); }