Package arc.util

Class Strings

java.lang.Object
arc.util.Strings

public class Strings extends Object
  • Field Details

    • utf8

      public static final Charset utf8
  • Constructor Details

    • Strings

      public Strings()
  • Method Details

    • matches

      public static boolean matches(String query, String name)
      Returns:
      whether the name matches the query; case-insensitive. Always returns true if query is empty.
    • count

      public static int count(CharSequence s, char c)
    • truncate

      public static String truncate(String s, int length)
    • truncate

      public static String truncate(String s, int length, String ellipsis)
    • getCauses

      public static Seq<Throwable> getCauses(Throwable e)
    • getSimpleMessage

      public static String getSimpleMessage(Throwable e)
    • getFinalMessage

      public static String getFinalMessage(Throwable e)
    • getFinalCause

      public static Throwable getFinalCause(Throwable e)
    • getStackTrace

      public static String getStackTrace(Throwable e)
    • neatError

      public static String neatError(Throwable e)
      Returns:
      a neat error message of a throwable, with stack trace.
    • neatError

      public static String neatError(Throwable e, boolean stacktrace)
      Returns:
      a neat error message of a throwable, with stack trace.
    • stripColors

      public static String stripColors(CharSequence str)
    • stripGlyphs

      public static String stripGlyphs(CharSequence str)
    • count

      public static int count(String str, String substring)
    • sanitizeFilename

      public static String sanitizeFilename(String str)
      Replaces non-safe filename characters with '_'. Handles reserved window file names.
    • encode

      public static String encode(String str)
    • format

      public static String format(String text, Object... args)
    • join

      public static String join(String separator, String... strings)
    • join

      public static String join(String separator, Iterable<String> strings)
    • levenshtein

      public static int levenshtein(String x, String y)
      Returns the levenshtein distance between two strings.
    • animated

      public static String animated(float time, int length, float scale, String replacement)
    • kebabToCamel

      public static String kebabToCamel(String s)
    • camelToKebab

      public static String camelToKebab(String s)
    • capitalize

      public static String capitalize(String s)
      Converts a snake_case or kebab-case string to Upper Case. For example: "test_string" -> "Test String"
    • insertSpaces

      public static String insertSpaces(String s)
      Adds spaces to a camel/pascal case string.
    • camelize

      public static String camelize(String s)
      Converts a Space Separated string to camelCase. For example: "Camel Case" -> "camelCase"
    • canParseInt

      public static boolean canParseInt(String s)
    • canParsePositiveInt

      public static boolean canParsePositiveInt(String s)
    • parseInt

      public static int parseInt(String s, int defaultValue)
    • parseInt

      public static int parseInt(String s, int radix, int defaultValue)
    • parseInt

      public static int parseInt(String s, int radix, int defaultValue, int start, int end)
    • parseLong

      public static long parseLong(String s, long defaultValue)
    • parseLong

      public static long parseLong(String s, int radix, long defaultValue)
    • parseLong

      public static long parseLong(String s, int radix, int start, int end, long defaultValue)
    • parseDouble

      public static double parseDouble(String value, double defaultValue)
      Faster double parser that doesn't throw exceptions.
    • parseInt

      public static int parseInt(String s)
      Returns Integer.MIN_VALUE if parsing failed.
    • canParseFloat

      public static boolean canParseFloat(String s)
    • canParsePositiveFloat

      public static boolean canParsePositiveFloat(String s)
    • parseFloat

      public static float parseFloat(String s)
      Returns Float.NEGATIVE_INFINITY if parsing failed.
    • parseFloat

      public static float parseFloat(String s, float defaultValue)
    • autoFixed

      public static String autoFixed(float value, int max)
    • fixed

      public static String fixed(float d, int decimalPlaces)
    • fixedBuilder

      public static StringBuilder fixedBuilder(float d, int decimalPlaces)
    • formatMillis

      public static String formatMillis(long val)
    • replace

      public static StringBuilder replace(StringBuilder builder, String find, String replace)
      Replaces all instances of find with replace.
    • replace

      public static StringBuilder replace(StringBuilder builder, char find, String replace)
      Replaces all instances of find with replace.