Class RegexpMatchFunctionHelper
- java.lang.Object
-
- org.ow2.authzforce.core.pdp.api.func.RegexpMatchFunctionHelper
-
public final class RegexpMatchFunctionHelper extends Object
*-regexp-match function helperWARNING: the regular expression syntax required by XACML refers to the
xf:matches
function from [XF] (see the XACML core spec for this reference). This function and associated syntax differ fromPattern
(Java 7) in several ways. Therefore, we cannot usePattern
directly. Find examples of differences below:Pattern
matches the entire string against the pattern always, whereasxf:matches
considers the string to match the pattern if any substring matches the pattern.xf:matches
regular expression syntax is based on XML schema which defines character class substraction using '-' character, whereasPattern
does not support this syntax but&&[^
instead.- Category escape: can be done in XML SCHEMA with:
[\P{X}]
.Pattern
only supports this form:[^\p{X}]
. - Character classes: XML schema define categories
\c
and\C
.Pattern
does not support them.
xf:matches
but does not compile withPattern
:[\i-[:]][\c-[:]]*
-
-
Constructor Summary
Constructors Constructor Description RegexpMatchFunctionHelper(FirstOrderFunctionSignature<BooleanValue> matchFunctionSignature, Datatype<? extends SimpleValue<String>> matchedDatatype)
Creates a "regex-match" (matching regular expressions) function helper
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FirstOrderFunctionCall<BooleanValue>
getCompiledRegexMatchCall(List<Expression<?>> argExpressions, Datatype<?>... remainingArgTypes)
Creates regex-match function call using pre-compiled regexstatic boolean
match(StringValue regex, SimpleValue<String> arg1)
Match a string against a regular expression
-
-
-
Constructor Detail
-
RegexpMatchFunctionHelper
public RegexpMatchFunctionHelper(FirstOrderFunctionSignature<BooleanValue> matchFunctionSignature, Datatype<? extends SimpleValue<String>> matchedDatatype)
Creates a "regex-match" (matching regular expressions) function helper- Parameters:
matchFunctionSignature
- signature of function thatgetCompiledRegexMatchCall(List, Datatype...)
must creatematchedDatatype
- datatype of value to be matched against the regular expression
-
-
Method Detail
-
match
public static boolean match(StringValue regex, SimpleValue<String> arg1) throws IllegalArgumentException
Match a string against a regular expression- Parameters:
regex
- regular expressionarg1
- string value- Returns:
- true iff
arg1
matchesregex
- Throws:
IllegalArgumentException
-regex
is not a valid regular expression
-
getCompiledRegexMatchCall
public FirstOrderFunctionCall<BooleanValue> getCompiledRegexMatchCall(List<Expression<?>> argExpressions, Datatype<?>... remainingArgTypes)
Creates regex-match function call using pre-compiled regex- Parameters:
argExpressions
- input expressionsremainingArgTypes
- types of remaining arguments (after input expressions)- Returns:
- function call using compiled regex from first argument if constant value; or null if first argument is not constant
-
-