gpt4 book ai didi

org.onosproject.yang.compiler.datamodel.YangNode类的使用及代码示例

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

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

YangNode介绍

[英]Represents base class of a node in data model tree.
[中]表示数据模型树中节点的基类。

代码示例

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

if (newSibling.getNodeType() == null) {
  throw new DataModelException("Cloned abstract node cannot be " +
                     "inserted into a tree "
                     + getName() + " in " +
                     getLineNumber() + " at " +
                     getCharPosition()
                     + " in " + getFileName() + "\"");
if (newSibling.getParent() == null) {
  newSibling.setParent(getParent());
} else {
  throw new DataModelException("Node is already part of a tree, " +
                     "and cannot be added as a " +
                     "sibling " + getName() + " in " +
                     getLineNumber() + " at " +
                     getCharPosition() + " in " +
                     getFileName() + "\"");
if (newSibling.getPreviousSibling() == null) {
  newSibling.setPreviousSibling(this);
  setNextSibling(newSibling);
} else {
  throw new DataModelException("New sibling to be added is not " +
                     "atomic, it already has a " +
                     "previous sibling " +
                     getName() + " in " +
                     getLineNumber() + " at " +
                     getCharPosition() + " in " +

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

nextNodeToClone = childToClone;
} else {
  nextNodeToClone = srcRootNode.getChild();
                         "tree null pointer " +
                         "reached " +
                         nextNodeToClone.getName() +
                         " in " + nextNodeToClone.getLineNumber() +
                         " at " + nextNodeToClone.getCharPosition() +
                         " in " + nextNodeToClone.getFileName() + "\"");
      newNode = nextNodeToClone.clone(yangUses, isDeviation,
                      isAnydata);
      if (newNode instanceof YangUses) {
        ((YangUses) newNode).setCloned(true);
      detectCollisionWhileCloning(clonedTreeCurNode, newNode,
                    curTraversal);
      clonedTreeCurNode.addChild(newNode);
      clonedTreeCurNode.addNextSibling(newNode);
      clonedTreeCurNode = newNode;
    } else {
      clonedTreeCurNode = clonedTreeCurNode.getParent();
        (clonedTreeCurNode.getParent() instanceof YangUses)) {
      YangAugment augment = (YangAugment) clonedTreeCurNode;

代码示例来源:origin: org.onosproject/onos-yang-compiler-linker

private static void processHierarchyChild(YangNode node,
                     Map<YangNode, List<YangNode>> map) {
  YangNode child = node.getChild();
  if (child != null) {
    List<YangNode> nodes = new ArrayList<>();
    while (child != null) {
      nodes.add(child);
      child.setParent(null);
      child = child.getNextSibling();
      if (child != null) {
        child.getPreviousSibling().setNextSibling(null);
        child.setPreviousSibling(null);
      }
    }
    map.put(node, nodes);
  }
  node.setChild(null);
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Returns true if op type info required for node.
 *
 * @return true if op type info required for node
 */
public boolean isOpTypeReq() {
  return this instanceof RpcNotificationContainer ||
      !(this instanceof InvalidOpTypeHolder) &&
          getParent().isOpTypeReq();
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Processes addition of schema node child to parent map.
 *
 * @param name      name of the node
 * @param namespace namespace of the node
 */
protected void processAdditionOfSchemaNodeToParentMap(String name,
                           YangNamespace namespace) {
  processAdditionOfSchemaNodeToMap(name, namespace, this, getParent());
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-linker

/**
   * Sets descendant node augmented flag in ancestors.
   *
   * @param targetNode augmented YANG node
   */
  private void setAugmentedFlagInAncestors(YangNode targetNode) {
    targetNode = targetNode.getParent();
    while (targetNode != null) {
      targetNode.setDescendantNodeAugmented(true);
      targetNode = targetNode.getParent();
    }
  }
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

@Override
public void isValueValid(String value)
    throws DataModelException {
  throw new DataModelException("Value validation asked for YANG node. "
                     + getName() + " in " +
                     getLineNumber() + " at " +
                     getCharPosition()
                     + " in " + getFileName() + "\"");
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-linker

/**
 * Verifies for child nodes in sub module.
 *
 * @param node submodule node
 * @param name name of child node
 * @return true if child node found
 */
private boolean verifyChildNode(YangNode node, String name) {
  node = node.getChild();
  while (node != null) {
    if (node.getName().equals(name)) {
      return true;
    }
    node = node.getNextSibling();
  }
  return false;
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-linker

YangNode curNode = node.getChild();
while (curNode != null) {
  if (curNode.getName().equals(node.getName())) {
  if (curTraversal != PARENT && curNode.getChild() != null) {
    curTraversal = CHILD;
    curNode = curNode.getChild();
  } else if (curNode.getNextSibling() != null) {
    curTraversal = SIBLING;
    curNode = curNode.getNextSibling();
  } else {
    curTraversal = PARENT;
    curNode = curNode.getParent();

代码示例来源:origin: org.onosproject/onos-yang-compiler-parser

while (augChild != null) {
  if (lastChild == logical) {
    augChild.setParent(lastChild);
    try {
      lastChild.addChild(augChild);
    } catch (DataModelException e) {
      throw new ParserException(
    augChild.setParent(lastChild.getParent());
    augChild.setPreviousSibling(lastChild);
    lastChild.setNextSibling(augChild);
  augChild = augChild.getNextSibling();

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

@Override
public YangNode clone(YangUses node, boolean isDeviation, boolean isAnyData) throws
    CloneNotSupportedException {
  YangNode clnNode = (YangNode) super.clone();
  clnNode.setParent(null);
  clnNode.setChild(null);
  clnNode.setNextSibling(null);
  clnNode.setPreviousSibling(null);
  return clnNode;
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Checks if there is any rpc defined in the module or sub-module.
 *
 * @param rootNode root node of the data model
 * @return status of rpc's existence
 */
public static boolean isRpcChildNodePresent(YangNode rootNode) {
  YangNode childNode = rootNode.getChild();
  while (childNode != null) {
    if (childNode instanceof YangRpc) {
      return true;
    }
    childNode = childNode.getNextSibling();
  }
  return false;
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-linker

resolver.resolveIdentityExtendList();
} catch (DataModelException e) {
  String errorInfo = "Error in file: " + yangNode.getName() +
      " in " + yangNode.getFileName() + " at " +
      "line: " + e.getLineNumber() + " at position: " +
      e.getCharPositionInLine() + NEW_LINE +
  String errorInfo = "Error in file: " + yangNode.getName() +
      " in " + yangNode.getFileName() + " at " +
      "line: " + e.getLineNumber() + " at position: " +
      e.getCharPositionInLine() + NEW_LINE +

代码示例来源:origin: org.onosproject/onos-yang-compiler-linker

caseNodes.add(child);
child = child.getNextSibling();
node.setNextSibling(null);
node.setPreviousSibling(null);
node.setParent(null);
YangCase javaCase = getYangCaseNode(JAVA_GENERATION);
javaCase.setName(node.getName());
node.setParent(javaCase);
javaCase.addChild(node);
node.setNextSibling(null);
node.setPreviousSibling(null);
node.setParent(null);
node.setParent(augment);

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Adds namespace for self, next sibling and first child. This is used
 * after obtaining namespace in case of submodule after performing
 * linking.
 */
public void setNameSpaceAndAddToParentSchemaMap() {
  // Get parent namespace.
  if (getParent() != null && getParent().getNodeType() != ANYDATA_NODE) {
    // Get parent namespace and set namespace for self node.
    setNameSpace(getParent().getNameSpace());
    // Process addition of leaf to the child schema map of parent.
    processAdditionOfSchemaNodeToParentMap(getName(), getNameSpace());
  } else if (getParent() != null && getParent().getNodeType() == ANYDATA_NODE) {
    processAdditionOfSchemaNodeToParentMap(getName(), getNameSpace());
  } else {
    // Module/Sub-module
    setNameSpace((YangNamespace) this);
  }
  /*
   * Check if node contains leaf/leaf-list, if yes add namespace for leaf
   * and leaf list.
   */
  if (this instanceof YangLeavesHolder) {
    ((YangLeavesHolder) this).setLeafNameSpaceAndAddToParentSchemaMap();
  }
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-parser

/**
   * Removes the duplicate YANG augment from the data tree by detaching it
   * from its parent and from its sibling.
   *
   * @param augment duplicate YANG augment
   */
  public static void removeAugment(YangAugment augment) {
    YangNode root = augment.getParent();
    YangNode child = root.getChild();
    YangNode pSib = null;
    if (child == null) {
      throw new ParserException("The root node of augment " + augment
          .getName() + " must have atleast one child");
    }
    while (child != null) {
      if (child == augment) {
        if (pSib == null) {
          root.setChild(null);
        } else {
          pSib.setNextSibling(null);
        }
      }
      pSib = child;
      child = child.getNextSibling();
    }
    augment = new YangJavaAugmentTranslator();
    augment = null;
  }
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-linker

private static void connectTree(Map<YangNode, List<YangNode>> map)
    throws DataModelException {
  ArrayList<YangNode> keys = new ArrayList<>(map.keySet());
  int size = keys.size();
  for (int i = size - 1; i >= 0; i--) {
    YangNode curNode = keys.get(i);
    List<YangNode> nodes = map.get(curNode);
    if (nodes != null) {
      for (YangNode node : nodes) {
        curNode.addChild(node);
      }
    }
  }
  map.clear();
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
   * Composes the error message for given new and existing YANG node
   * name conflict.
   *
   * @param node    newly added YANG node
   * @param oldNode existing YANG node.
   */
  private static String composeErrorMsg(YangNode node, YangNode oldNode) {
    return "Node with name " + node.getName() + " in file " +
        node.getFileName() + " at line " + node.getLineNumber() +
        " is already present " + "in file " + oldNode.getFileName() +
        " at " + "line " + oldNode.getLineNumber() + "" + ".";
  }
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

/**
 * Returns referred node.
 *
 * @param nodeId     node identifier
 * @param potRefNode potential referred node
 * @return potential referred node
 */
private static YangNode getNode(YangNodeIdentifier nodeId,
                YangNode potRefNode) {
  while (potRefNode != null) {
    if (potRefNode.getName().equals(nodeId.getName())) {
      return potRefNode;
    }
    potRefNode = potRefNode.getNextSibling();
  }
  return null;
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel

@Override
  public YangSchemaNode addSchema(YangSchemaNode containedSchema) throws
      IllegalArgumentException {
    YangNode nodeToClone = (YangNode) containedSchema;
    try {
      cloneSubTree(nodeToClone.getParent(), this, null,
             false, nodeToClone);
    } catch (DataModelException e) {
      throw new IllegalArgumentException(e);
    }
    YangNode child = getChild();
    // Contained Schema Name
    String name = containedSchema.getName();
    while (child.getName() != name) {
      child = child.getNextSibling();
    }
    return child;
  }
}

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