com.vaadin.flow.internal.

Class StringUtil

java.lang.Object
com.vaadin.flow.internal.StringUtil
public final class StringUtil extends Object

Utility class for special string handling.

For internal use only. May be renamed or removed in a future release.

Since:

2.1.4

  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • removeComments

      public static String removeComments(String code)

      Removes comments (block comments and line comments) from the JS code.

      Parameters:

      code - code to clean comments from

      Returns:

      the code with removed comments

    • removeComments

      public static String removeComments(String code, boolean useStringApostrophe)

      Removes comments (block comments and line comments) from the JS code.

      Parameters:

      code - code to clean comments from

      useStringApostrophe - if true then ' is also considered a string and comments will not be considered inside it

      Returns:

      the code with removed comments

    • stripSuffix

      public static String stripSuffix(String string, String suffix)

      Strips the given suffix from the given string, if the strings end with the suffix.

      Parameters:

      string - the string to scan

      suffix - the suffix

      Returns:

      the string without the suffix at the end or the same string if the suffix was not found

    • getHash

      public static String getHash(String content)

      Generate a hash for given content.

      Parameters:

      content - content to generate hash for

      Returns:

      hash String for given content. In case content is null or empty returns empty String.

    • getHash

      public static String getHash(String content, Charset charset)

      Generate hash for content using given charset for string byte encoding.

      Parameters:

      content - content to hash

      charset - charset for encoding

      Returns:

      hash String for given content. In case content is null or empty * returns empty String.

    • getHash

      public static String getHash(String content, byte[] salt, Charset charset)

      Generate hash for content using a given salt bytes and a given charset for string byte encoding.

      Parameters:

      content - content to hash

      salt - salt to be added into hash calculation

      charset - charset for encoding

      Returns:

      hash String for given content. In case content is null or empty * returns empty String.