本文整理了Java中org.onosproject.yangutils.datamodel.YangAtomicPath
类的一些代码示例,展示了YangAtomicPath
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangAtomicPath
类的具体详情如下:
包路径:org.onosproject.yangutils.datamodel.YangAtomicPath
类名称:YangAtomicPath
[英]Representation of data model node to maintain absolute path defined in YANG path-arg.
[中]表示数据模型节点,以维护YANG path arg中定义的绝对路径。
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
/**
* Returns the augment name, after removing the prefix, in each atomic
* content, which is equal to the root prefix.
*
* @param atomics atomic content list
* @param root root node
* @return prefix removed augment name
*/
public static String getPrefixRemovedName(List<YangAtomicPath> atomics,
YangNode root) {
String rootPrefix = getRootPrefix(root);
StringBuilder builder = new StringBuilder();
for (YangAtomicPath atomic : atomics) {
String id;
String prefix = atomic.getNodeIdentifier().getPrefix();
String name = atomic.getNodeIdentifier().getName();
if (rootPrefix.equals(prefix) || prefix == null) {
id = SLASH_FOR_STRING + name;
} else {
id = SLASH_FOR_STRING + prefix + COLON + name;
}
builder.append(id);
}
return builder.toString();
}
}
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
/**
* Returns the remaining path after parsing and processing an atomic
* content which doesn't have path-predicate.
*
* @param path leaf-ref path
* @param atomicList atomic content list
* @param pathType yang construct for creating error message
* @param pathCtx yang construct's context to get the line number
* and character position
* @return remaining path after parsing one atomic content
*/
public static String getPath(String path, List<YangAtomicPath> atomicList,
YangConstructType pathType,
PathStatementContext pathCtx) {
String comPath = path;
String nodeId;
if (comPath.contains(SLASH_FOR_STRING)) {
nodeId = comPath.substring(0, comPath.indexOf(CHAR_OF_SLASH));
comPath = comPath.substring(comPath.indexOf(CHAR_OF_SLASH));
} else {
nodeId = comPath;
comPath = null;
}
YangNodeIdentifier validNodeId =
getValidNodeIdentifier(nodeId, pathType, pathCtx);
YangAtomicPath atomicPath = new YangAtomicPath();
atomicPath.setNodeIdentifier(validNodeId);
atomicList.add(atomicPath);
return comPath;
}
代码示例来源:origin: org.onosproject/onos-yang-datamodel
/**
* Adds predicate expression in data holder.
*
* @param predicatesExp the predicate expression to be added
*/
public void addLeavesPredicate(YangPathPredicate predicatesExp) {
getPathPredicatesList().add(predicatesExp);
}
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
YangAtomicPath atomicPath = new YangAtomicPath();
YangNodeIdentifier validId =
getValidNodeIdentifier(nodeId, pathType, pathCtx);
pathType,
pathCtx, yangLeafRef);
atomicPath.setNodeIdentifier(validId);
atomicPath.setPathPredicatesList(predicates);
atomics.add(atomicPath);
return comPath;
代码示例来源:origin: org.onosproject/onos-yang-datamodel
/**
* Converts the prefixes in all the nodes of the leafref with respect to the uses node.
*
* @param leafrefForCloning leafref that is to be cloned
* @param yangUses instance of YANG uses where cloning is done
* @throws DataModelException data model error
*/
private static void convertThePrefixesDuringChange(YangLeafRef leafrefForCloning, YangUses yangUses)
throws DataModelException {
List<YangAtomicPath> atomicPathList = leafrefForCloning.getAtomicPath();
if (atomicPathList != null && !atomicPathList.isEmpty()) {
Iterator<YangAtomicPath> atomicPathIterator = atomicPathList.listIterator();
while (atomicPathIterator.hasNext()) {
YangAtomicPath atomicPath = atomicPathIterator.next();
Map<String, String> prefixesAndItsImportNameNode = leafrefForCloning.getPrefixAndNode();
String prefixInPath = atomicPath.getNodeIdentifier().getPrefix();
String importedNodeName = prefixesAndItsImportNameNode.get(prefixInPath);
assignCurrentLeafedWithNewPrefixes(importedNodeName, atomicPath, yangUses);
}
}
}
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
YangNodeIdentifier nodeId =
getValidNodeIdentifier(relPath, pathType, pathCtx);
YangAtomicPath atomicPath = new YangAtomicPath();
atomicPath.setNodeIdentifier(nodeId);
atomicList.add(atomicPath);
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
/**
* Returns the leaf which unique refers.
*
* @param nodeForLeaf last node where leaf is referred
* @param leafInUnique leaf in unique path
* @return YANG leaf
*/
private static YangLeaf getReferenceLeafFromUnique(YangNode nodeForLeaf, YangAtomicPath leafInUnique) {
YangLeavesHolder leavesHolder = (YangLeavesHolder) nodeForLeaf;
List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
if (leaves != null && !leaves.isEmpty()) {
for (YangLeaf leaf : leaves) {
if (leafInUnique.getNodeIdentifier().getName().equals(leaf.getName())) {
return leaf;
}
}
}
return null;
}
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
for (String nodeIdentifiers : tmpData) {
yangNodeIdentifier = getValidNodeIdentifier(nodeIdentifiers, yangConstructType, ctx);
YangAtomicPath yangAbsPath = new YangAtomicPath();
yangAbsPath.setNodeIdentifier(yangNodeIdentifier);
targetNodes.add(yangAbsPath);
代码示例来源:origin: org.onosproject/onos-yang-datamodel
/**
* Assigns leafref with new prefixes while cloning.
*
* @param importedNodeName imported node name from grouping
* @param atomicPath atomic path in leafref
* @param node instance of YANG uses where cloning is done
* @throws DataModelException data model error
*/
private static void assignCurrentLeafedWithNewPrefixes(String importedNodeName, YangAtomicPath atomicPath,
YangNode node)
throws DataModelException {
while (!(node instanceof YangReferenceResolver)) {
node = node.getParent();
if (node == null) {
throw new DataModelException("Internal datamodel error: Datamodel tree is not correct");
}
}
if (node instanceof YangModule) {
List<YangImport> importInUsesList = ((YangModule) node).getImportList();
if (importInUsesList != null && !importInUsesList.isEmpty()) {
Iterator<YangImport> importInUsesListIterator = importInUsesList.listIterator();
while (importInUsesListIterator.hasNext()) {
YangImport importInUsesNode = importInUsesListIterator.next();
if (importInUsesNode.getModuleName().equals(importedNodeName)) {
atomicPath.getNodeIdentifier().setPrefix(importInUsesNode.getPrefixId());
}
}
}
}
}
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
/**
* Validates the unique syntax from the reference path.
*
* @param uniquePath path of unique
* @param prefixOfFile current file's prefix
* @param ctx yang construct's context to get the line number and character position
* @return list of absolute path
*/
private static List<YangAtomicPath> validateUniqueValues(String uniquePath, String prefixOfFile,
ParserRuleContext ctx) {
List<YangAtomicPath> atomicPath = new LinkedList<>();
String[] pathInUnique = uniquePath.split(SLASH_FOR_STRING);
for (String uniqueValue : pathInUnique) {
YangAtomicPath yangAtomicPathPath = new YangAtomicPath();
YangNodeIdentifier nodeIdentifier = getValidNodeIdentifier(uniqueValue, YangConstructType.UNIQUE_DATA, ctx);
yangAtomicPathPath.setNodeIdentifier(nodeIdentifier);
atomicPath.add(yangAtomicPathPath);
if (nodeIdentifier.getPrefix() != null && nodeIdentifier.getPrefix() != prefixOfFile) {
ParserException parserException = new ParserException("YANG file error : A leaf reference, in unique," +
" must refer to a leaf in the list");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
}
return atomicPath;
}
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
/**
* Returns the last node under the unique path.
*
* @param uniquePath atomic path list
* @param node root node from where it starts searching
* @param ctx yang construct's context to get the line number and character position
* @return last node in the list
*/
private static YangNode getNodeUnderListFromPath(List<YangAtomicPath> uniquePath, YangNode node,
ParserRuleContext ctx) {
Iterator<YangAtomicPath> nodesInReference = uniquePath.listIterator();
YangNode potentialReferredNode = node.getChild();
while (nodesInReference.hasNext()) {
YangAtomicPath nodeInUnique = nodesInReference.next();
YangNode referredNode = getReferredNodeFromTheUniqueNodes(nodeInUnique.getNodeIdentifier(),
potentialReferredNode);
if (referredNode == null) {
ParserException parserException = new ParserException("YANG file error : The target node in unique " +
"reference path is invalid");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
} else {
potentialReferredNode = referredNode.getChild();
}
}
return potentialReferredNode;
}
代码示例来源:origin: org.onosproject/onos-yang-utils-parser
/**
* Validates the prefix of the YANG file where leaf-ref is present and
* puts it in the map of node and prefix in leaf-ref.
*
* @param atomicList atomic content list in leaf-ref
* @param leafRef YANG leaf-ref
*/
private static void valPrefix(List<YangAtomicPath> atomicList,
YangLeafRef leafRef) {
for (YangAtomicPath atomicPath : atomicList) {
String prefix = atomicPath.getNodeIdentifier().getPrefix();
YangNode parent = leafRef.getParentNode();
YangNode rootNode = getRootNode(parent);
List<YangImport> imports;
if (rootNode instanceof YangModule) {
imports = ((YangModule) rootNode).getImportList();
} else {
imports = ((YangSubModule) rootNode).getImportList();
}
updatePrefixWithNode(rootNode, imports, prefix, leafRef);
}
}
内容来源于网络,如有侵权,请联系作者删除!