Class EngineUtil

java.lang.Object
org.smartparam.engine.util.EngineUtil

public abstract class EngineUtil extends Object

The class contains the helper and tool methods used by the engine.

Some methods have equivalents in the standard library or different tool libraries but implemented in a way that increases their efficiency for use in the engine.
Since:
1.0.0
Author:
Przemek Hertel
  • Method Details

    • hasText

      public static boolean hasText(String text)
    • split

      public static String[] split(String str, char delim, int maxTokens)

      Splits the given string and returns an array of tokens. The separator is a single delim character. Returns a maximum of max tokens even if the input string contains more tokens.

      The method is more than 4 times faster than String.split () called for a 1-character delimiter.
      Parameters:
      str - input string
      delim - single character treated as a separator
      maxTokens - maximum number of tokens, the value -1 returns an array of all tokens (unlimited)
      Returns:
      token array, never returns null
      See Also:
    • split

      public static String[] split(String str, char delim)

      Splits the given string and returns an array of tokens. The separator is a single delim character. Returns arrays with all tokens found in the input string.

      The method is more than 4 times faster than String.split () called for a 1-character delimiter.
      Parameters:
      str - input string
      delim - character treated as a separator
      Returns:
      Array of all tokens, never returns null
      See Also:
    • split2

      public static String[] split2(String str, char delim)

      Splits a string into exactly 2 tokens. The separator is the first occurrence of the delim character.

      The method is 6 times faster than (java.lang.String, char, int) and about 24 times faster than String.split. Applicable to typical hotspots.
      Parameters:
      str - string that will be split into exactly 2 tokens
      delim - character to be the separator
      Returns:
      2 element's token array, never returns null
    • trimAllWhitespace

      public static String trimAllWhitespace(String str)