in src/main/java/org/apache/commons/configuration2/tree/xpath/XPathExpressionEngine.java [293:337]
<T> NodeAddData<T> createNodeAddData(final String path, final QueryResult<T> parentNodeResult) {
if (parentNodeResult.isAttributeResult()) {
invalidPath(path, " cannot add properties to an attribute.");
}
final List<String> pathNodes = new LinkedList<>();
String lastComponent = null;
boolean attr = false;
boolean first = true;
final StringTokenizer tok = new StringTokenizer(path, NODE_PATH_DELIMITERS, true);
while (tok.hasMoreTokens()) {
final String token = tok.nextToken();
if (PATH_DELIMITER.equals(token)) {
if (attr) {
invalidPath(path, " contains an attribute" + " delimiter at a disallowed position.");
}
if (lastComponent == null) {
invalidPath(path, " contains a '/' at a disallowed position.");
}
pathNodes.add(lastComponent);
lastComponent = null;
} else if (ATTR_DELIMITER.equals(token)) {
if (attr) {
invalidPath(path, " contains multiple attribute delimiters.");
}
if (lastComponent == null && !first) {
invalidPath(path, " contains an attribute delimiter at a disallowed position.");
}
if (lastComponent != null) {
pathNodes.add(lastComponent);
}
attr = true;
lastComponent = null;
} else {
lastComponent = token;
}
first = false;
}
if (lastComponent == null) {
invalidPath(path, "contains no components.");
}
return new NodeAddData<>(parentNodeResult.getNode(), lastComponent, attr, pathNodes);
}