Package org.casbin.jcasbin.util
Class Util
java.lang.Object
org.casbin.jcasbin.util.Util
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
array2DEquals determines whether two 2-dimensional string arrays are identical.static boolean
arrayEquals
(List<String> a, List<String> b) arrayEquals determines whether two string arrays are identical.arrayRemoveDuplicates removes any duplicated elements in a string array preserving the order.static String
arrayToString
(List<String> s) arrayToString gets a printable string for a string array.static String
convertInSyntax
(String expString) convertInSyntax Convert 'in' to 'include' to fit aviatorscript,because aviatorscript don't support native 'in' syntaxstatic String
escapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.private static MessageDigest
static boolean
static boolean
isJsonString
(String str) Helper method to check if a string is a valid JSONstatic void
logEnforce
(Object[] request, boolean result, List<String> explain) logEnforce prints the log of Enforce.static void
logPrint prints the log.static void
logPrintf prints the log with the format.static void
logPrintfError
(String format, Object... v) logPrintf prints the log with the format as an error.static void
logPrintfError
(String message, Throwable t) logPrintf prints the log with the format as an error.static void
logPrintfWarn
(String format, Object... v) logPrintf prints the log with the format as a warning.static String
static String
paramsToString
(String[] s) paramsToString gets a printable string for variable number of parameters.static String
removeComments removes the comments starting with # in the text.static String
replaceEval
(String s, String replacement) static boolean
setEquals determines whether two string sets are identical.static String[]
splitCommaDelimited splits a comma-delimited string according to the default processing method of the CSV file into a string array.
-
Field Details
-
enableLog
public static boolean enableLog -
evalReg
-
escapeAssertionRegex
-
LOGGER
private static org.slf4j.Logger LOGGER -
md5AlgorithmName
- See Also:
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
logPrint
logPrint prints the log.- Parameters:
v
- the log.
-
logPrintf
logPrintf prints the log with the format.- Parameters:
format
- the format of the log.v
- the log.
-
logPrintfWarn
logPrintf prints the log with the format as a warning.- Parameters:
format
- the format of the log.v
- the log.
-
logPrintfError
logPrintf prints the log with the format as an error.- Parameters:
format
- the format of the log.v
- the log.
-
logPrintfError
logPrintf prints the log with the format as an error.- Parameters:
message
- the message accompanying the exceptiont
- the exception (throwable) to log
-
logEnforce
logEnforce prints the log of Enforce.- Parameters:
request
- the Enforce request.result
- the Enforce result.explain
- to explain enforcement by matched rules.
-
escapeAssertion
escapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.- Parameters:
s
- the value of the matcher and effect assertions.- Returns:
- the escaped value.
-
convertInSyntax
convertInSyntax Convert 'in' to 'include' to fit aviatorscript,because aviatorscript don't support native 'in' syntax- Parameters:
expString
- the value of the matcher- Returns:
- the 'include' expression.
-
removeComments
removeComments removes the comments starting with # in the text.- Parameters:
s
- a line in the model.- Returns:
- the line without comments.
-
arrayEquals
arrayEquals determines whether two string arrays are identical.- Parameters:
a
- the first array.b
- the second array.- Returns:
- whether a equals to b.
-
array2DEquals
array2DEquals determines whether two 2-dimensional string arrays are identical.- Parameters:
a
- the first 2-dimensional array.b
- the second 2-dimensional array.- Returns:
- whether a equals to b.
-
arrayRemoveDuplicates
arrayRemoveDuplicates removes any duplicated elements in a string array preserving the order.- Parameters:
s
- the array.- Returns:
- the array without duplicates.
-
arrayToString
arrayToString gets a printable string for a string array.- Parameters:
s
- the array.- Returns:
- the string joined by the array elements.
-
paramsToString
paramsToString gets a printable string for variable number of parameters.- Parameters:
s
- the parameters.- Returns:
- the string joined by the parameters.
-
splitCommaDelimited
splitCommaDelimited splits a comma-delimited string according to the default processing method of the CSV file into a string array. It assumes that any number of whitespace might exist before or after the token and that tokens do not include whitespace as part of their value unless they are enclosed by double quotes.- Parameters:
s
- the string.- Returns:
- the array with the string tokens.
-
setEquals
setEquals determines whether two string sets are identical.- Parameters:
a
- the first set.b
- the second set.- Returns:
- whether a equals to b.
-
hasEval
-
replaceEval
-
md5
-
getDigest
-
isJsonString
Helper method to check if a string is a valid JSON- Parameters:
str
- the string to be checked.- Returns:
- whether the string is a valid
-