}
@Override
public Value evaluate(FunctionArgument[] args, Value value) {
if(Array.getLength(args) != 2) {
throw new JPathRuntimeException("InvalidArgCount");
}
if(args[0] == null || args[0].type != ARGUMENT_TYPE.ATTRIBUTE) {
throw new JPathRuntimeException("InvalidArg", args[0]);
}
if(args[1] == null || args[1].type != ARGUMENT_TYPE.VALUE) {
throw new JPathRuntimeException("InvalidArg", args[1]);
}
String attributeName = ((AttributeArgument) args[0]).getAttributeName();
if(!value.has(attributeName)) {
return null;
}
Value regexValue = ((ValueArgument) args[1]).getValue();
if(regexValue.getValueType() != Value.TYPE.STRING) {
throw new JPathRuntimeException("InvalidArg", args[1]);
}
Value matchValue = value.get(attributeName);
Pattern pattern = Pattern.compile(regexValue.getString());