Package com.almis.awe.model.util.data
Class StringUtil
java.lang.Object
com.almis.awe.model.util.data.StringUtil
StringUtil Class
String Utilities for AWE
- Author:
- Pablo GARCIA - 20/JAN/2011
-
Method Summary
Modifier and TypeMethodDescriptionasList
(com.fasterxml.jackson.databind.JsonNode parameter) Get parameter as string liststatic String
camelToSnake
(String camelCase) static String
compressJson
(String value) Compress Jsonstatic boolean
containsIgnoreCase
(String base, String compareTo) Compare two values ignoring casestatic String
decompressJson
(String compressed) Decompress Jsonstatic org.graalvm.polyglot.Value
Evaluates an expression as a javascript enginestatic String
evalMarkdown
(String expression) Evaluates an expression as a javascript enginestatic String
fixCriteriaValue
(String value) Fixes an string value for a criteriastatic String
fixFileName
(String value) Fixes an string value for a file namestatic String
fixFormatValue
(String value) Fixes an string value for a JSON Filestatic String
fixHTMLValue
(String value) Fixes an string value for a criteriastatic String
fixJSonValue
(String value) Fixes an string value for a JSON Filestatic String
fixListString
(String list, String start, String end) Removes first and last characters and changes themstatic String
Fixes an string value for a Pathstatic String
fixQueryValue
(String value) Fixes an string value for a criteriastatic String
Fixes an string value for an URIstatic String
getAbsolutePath
(String path, String base) Retrieves the absolute path of an unknown type pathstatic String
getContextPath
(String path) Get the last word of a pathstatic String
parseLocale
(Global locale) Parse a localestatic String
removeComments
(String value, boolean removeLines) Removes comments in js and cssstatic String
removeHTMLFromText
(String value) Removes HTML characters from textstatic String
removeNewLine
(String value) Remove new linesstatic String
replaceWildcard
(String target, String key, String val) Replaces a wildcard inside a script or css filestatic String
Replaces a wildcardstatic String
sanitizeInputParameter
(String parameter) Sanitize input parameters.static String
shortenText
(String text, Integer size, String replacement) Shorten a text if longer than sizestatic com.fasterxml.jackson.databind.node.ArrayNode
toArrayNode
(String pattern, String value) Generates an ArrayNodestatic String
toHTMLText
(String value) Generates an HTML Formatstatic String
toPlainText
(String value) Generates a Plain TexttoStringList
(String pattern, String value) Generates a string liststatic String
toUnilineText
(String value) Generates an Uniline Text
-
Method Details
-
fixFileName
Fixes an string value for a file name- Parameters:
value
- String value- Returns:
- Value fixed
-
fixHTMLValue
Fixes an string value for a criteria- Parameters:
value
- String value- Returns:
- Value fixed
-
fixCriteriaValue
Fixes an string value for a criteria- Parameters:
value
- String value- Returns:
- Value fixed
-
fixQueryValue
Fixes an string value for a criteria- Parameters:
value
- String value- Returns:
- Value fixed
-
fixJSonValue
Fixes an string value for a JSON File- Parameters:
value
- String value- Returns:
- Value fixed
-
fixFormatValue
Fixes an string value for a JSON File- Parameters:
value
- String value- Returns:
- Value fixed
-
removeHTMLFromText
Removes HTML characters from text- Parameters:
value
- String value- Returns:
- Value fixed
-
toHTMLText
Generates an HTML Format- Parameters:
value
- String value- Returns:
- Value fixed
-
toPlainText
Generates a Plain Text- Parameters:
value
- String value- Returns:
- Value fixed
-
toUnilineText
Generates an Uniline Text- Parameters:
value
- String value- Returns:
- Value fixed
-
removeNewLine
Remove new lines- Parameters:
value
- String value- Returns:
- Value fixed
-
compressJson
Compress Json- Parameters:
value
- String value- Returns:
- Value fixed
-
decompressJson
Decompress Json- Parameters:
compressed
- String value- Returns:
- Value fixed
-
removeComments
Removes comments in js and css- Parameters:
value
- String valueremoveLines
- Remove new lines- Returns:
- Value fixed
-
fixPath
Fixes an string value for a Path- Parameters:
path
- String path- Returns:
- Path fixed
-
sanitizeInputParameter
Sanitize input parameters. Replace some characters for not be vulnerable to injection attacks- Parameters:
parameter
- unsafe input parameter- Returns:
- parameter sanitized
-
getAbsolutePath
Retrieves the absolute path of an unknown type path- Parameters:
path
- String pathbase
- Base path- Returns:
- Absolute path
-
fixURI
Fixes an string value for an URI- Parameters:
uri
- String path- Returns:
- URI fixed
-
getContextPath
Get the last word of a path- Parameters:
path
- Complete path- Returns:
- Last word of a path
-
replaceWildcard
Replaces a wildcard inside a script or css file- Parameters:
target
- string to replacekey
- wildcard keyval
- 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 replacekey
- wildcard keyval
- wildcard valuestart
- Pattern headerend
- Pattern footer- Returns:
- Value fixed
-
fixListString
Removes first and last characters and changes them- Parameters:
list
- List as string valuestart
- New start characterend
- 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 evaluatecontext
- Javascript engine context- Returns:
- Evaluated expression
-
evalMarkdown
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
- Patternvalue
- String value- Returns:
- Value as ArrayNode
-
toStringList
Generates a string list- Parameters:
pattern
- Patternvalue
- String value- Returns:
- Value as ArrayNode
-
containsIgnoreCase
Compare two values ignoring case- Parameters:
base
- Base stringcompareTo
- compare to element- Returns:
- Base contains compareTo
-
asList
Get parameter as string list- Parameters:
parameter
- parameter- Returns:
- parameter list
-
shortenText
Shorten a text if longer than size- Parameters:
text
- Text to shortensize
- Max text sizereplacement
- Text to replace the extra characters- Returns:
- Shortened string
-
parseLocale
Parse a locale- Parameters:
locale
- Locale- Returns:
- locale parsed
-
camelToSnake
-