- private static Logger logger = FlexLogger.getLogger(FunctionDefinitionCustomRegexpMatch.class);
-
- /**
- * Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation.
- *
- * @param idIn
- * @param dataTypeArgsIn
- */
- public FunctionDefinitionCustomRegexpMatch(Identifier idIn, DataType<I> dataTypeArgsIn) {
- super(idIn, DataTypes.DT_BOOLEAN, dataTypeArgsIn, false);
- }
-
-
- @Override
- public ExpressionResult evaluate(EvaluationContext evaluationContext, List<FunctionArgument> arguments) {
-
- if (arguments == null || arguments.size() != 2) {
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " Expected 2 arguments, got " +
- ((arguments == null) ? "null" : arguments.size()) ));
- }
-
- // get the regular expression
- FunctionArgument regexpArgument = arguments.get(0);
-
- ConvertedArgument<String> convertedArgument = new ConvertedArgument<>(regexpArgument, DataTypes.DT_STRING, false);
- if ( ! convertedArgument.isOk()) {
- return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus()));
- }
-
- // String regexpValue = (String)regexpArgument.getValue().getValue();
- String regexpValue = convertedArgument.getValue();
-
-
- // now get the element to match
- FunctionArgument elementArgument = arguments.get(1);
-
- ConvertedArgument<I> convertedElement = new ConvertedArgument<>(elementArgument, this.getDataTypeArgs(), false);
- if ( ! convertedElement.isOk()) {
- return ExpressionResult.newError(getFunctionStatus(convertedElement.getStatus()));
- }
-
- I elementValueObject = convertedElement.getValue();
-
- String elementValueString;
- try {
- elementValueString = this.getDataTypeArgs().toStringValue(elementValueObject);
- } catch (DataTypeException e) {
- logger.error(e.getMessage() +e);
- String message = e.getMessage();
- if (e.getCause() != null) {
- message = e.getCause().getMessage();
- }
- return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId() + " " + message));
- }
-
- // ConvertedArgument checks for null value, so do not need to do again here
-
- // Adding this code will Change the Functionality which allows to retrieve Multiple-policy using single request.
- elementValueString = elementValueString + regexpValue ;
- regexpValue = elementValueString.substring(0,(elementValueString.length()- regexpValue.length()));
- elementValueString = elementValueString.substring(regexpValue.length(),(elementValueString.length()));
- //
- // Supporting multiple values in the element and be able to query them.
- if(elementValueString.contains(",")){
- String[] elements = elementValueString.split(",");
- for(int i=0; i<elements.length; i++){
- if(elements[i].trim().matches(regexpValue)) {
- return ER_TRUE;
- }
- }
- }
- if (elementValueString.matches(regexpValue)) {
- return ER_TRUE;
- } else {
- return ER_FALSE;
- }
-
- }
+ private static Logger logger = FlexLogger.getLogger(FunctionDefinitionCustomRegexpMatch.class);
+
+ /**
+ * Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation.
+ *
+ * @param idIn the identifier
+ * @param dataTypeArgsIn the data type
+ */
+ public FunctionDefinitionCustomRegexpMatch(final Identifier idIn, final DataType<I> dataTypeArgsIn) {
+ super(idIn, DataTypes.DT_BOOLEAN, dataTypeArgsIn, false);
+ }
+
+
+ @Override
+ public ExpressionResult evaluate(final EvaluationContext evaluationContext,
+ final List<FunctionArgument> arguments) {
+
+ if (arguments == null || arguments.size() != 2) {
+ return ExpressionResult
+ .newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, this.getShortFunctionId()
+ + " Expected 2 arguments, got " + ((arguments == null) ? "null" : arguments.size())));
+ }
+
+ // get the regular expression
+ final FunctionArgument regexpArgument = arguments.get(0);
+
+ final ConvertedArgument<String> convertedArgument =
+ new ConvertedArgument<>(regexpArgument, DataTypes.DT_STRING, false);
+ if (!convertedArgument.isOk()) {
+ return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus()));
+ }
+
+ // String regexpValue = (String)regexpArgument.getValue().getValue();
+ String regexpValue = convertedArgument.getValue();
+
+
+ // now get the element to match
+ final FunctionArgument elementArgument = arguments.get(1);
+
+ final ConvertedArgument<I> convertedElement =
+ new ConvertedArgument<>(elementArgument, this.getDataTypeArgs(), false);
+ if (!convertedElement.isOk()) {
+ return ExpressionResult.newError(getFunctionStatus(convertedElement.getStatus()));
+ }
+
+ final I elementValueObject = convertedElement.getValue();
+
+ String elementValueString;
+ try {
+ elementValueString = this.getDataTypeArgs().toStringValue(elementValueObject);
+ } catch (final DataTypeException e) {
+ logger.error(e.getMessage() + e);
+ String message = e.getMessage();
+ if (e.getCause() != null) {
+ message = e.getCause().getMessage();
+ }
+ return ExpressionResult.newError(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
+ this.getShortFunctionId() + " " + message));
+ }
+
+ // ConvertedArgument checks for null value, so do not need to do again here
+
+ // Adding this code will Change the Functionality which allows to retrieve Multiple-policy using single request.
+ elementValueString = elementValueString + regexpValue;
+ regexpValue = elementValueString.substring(0, (elementValueString.length() - regexpValue.length()));
+ elementValueString = elementValueString.substring(regexpValue.length(), (elementValueString.length()));
+ //
+ // Supporting multiple values in the element and be able to query them.
+ if (elementValueString.contains(",")) {
+ final String[] elements = elementValueString.split(",");
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i].trim().matches(regexpValue)) {
+ return ER_TRUE;
+ }
+ }
+ }
+ if (elementValueString.matches(regexpValue)) {
+ return ER_TRUE;
+ } else {
+ return ER_FALSE;
+ }
+
+ }