Class StringUtil

java.lang.Object
com.almis.awe.model.util.data.StringUtil

public final class StringUtil extends Object
StringUtil Class

String Utilities for AWE

Author:
Pablo GARCIA - 20/JAN/2011
  • Method Details

    • fixFileName

      public static String fixFileName(String value)
      Fixes an string value for a file name
      Parameters:
      value - String value
      Returns:
      Value fixed
    • fixHTMLValue

      public static String fixHTMLValue(String value)
      Fixes an string value for a criteria
      Parameters:
      value - String value
      Returns:
      Value fixed
    • fixCriteriaValue

      public static String fixCriteriaValue(String value)
      Fixes an string value for a criteria
      Parameters:
      value - String value
      Returns:
      Value fixed
    • fixQueryValue

      public static String fixQueryValue(String value)
      Fixes an string value for a criteria
      Parameters:
      value - String value
      Returns:
      Value fixed
    • fixJSonValue

      public static String fixJSonValue(String value)
      Fixes an string value for a JSON File
      Parameters:
      value - String value
      Returns:
      Value fixed
    • fixFormatValue

      public static String fixFormatValue(String value)
      Fixes an string value for a JSON File
      Parameters:
      value - String value
      Returns:
      Value fixed
    • removeHTMLFromText

      public static String removeHTMLFromText(String value)
      Removes HTML characters from text
      Parameters:
      value - String value
      Returns:
      Value fixed
    • toHTMLText

      public static String toHTMLText(String value)
      Generates an HTML Format
      Parameters:
      value - String value
      Returns:
      Value fixed
    • toPlainText

      public static String toPlainText(String value)
      Generates a Plain Text
      Parameters:
      value - String value
      Returns:
      Value fixed
    • toUnilineText

      public static String toUnilineText(String value)
      Generates an Uniline Text
      Parameters:
      value - String value
      Returns:
      Value fixed
    • removeNewLine

      public static String removeNewLine(String value)
      Remove new lines
      Parameters:
      value - String value
      Returns:
      Value fixed
    • compressJson

      public static String compressJson(String value)
      Compress Json
      Parameters:
      value - String value
      Returns:
      Value fixed
    • decompressJson

      public static String decompressJson(String compressed)
      Decompress Json
      Parameters:
      compressed - String value
      Returns:
      Value fixed
    • removeComments

      public static String removeComments(String value, boolean removeLines)
      Removes comments in js and css
      Parameters:
      value - String value
      removeLines - Remove new lines
      Returns:
      Value fixed
    • fixPath

      public static String fixPath(String path)
      Fixes an string value for a Path
      Parameters:
      path - String path
      Returns:
      Path fixed
    • getAbsolutePath

      public static String getAbsolutePath(String path, String base)
      Retrieves the absolute path of an unknown type path
      Parameters:
      path - String path
      base - Base path
      Returns:
      Absolute path
    • fixURI

      public static String fixURI(String uri)
      Fixes an string value for an URI
      Parameters:
      uri - String path
      Returns:
      URI fixed
    • getContextPath

      public static String getContextPath(String path)
      Get the last word of a path
      Parameters:
      path - Complete path
      Returns:
      Last word of a path
    • replaceWildcard

      public static String replaceWildcard(String target, String key, String val)
      Replaces a wildcard inside a script or css file
      Parameters:
      target - string to replace
      key - wildcard key
      val - wildcard value
      Returns:
      file with the wildcard replaced
    • replaceWildcard

      public static String replaceWildcard(String target, String key, String val, String start, String end)
      Replaces a wildcard
      Parameters:
      target - string to replace
      key - wildcard key
      val - wildcard value
      start - Pattern header
      end - Pattern footer
      Returns:
      Value fixed
    • fixListString

      public static String fixListString(String list, String start, String end)
      Removes first and last characters and changes them
      Parameters:
      list - List as string value
      start - New start character
      end - New end character
      Returns:
      List value fixed
    • eval

      public static org.graalvm.polyglot.Value eval(String expression, org.graalvm.polyglot.Context context)
      Evaluates an expression as a javascript engine
      Parameters:
      expression - Expression to evaluate
      context - Javascript engine context
      Returns:
      Evaluated expression
    • evalMarkdown

      public static String evalMarkdown(String expression)
      Evaluates an expression as a javascript engine
      Parameters:
      expression - Expression to evaluate
      Returns:
      Evaluated expression
    • toArrayNode

      public static com.fasterxml.jackson.databind.node.ArrayNode toArrayNode(String pattern, String value)
      Generates an ArrayNode
      Parameters:
      pattern - Pattern
      value - String value
      Returns:
      Value as ArrayNode
    • toStringList

      public static List<String> toStringList(String pattern, String value)
      Generates a string list
      Parameters:
      pattern - Pattern
      value - String value
      Returns:
      Value as ArrayNode
    • containsIgnoreCase

      public static boolean containsIgnoreCase(String base, String compareTo)
      Compare two values ignoring case
      Parameters:
      base - Base string
      compareTo - compare to element
      Returns:
      Base contains compareTo
    • asList

      public static List<String> asList(com.fasterxml.jackson.databind.JsonNode parameter)
      Get parameter as string list
      Parameters:
      parameter - parameter
      Returns:
      parameter list
    • shortenText

      public static String shortenText(String text, Integer size, String replacement)
      Shorten a text if longer than size
      Parameters:
      text - Text to shorten
      size - Max text size
      replacement - Text to replace the extra characters
      Returns:
      Shortened string
    • parseLocale

      public static String parseLocale(Global locale)
      Parse a locale
      Parameters:
      locale - Locale
      Returns:
      locale parsed
    • camelToSnake

      public static String camelToSnake(String camelCase)