本文整理了Java中org.onosproject.yang.compiler.datamodel.YangAtomicPath
类的一些代码示例,展示了YangAtomicPath
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangAtomicPath
类的具体详情如下:
包路径:org.onosproject.yang.compiler.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-compiler-linker
/**
* Returns target node when leaf-ref has only one absolute path in list.
*
* @param paths absolute paths
* @return target node
*/
private YangNode getTargetNodeWhenPathSizeIsOne(List<YangAtomicPath> paths) {
if (paths.get(0).getNodeIdentifier().getPrefix() != null &&
!paths.get(0).getNodeIdentifier().getPrefix().equals(
getRootsPrefix(rootNode))) {
return getImportedNode(rootNode, paths.get(0).getNodeIdentifier());
}
return rootNode;
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-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-compiler-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-compiler-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-compiler-linker
YangAtomicPath tempPath = pathIterator.next();
YangNodeIdentifier nodeId;
curPrefix = tempPath.getNodeIdentifier().getPrefix();
int index = 0;
YangNode tempAugment;
do {
nodeId = tempPath.getNodeIdentifier();
if (tempPath.getNodeIdentifier().getPrefix() == null) {
tempAugment = resolveIntraFileAugment(tempPath, root);
} else {
if (!tempPath.getNodeIdentifier().getPrefix().equals(curPrefix)) {
curPrefix = tempPath.getNodeIdentifier().getPrefix();
root = getImportedNode(rootNode, tempPath.getNodeIdentifier());
tempPath.setResolvedNode(tempNode);
validateTempPathNode(tempNode);
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Sets the left axis node in the YANG path predicate after finding it
* under the YANG list node.
*
* @param leafRef YANG leaf-ref
* @param atom atomic path content
* @param predicate predicate in the atomic path
* @throws DataModelException if there is a data model error
*/
private static void setLeftAxisNode(YangLeafRef<?> leafRef,
YangAtomicPath atom,
YangPathPredicate predicate)
throws DataModelException {
YangNode resolvedNode = atom.getResolvedNode();
if (!(resolvedNode instanceof YangList)) {
throw getDataModelExc(LEAF_REF_LIST_ERR, leafRef);
}
YangNodeIdentifier leftAxisName = predicate.getNodeId();
Object target = getTarget(leftAxisName, resolvedNode, leafRef);
predicate.setLeftAxisNode(target);
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Validates the nodes in the path for any invalid node.
*
* @param leafref instance of YANG leafref
*/
private void validateInvalidNodesInThePath(YangLeafRef leafref) {
for (YangAtomicPath absolutePath : (Iterable<YangAtomicPath>) leafref
.getAtomicPath()) {
YangNode nodeInPath = absolutePath.getResolvedNode();
if (nodeInPath instanceof LeafRefInvalidHolder) {
LinkerException ex = new LinkerException(
LEAFREF_ERROR + leafref.getPath() + IS_INVALID);
ex.setCharPosition(leafref.getCharPosition());
ex.setLine(leafref.getLineNumber());
ex.setFileName(leafref.getFileName());
throw ex;
}
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Searches for the augment node in imported module when prefix has changed from
* inter file to inter file.
*
* @param nodeId node id
* @param index index
* @return true if found
*/
private boolean searchForAugmentInImportedNode(YangNodeIdentifier nodeId,
int index) {
if (index == absPaths.size()) {
return false;
}
YangNodeIdentifier tempNodeId = absPaths.get(index).getNodeIdentifier();
return nodeId.getName().equals(tempNodeId.getName());
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
YangNodeIdentifier nodeId =
getValidNodeIdentifier(relPath, pathType, pathCtx);
YangAtomicPath atomicPath = new YangAtomicPath();
atomicPath.setNodeIdentifier(nodeId);
atomicList.add(atomicPath);
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Fills the path predicates of the leaf-ref with right axis node and
* left axis node, after linking the nodes.
*
* @param leafRef YANG leaf-ref
* @throws DataModelException if there is a data model error
*/
public static void fillPathPredicates(YangLeafRef<?> leafRef)
throws DataModelException {
List<YangAtomicPath> atomics = leafRef.getAtomicPath();
if (atomics != null) {
for (YangAtomicPath atom : atomics) {
List<YangPathPredicate> predicates =
atom.getPathPredicatesList();
if (predicates != null) {
for (YangPathPredicate predicate : predicates) {
setLeftAxisNode(leafRef, atom, predicate);
setRightAxisNode(leafRef, predicate);
}
}
}
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-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-compiler-linker
if (value != null && !value.isEmpty() && !value.equals(EMPTY_STRING)) {
YangNodeIdentifier nodeId = getValidNodeIdentifier(value, PATH_DATA);
YangAtomicPath atomicPath = new YangAtomicPath();
atomicPath.setNodeIdentifier(nodeId);
finalListForAbsolute.add(atomicPath);
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Process linking using for node identifier for inter/intra file.
*
* @param root root node
* @return linked target node
*/
private YangNode parseData(YangNode root) {
String rootPrefix = getRootsPrefix(root);
constructsParentsPrefix = rootPrefix;
Iterator<YangAtomicPath> pathIterator = absPaths.iterator();
YangAtomicPath path = pathIterator.next();
if (path.getNodeIdentifier().getPrefix() != null
&& !path.getNodeIdentifier().getPrefix().equals(rootPrefix)) {
return parsePath(getImportedNode(root, path.getNodeIdentifier()));
} else {
return parsePath(root);
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-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-compiler-linker
prePrefix = curPrefix;
absPath = pathIterator.next();
curPrefix = absPath.getNodeIdentifier().getPrefix();
if (curPrefix != null && !(curPrefix.equals(rootPrefix))) {
if (!curPrefix.equals(prePrefix)) {
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
String[] path = val.split(SLASH_FOR_STRING);
for (String uniVal : path) {
YangAtomicPath atomicPath = new YangAtomicPath();
YangNodeIdentifier id = getValidNodeIdentifier(uniVal, type, ctx);
atomicPath.setNodeIdentifier(id);
pathList.add(atomicPath);
if (id.getPrefix() != null &&
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
if (curPrefix != tempPath.getNodeIdentifier().getPrefix()) {
root = getIncludedNode(rootNode, tempPath.getNodeIdentifier().getName());
if (root == null) {
root = getIncludedNode(rootNode, getAugmentNodeIdentifier(
tempPath.getNodeIdentifier(), absPaths, rootNode));
if (root == null) {
root = rootNode;
root = getImportedNode(root, tempPath.getNodeIdentifier());
curPrefix = tempPath.getNodeIdentifier().getPrefix();
tempAugment = getAugment(tempPath.getNodeIdentifier(), root, absPaths);
if (tempAugment == null) {
tempAugment = getAugment(tempPath.getNodeIdentifier(), rootNode,
absPaths);
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Resolves inter file augment linking.
*
* @param tempPath temporary absolute path
* @param root root node
* @param size node size
* @return linked target node
*/
private YangNode resolveInterFileAugment(YangAtomicPath tempPath,
YangNode root, int size) {
YangNode tempAugment = getAugment(tempPath.getNodeIdentifier(), root, absPaths);
if (tempAugment == null) {
return resolveInterToInterFileAugment(root, size);
}
return tempAugment;
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Removes deviation target node from cloned data model.
*
* @param target deviation target node
* @param targetPath deviation target's last node
*/
private void resolveDeviationNotSupported(YangSchemaNode target,
YangAtomicPath targetPath) {
if (target.getName().equals(targetPath.getNodeIdentifier().getName())) {
deleteUnsupportedNodeFromTree((YangNode) target);
} else {
deleteUnsupportedLeafOrLeafList((YangLeavesHolder) target,
targetPath.getNodeIdentifier().getName());
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-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);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!