summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java
diff options
context:
space:
mode:
authorshivasubedi <shiva.subedi@est.tech>2021-04-22 14:54:49 +0100
committershivasubedi <shiva.subedi@est.tech>2021-04-26 11:05:59 +0100
commit0d8464363d70fa470c048bb4cd1f24a9e79d7cce (patch)
tree42f8e219db6cca4978944631ffd3ec4c50bfcf42 /cps-ri/src/main/java
parent51ddaf6a3e004e9e9940d6ae3dc9b9e01188a85b (diff)
Leaf String value comparison matches mix of single and double quotes
Issue-ID: CPS-345 Signed-off-by: shivasubedi <shiva.subedi@est.tech> Change-Id: Id6db86817878ed5ed8ccaed4a9a71c5a06d6f97c
Diffstat (limited to 'cps-ri/src/main/java')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java b/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java
index c5861bd4b6..ac7e7e0ac3 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java
@@ -52,7 +52,8 @@ public class CpsPathQuery {
private static final Pattern LEAF_INTEGER_VALUE_PATTERN = Pattern.compile("[-+]?\\d+");
- private static final Pattern LEAF_STRING_VALUE_PATTERN = Pattern.compile("['\"](.*)['\"]");
+ private static final Pattern LEAF_STRING_VALUE_IN_SINGLE_QUOTES_PATTERN = Pattern.compile("'(.*)'");
+ private static final Pattern LEAF_STRING_VALUE_IN_DOUBLE_QUOTES_PATTERN = Pattern.compile("\"(.*)\"");
private static final String YANG_MULTIPLE_LEAF_VALUE_EQUALS_CONDITION = "\\[(.*?)\\s{0,9}]";
@@ -118,9 +119,15 @@ public class CpsPathQuery {
}
private static Object convertLeafValueToCorrectType(final String leafValueString, final String cpsPath) {
- final Matcher stringValueWithQuotesMatcher = LEAF_STRING_VALUE_PATTERN.matcher(leafValueString);
- if (stringValueWithQuotesMatcher.matches()) {
- return stringValueWithQuotesMatcher.group(1);
+ final Matcher stringValueWithSingleQuotesMatcher =
+ LEAF_STRING_VALUE_IN_SINGLE_QUOTES_PATTERN.matcher(leafValueString);
+ if (stringValueWithSingleQuotesMatcher.matches()) {
+ return stringValueWithSingleQuotesMatcher.group(1);
+ }
+ final Matcher stringValueWithDoubleQuotesMatcher =
+ LEAF_STRING_VALUE_IN_DOUBLE_QUOTES_PATTERN.matcher(leafValueString);
+ if (stringValueWithDoubleQuotesMatcher.matches()) {
+ return stringValueWithDoubleQuotesMatcher.group(1);
}
final Matcher integerValueMatcher = LEAF_INTEGER_VALUE_PATTERN.matcher(leafValueString);
if (integerValueMatcher.matches()) {