public final class RegexpMatchFunctionHelper extends Object
WARNING: 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 from Pattern
(Java 7) in several ways. Therefore, we cannot use Pattern
directly. Find examples of differences below:
Pattern
matches the entire string against the pattern always, whereas xf: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, whereas Pattern
does not support this syntax but
&&[^
instead.[\P{X}]
. Pattern
only supports this form: [^\p{X}]
.\c
and \C
. Pattern
does not support them.xf:matches
but does not compile with Pattern
:
[\i-[:]][\c-[:]]*
Constructor and Description |
---|
RegexpMatchFunctionHelper(FirstOrderFunctionSignature<BooleanValue> matchFunctionSignature,
Datatype<? extends SimpleValue<String>> matchedDatatype)
Creates a "regex-match" (matching regular expressions) function helper
|
Modifier and Type | Method and Description |
---|---|
FirstOrderFunctionCall<BooleanValue> |
getCompiledRegexMatchCall(List<Expression<?>> argExpressions,
Datatype<?>... remainingArgTypes)
Creates regex-match function call using pre-compiled regex
|
static boolean |
match(StringValue regex,
SimpleValue<String> arg1)
Match a string against a regular expression
|
public RegexpMatchFunctionHelper(FirstOrderFunctionSignature<BooleanValue> matchFunctionSignature, Datatype<? extends SimpleValue<String>> matchedDatatype)
matchFunctionSignature
- signature of function that getCompiledRegexMatchCall(List, Datatype...)
must creatematchedDatatype
- datatype of value to be matched against the regular expressionpublic static boolean match(StringValue regex, SimpleValue<String> arg1) throws IllegalArgumentException
regex
- regular expressionarg1
- string valuearg1
matches regex
IllegalArgumentException
- regex
is not a valid regular expressionpublic FirstOrderFunctionCall<BooleanValue> getCompiledRegexMatchCall(List<Expression<?>> argExpressions, Datatype<?>... remainingArgTypes)
argExpressions
- input expressionsremainingArgTypes
- types of remaining arguments (after input expressions)Copyright © 2012–2020. All rights reserved.