diff options
Diffstat (limited to 'cps-path-parser/src/main')
3 files changed, 20 insertions, 1 deletions
diff --git a/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 b/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 index 74b99feb33..bb6bfc3942 100644 --- a/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 +++ b/cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4 @@ -27,10 +27,12 @@ grammar CpsPath ; -cpsPath : ( prefix | descendant ) multipleLeafConditions? textFunctionCondition? containsFunctionCondition? ancestorAxis? EOF ; +cpsPath : ( prefix | descendant ) multipleLeafConditions? textFunctionCondition? containsFunctionCondition? ancestorAxis? attributeAxis? EOF ; slash : SLASH ; +attributeAxis : SLASH AT leafName ; + ancestorAxis : KW_ANCESTOR_AXIS_PREFIX ancestorPath ; ancestorPath : yangElement ( slash yangElement)* ; diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java index b67d70847c..d0deb7defc 100644 --- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java +++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java @@ -131,6 +131,13 @@ public class CpsPathBuilder extends CpsPathBaseListener { } @Override + public void exitAttributeAxis(final CpsPathParser.AttributeAxisContext ctx) { + final String attributeName = ctx.leafName().getText(); + normalizedXpathBuilder.append("/@").append(attributeName); + cpsPathQuery.setAttributeAxisAttributeName(attributeName); + } + + @Override public void exitTextFunctionCondition(final TextFunctionConditionContext ctx) { cpsPathQuery.setTextFunctionConditionLeafName(ctx.leafName().getText()); cpsPathQuery.setTextFunctionConditionValue(unwrapQuotedString(ctx.StringLiteral().getText())); diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java index 03602b64f6..3612ec57fb 100644 --- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java +++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathQuery.java @@ -40,6 +40,7 @@ public class CpsPathQuery { private String descendantName; private List<LeafCondition> leafConditions; private String ancestorSchemaNodeIdentifier = ""; + private String attributeAxisAttributeName = ""; private String textFunctionConditionLeafName; private String textFunctionConditionValue; private List<String> booleanOperators; @@ -66,6 +67,15 @@ public class CpsPathQuery { } /** + * Has attribute axis been included in cpsPath. + * + * @return boolean value. + */ + public boolean hasAttributeAxis() { + return !(attributeAxisAttributeName.isEmpty()); + } + + /** * Have leaf value conditions been included in cpsPath. * * @return boolean value. |