gpt4 book ai didi

org.onosproject.yangutils.datamodel.YangAtomicPath.getNodeIdentifier()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 11:55:31 26 4
gpt4 key购买 nike

本文整理了Java中org.onosproject.yangutils.datamodel.YangAtomicPath.getNodeIdentifier()方法的一些代码示例,展示了YangAtomicPath.getNodeIdentifier()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangAtomicPath.getNodeIdentifier()方法的具体详情如下:
包路径:org.onosproject.yangutils.datamodel.YangAtomicPath
类名称:YangAtomicPath
方法名:getNodeIdentifier

YangAtomicPath.getNodeIdentifier介绍

[英]Returns the node identifier.
[中]返回节点标识符。

代码示例

代码示例来源: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-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

/**
 * 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-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

/**
 * 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);
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com