Package gaiasky.util

Class TextUtils

java.lang.Object
gaiasky.util.TextUtils

public class TextUtils extends Object
Utilities to manipulate strings and text.
  • Constructor Details

    • TextUtils

      public TextUtils()
  • Method Details

    • escape

      public static String escape(String s)
      Escape a give String to make it safe to be printed or stored.
      Parameters:
      s - The input String.
      Returns:
      The output String.
    • surroundBrackets

      public static String surroundBrackets(String in)
    • surround

      public static String surround(String in, String pre, String post)
    • breakCharacters

      public static String breakCharacters(CharSequence in, int breakChars)
      Breaks the string with new line ('\n') characters so that the lines have approximately breakChars characters.
      Parameters:
      in - The character sequence.
      breakChars - The number of characters per line.
      Returns:
      The string, broken into lines.
    • breakCharacters

      public static String breakCharacters(String in, int breakChars)
      Breaks the string with new line ('\n') characters so that the lines have approximately breakChars characters.
      Parameters:
      in - The string.
      breakChars - The number of characters per line.
      Returns:
      The string, broken into lines.
    • breakCharacters

      public static String breakCharacters(String in, int breakChars, boolean forceBreak)
      Breaks the string with new line ('\n') characters so that the lines have approximately breakChars characters.
      Parameters:
      in - The string.
      breakChars - The number of characters per line.
      forceBreak - Break the string even when there are no separator characters.
      Returns:
      The string, broken into lines.
    • countLines

      public static long countLines(String str)
    • breakSpaces

      public static String breakSpaces(CharSequence in, int breakSpaces)
    • breakSpaces

      public static String breakSpaces(String in, int breakSpaces)
    • capLabelWidth

      public static void capLabelWidth(com.badlogic.gdx.scenes.scene2d.ui.Label l, float targetWidth)
    • limitWidth

      public static CharSequence limitWidth(CharSequence text, float width, float letterWidth)
    • capString

      public static String capString(String in, int targetLength)
    • capString

      public static String capString(String in, int targetLength, boolean fromStart)
    • propertyToMethodName

      public static String propertyToMethodName(String property)
      Converts from property displayName to method displayName by removing the separator dots and capitalising each chunk. Example: model.texture.bump -> ModelTextureBump
      Parameters:
      property - The property displayName
      Returns:
      The method name
    • capitalise

      public static String capitalise(String line)
      Returns the given string with the first letter capitalised
      Parameters:
      line - The input string
      Returns:
      The string with its first letter capitalised
    • trueCapitalise

      public static String trueCapitalise(String line)
      Returns the given string with the first letter capitalised and all the others in lower case
      Parameters:
      line - The input string
      Returns:
      The string with its first letter capitalised and the others in lower case
    • concatenate

      public static String concatenate(String split, String... strings)
      Concatenates the strings using the given split
      Parameters:
      split - The split
      strings - The strings
      Returns:
      The concatenation
    • concatenate

      public static String concatenate(String split, com.badlogic.gdx.utils.Array<String> strings)
      Concatenates the strings using the given split
      Parameters:
      split - The split
      strings - The strings
      Returns:
      The concatenation
    • concatenate

      public static String concatenate(String split, List<String> strings)
      Concatenates the strings using the given split
      Parameters:
      split - The split
      strings - The strings
      Returns:
      The concatenation
    • arrayToStr

      public static String arrayToStr(String[] arr)
    • arrayToStr

      public static String arrayToStr(String[] arr, String pre, String post, String sep)
    • setToStr

      public static String setToStr(Set<String> set)
    • setToStr

      public static String setToStr(Set<String> set, String pre, String post, String sep)
    • getFormattedTimeWarp

      public static String getFormattedTimeWarp(double warp)
    • getFormattedTimeWarp

      public static String getFormattedTimeWarp()
    • secondsToTimeUnit

      public static String secondsToTimeUnit(double seconds)
    • concatAll

      public static String[] concatAll(String base, String[] suffixes)
      Concatenates the base with each of the strings in suffixes
      Parameters:
      base - The base string
      suffixes - All the suffixes
      Returns:
      The result
    • concatAll

      public static String[] concatAll(String base, String[] suffixes, String suffixAdditional)
    • addToBeginningOfArray

      public static <T> T[] addToBeginningOfArray(T[] elements, T element)
    • contains

      public static boolean contains(String[] list, String key)
    • contains

      public static boolean contains(String[] list, String key, boolean ignoreCase)
    • startsWith

      public static boolean startsWith(String[] list, String prefix)
    • ensureStartsWith

      public static String ensureStartsWith(String base, String start)
    • contains

      public static boolean contains(String name, List<String> list)
    • containsOrMatches

      public static boolean containsOrMatches(String[] list, String key, boolean ignoreCase)
    • containsOrMatches

      public static boolean containsOrMatches(String[][] list, String key, boolean ignoreCase)
    • html2text

      public static String html2text(String html)
    • unescape

      public static String unescape(String oldStr)
    • classSimpleName

      public static String classSimpleName(String className)
    • padString

      public static String padString(String str, int length, char padChar)
      Pads the given string with the given character to be the given length.
      Parameters:
      str - The string to pad.
      length - The target length.
      padChar - The padding character to use.
      Returns:
      The padded string, or the original string if its length was greater than the given target length.
    • hashFast

      public static int hashFast(String str)
    • hashFast

      public static int hashFast(char[] val)
    • hashFNV1

      public static int hashFNV1(String str)
    • hashFNV1

      public static int hashFNV1(char[] data, long seed)
    • hashMurmur

      public static int hashMurmur(String str)
    • hashMurmur

      public static int hashMurmur(char[] data, int seed)