diff options
Diffstat (limited to 'cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java')
-rw-r--r-- | cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java index 97d7d1d76..60f0e2efc 100644 --- a/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java +++ b/cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathUtil.java @@ -20,6 +20,9 @@ package org.onap.cps.cpspath.parser; +import static org.onap.cps.cpspath.parser.CpsPathPrefixType.ABSOLUTE; + +import java.util.List; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -45,8 +48,34 @@ public class CpsPathUtil { * @return a normalized xpath String. */ public static String getNormalizedXpath(final String xpathSource) { - final CpsPathBuilder cpsPathBuilder = getCpsPathBuilder(xpathSource); - return cpsPathBuilder.build().getNormalizedXpath(); + return getCpsPathBuilder(xpathSource).build().getNormalizedXpath(); + } + + /** + * Returns the parent xpath. + * + * @param xpathSource xpath + * @return the parent xpath String. + */ + public static String getNormalizedParentXpath(final String xpathSource) { + return getCpsPathBuilder(xpathSource).build().getNormalizedParentPath(); + } + + public static String[] getXpathNodeIdSequence(final String xpathSource) { + final List<String> containerNames = getCpsPathBuilder(xpathSource).build().getContainerNames(); + return containerNames.toArray(new String[containerNames.size()]); + } + + + /** + * Returns boolean indicating xpath is an absolute path to a list element. + * + * @param xpathSource xpath + * @return true if xpath is an absolute path to a list element + */ + public static boolean isPathToListElement(final String xpathSource) { + final CpsPathQuery cpsPathQuery = getCpsPathBuilder(xpathSource).build(); + return cpsPathQuery.getCpsPathPrefixType() == ABSOLUTE && cpsPathQuery.hasLeafConditions(); } /** @@ -57,8 +86,7 @@ public class CpsPathUtil { */ public static CpsPathQuery getCpsPathQuery(final String cpsPathSource) { - final CpsPathBuilder cpsPathBuilder = getCpsPathBuilder(cpsPathSource); - return cpsPathBuilder.build(); + return getCpsPathBuilder(cpsPathSource).build(); } private static CpsPathBuilder getCpsPathBuilder(final String cpsPathSource) { |