Klasse Utils.StringUtils

java.lang.Object
net.risingworld.api.utils.Utils.StringUtils
Umschließende Klasse:
Utils

public abstract static class Utils.StringUtils extends Object
Various String functions, i.e functions to check if certain strings are numeric, getting checksums of strings, and conversion utils.
  • Konstruktordetails

    • StringUtils

      public StringUtils()
  • Methodendetails

    • parseInteger

      public static int parseInteger(String string, int defaultValue)
      Tries to parse an integer value from a string. If the provided string is an integer, the parsed int will be returned. Otherwise the provided default value is returned instead.
      Parameter:
      string - the string you want to parse.
      defaultValue - the default return value if the string could not be parsed.
      Gibt zurück:
      the parsed int value, or the provided default value if the string could not be parsed.
    • parseLong

      public static long parseLong(String string, long defaultValue)
      Tries to parse a long value from a string. If the provided string is an integer/long, the parsed long will be returned. Otherwise the provided default value is returned instead.
      Parameter:
      string - the string you want to parse.
      defaultValue - the default return value if the string could not be parsed.
      Gibt zurück:
      the parsed long value, or the provided default value if the string could not be parsed.
    • parseFloat

      public static float parseFloat(String string, float defaultValue)
      Tries to parse a float value from a string. If the provided string is a floating number, the parsed float will be returned. Otherwise the provided default value is returned instead.
      Parameter:
      string - the string you want to parse.
      defaultValue - the default return value if the string could not be parsed.
      Gibt zurück:
      the parsed float value, or the provided default value if the string could not be parsed.
    • parseDouble

      public static double parseDouble(String string, double defaultValue)
      Tries to parse a float value from a string. If the provided string is a floating number, the parsed float will be returned. Otherwise the provided default value is returned instead.
      Parameter:
      string - the string you want to parse.
      defaultValue - the default return value if the string could not be parsed.
      Gibt zurück:
      the parsed float value, or the provided default value if the string could not be parsed.
    • parseBoolean

      public static boolean parseBoolean(String string, boolean defaultValue)
      Tries to parse a boolean from a string. If the provided string is "true" or "false" (or "1" or "0"), the parsed boolean value will be returned. Otherwise the provided default value is returned instead.
      Parameter:
      string - the string you want to parse.
      defaultValue - the default return value if the string could not be parsed.
      Gibt zurück:
      the parsed boolean value, or the provided default value if the string could not be parsed.
    • isInteger

      public static boolean isInteger(String string)
      Determines whether or not the provided string represents an integer/long value (for example, it will return true for values like "0", "1", "-7", "42", but false for strings like "7.62", "Hello", "5+5" etc).
      Parameter:
      string - the string you want to check.
      Gibt zurück:
      true if the provided string represents an int value, false if not.
    • isNumeric

      public static boolean isNumeric(String string)
      Determines whether or not the provided string represents a numeric value (integer/long or float/double, for example, it will return true for values like "0", "1.426", "-100", "22.0", but false for strings like "3k", "Bonjour", "7*7" etc).
      Parameter:
      string - the string you want to check.
      Gibt zurück:
      true if the provided string represents a numeric value, false if not.
    • isHex

      public static boolean isHex(String string)
      Determines whether or not the provided string represents a hexadecimal (hex) value using a "0x" prefix (for example, it will return true for values like "0xFF", "0xaabbcc", "0x41AB", "0x0", but false for strings like "56", "#FFAA13", "0xZVKK").
      Parameter:
      string - the string you want to check.
      Gibt zurück:
      true if the provided string represents a hex value, false if not.
    • isBoolean

      public static boolean isBoolean(String string)
      Determines whether or not the provided string represents a boolean value (lower case, it will only return true for "true" or "false").
      Parameter:
      string - the string you want to check.
      Gibt zurück:
      true if the provided string equals "true" or "false", false if not.
    • combineStringArray

      public static String combineStringArray(String[] array, int start, int end, char delimiter)
    • firstCharToUpper

      public static String firstCharToUpper(String string)
    • firstCharToLower

      public static String firstCharToLower(String string)
    • removeAllNonWordCharacters

      public static String removeAllNonWordCharacters(String string)
    • removeAllWhitespaces

      public static String removeAllWhitespaces(String string)
    • removeAllLeadingWhitespaces

      public static String removeAllLeadingWhitespaces(String string)
      Removes all leading white spaces. e.g if you provide the string " Test", this function returns "Test". If you provide "Hello World", this function returns the unmodified "Hello World" string.
      Parameter:
      string - the string you want to remove the leading white spaces from.
      Gibt zurück:
      the new string which does not contain any leading white spaces.
    • removeAllTrailingWhitespaces

      public static String removeAllTrailingWhitespaces(String string)
    • removeAllLeadingAndTrailingWhitespaces

      public static String removeAllLeadingAndTrailingWhitespaces(String string)
    • getLines

      public static String[] getLines(String string)
      Splits the string by new line characters, i.e \n or \r etc. Returns a character containing the individual lines. Does not contain empty lines.
      Parameter:
      string - the string you want to split, e.g the text from a text file.
      Gibt zurück:
      the individual lines as an array of strings.
    • getMd5

      public static String getMd5(String string)
      Generates an MD5 hash from the provided string. This is useful for checksums etc., but keep in mind that MD5 is not safe enough for saving passwords, for example.
      Parameter:
      string - the string you want to turn into an MD5 hash.
      Gibt zurück:
      an MD5 hash.
    • vector3fToString

      public static String vector3fToString(Vector3f vector3f)