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 booleanarray2DEquals determines whether two 2-dimensional string arrays are identical.static booleanarrayEquals(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 StringarrayToString(List<String> s) arrayToString gets a printable string for a string array.static StringconvertInSyntax(String expString) convertInSyntax Convert 'in' to 'include' to fit aviatorscript,because aviatorscript don't support native 'in' syntaxstatic StringescapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.private static MessageDigeststatic booleanstatic booleanisJsonString(String str) Helper method to check if a string is a valid JSONstatic voidlogEnforce(Object[] request, boolean result, List<String> explain) logEnforce prints the log of Enforce.static voidlogPrint prints the log.static voidlogPrintf prints the log with the format.static voidlogPrintfError(String format, Object... v) logPrintf prints the log with the format as an error.static voidlogPrintfError(String message, Throwable t) logPrintf prints the log with the format as an error.static voidlogPrintfWarn(String format, Object... v) logPrintf prints the log with the format as a warning.static Stringstatic StringparamsToString(String[] s) paramsToString gets a printable string for variable number of parameters.static StringremoveComments removes the comments starting with # in the text.static StringreplaceEval(String s, String replacement) static booleansetEquals 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
-