gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-17 04:41:31 26 4
gpt4 key购买 nike

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

YangNode介绍

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

代码示例

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

if (newChild.getNodeType() == null) {
  throw new DataModelException("Abstract node cannot be inserted " +
                     "into a tree " + getName() +
                     " in " + getLineNumber() +
                     " at " + getCharPosition() +
                     " in " + getFileName() + "\"");
if (newChild.getParent() == null) {
  newChild.setParent(this);
} else if (newChild.getParent() != this) {
  throw new DataModelException("Node is already part of a tree " +
                     getName() + " in " +
                     getLineNumber() + " at " +
                     getCharPosition() + " in " +
                     getFileName() + "\"");
if (newChild.getChild() != null) {
  throw new DataModelException("Child to be added is not atomic, " +
                     "it already has a child " +
                     getName() + " in " +
                     getLineNumber() + " at " +
                     getCharPosition() + " in " +
                     getFileName() + "\"");
if (newChild.getNextSibling() != null) {
  throw new DataModelException("Child to be added is not atomic, " +
                     "it already has a next " +
                     "sibling " + getName() +
                     " in " + getLineNumber() +

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

nextNodeToClone = nextNodeToClone.getChild();
if (nextNodeToClone == null) {
  return;
                         "tree null pointer " +
                         "reached " +
                         nextNodeToClone.getName() +
                         " in " + nextNodeToClone.getLineNumber() +
                         " at " + nextNodeToClone.getCharPosition() +
                         " in " + nextNodeToClone.getFileName() + "\"");
      newNode = nextNodeToClone.clone(yangUses);
      detectCollisionWhileCloning(clonedTreeCurNode, newNode,
                    curTraversal);
      clonedTreeCurNode.addChild(newNode);
      clonedTreeCurNode.addNextSibling(newNode);
      clonedTreeCurNode = newNode;
    } else {
      clonedTreeCurNode = clonedTreeCurNode.getParent();
    if (curTraversal != PARENT && nextNodeToClone.getChild() != null) {
      curTraversal = CHILD;
      nextNodeToClone = nextNodeToClone.getChild();
    } else if (nextNodeToClone.getNextSibling() != null) {

代码示例来源:origin: org.onosproject/onos-yang-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-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-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-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-datamodel

while (curNode != null) {
  if (curNode == referredGrouping || (curNode instanceof YangUses &&
  curNode.getName().equals(referredGrouping.getName()))) {
  if (curTraversal != PARENT && curNode.getChild() != null) {
    curTraversal = CHILD;
    curNode = curNode.getChild();
  } else if (curNode.getNextSibling() != null) {
    curTraversal = SIBILING;
    curNode = curNode.getNextSibling();
  } else {
    curTraversal = PARENT;
    curNode = curNode.getParent();

代码示例来源:origin: org.onosproject/onos-yang-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) {
    // 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 {
    // 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-utils-parser

/**
   * Adds the enumeration node to the parent holder.
   *
   * @param listener listener's object
   * @param enumerationNode enumeration node which needs to be added to parent
   */
  private static void addChildToParentNode(TreeWalkListener listener, YangEnumeration enumerationNode) {
    if (!(listener.getParsedDataStack().peek() instanceof YangNode)) {
      throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, ENUMERATION_DATA,
          "", ENTRY));
    } else {
      YangNode curNode = (YangNode) listener.getParsedDataStack().peek();
      try {
        curNode.addChild(enumerationNode);
      } catch (DataModelException e) {
        throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
            YangConstructType.ENUMERATION_DATA, "", ENTRY, e.getMessage()));
      }
    }
  }
}

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

" in " + leavesHolder.getFileName() + "\"");
YangNode potentialTypeNode = ((YangNode) leavesHolder).getChild();
while (potentialTypeNode != null) {
  String dataTypeName = null;
    dataTypeName = unionNode.getName();
  if (potentialTypeNode.getName().contentEquals(dataTypeName)) {
    dataType.setDataTypeExtendedInfo(potentialTypeNode);
    return;
  potentialTypeNode = potentialTypeNode.getNextSibling();

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

/**
 * Returns the node that matches with the name of the node in path.
 *
 * @param nodeInUnique          node name in path
 * @param potentialReferredNode node under which it has to match
 * @return referred node
 */
private static YangNode getReferredNodeFromTheUniqueNodes(YangNodeIdentifier nodeInUnique, YangNode
    potentialReferredNode) {
  while (potentialReferredNode != null) {
    // Check if the potential referred node is the actual referred node
    if (potentialReferredNode.getName().equals(nodeInUnique.getName())) {
      return potentialReferredNode;
    }
    potentialReferredNode = potentialReferredNode.getNextSibling();
  }
  return null;
}

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

/**
 * Returns referred node in a given set.
 *
 * @param yangNodeSet YANG node set
 * @param refNodeName name of the node which is referred
 * @return referred node's reference
 */
public static YangNode findReferredNode(Set<YangNode> yangNodeSet, String refNodeName) {
  /*
   * Run through the YANG files to see which YANG file matches the
   * referred node name.
   */
  for (YangNode yangNode : yangNodeSet) {
    if (yangNode.getName().equals(refNodeName)) {
      return yangNode;
    }
  }
  return null;
}

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

/**
 * Returns the contained data model parent node.
 *
 * @param currentNode current node which parent contained node is required
 * @return parent node in which the current node is an attribute
 */
public static YangNode getParentNodeInGenCode(YangNode currentNode) {
  /*
   * TODO: recursive parent lookup to support choice/augment/uses. TODO:
   * need to check if this needs to be updated for
   * choice/case/augment/grouping
   */
  return currentNode.getParent();
}

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

/**
 * Resolved inter-jar dependencies.
 *
 * @param dependentSchema dependent schema list
 * @throws IOException when fails to do IO operations
 */
private void addSchemaToFileSet(List<YangNode> dependentSchema)
    throws IOException {
  if (dependentSchema == null || dependentSchema.isEmpty()) {
    return;
  }
  for (YangNode node : dependentSchema) {
    YangFileInfo dependentFileInfo = new YangFileInfo();
    node.setToTranslate(false);
    dependentFileInfo.setRootNode(node);
    dependentFileInfo.setForTranslator(false);
    dependentFileInfo.setYangFileName(node.getName());
    yangFileInfoSet.add(dependentFileInfo);
  }
}

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

private boolean isUsesPresentInList() {
  YangNode node = getChild();
  while (node != null) {
    if (node instanceof YangUses) {
      return true;
    }
    node = node.getNextSibling();
  }
  return false;
  // TODO When grouping linking is done this method has to be modified.
}

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

@Override
public void addToChildSchemaMap(YangSchemaNodeIdentifier id,
                YangSchemaNodeContextInfo context)
    throws DataModelException {
  getYsnContextInfoMap().put(id, context);
  YangSchemaNodeContextInfo contextInfo = new YangSchemaNodeContextInfo();
  contextInfo.setSchemaNode(context.getSchemaNode());
  contextInfo.setContextSwitchedNode(this);
  getParent().addToChildSchemaMap(id, contextInfo);
}

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

YangNode.cloneSubTree(referredGrouping, usesParentNode, this);
} catch (DataModelException e) {
  throw new DataModelException(e.getMessage());

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

throw new DataModelException("Node in data model tree does not " +
                     "support collision detection " +
                     newNode.getName() + " in " +
                     newNode.getLineNumber() + " at " +
                     newNode.getCharPosition() +
                     " in " + newNode.getFileName() + "\"");
Parsable parsable = (Parsable) newNode;
if (addAs == TraversalType.CHILD) {
  collisionDetector.detectCollidingChild(newNode.getName(),
                      parsable.getYangConstructType());
} else if (addAs == TraversalType.SIBILING) {
  currentNode = currentNode.getParent();
  if (!(currentNode instanceof CollisionDetector)) {
    throw new DataModelException("Node in data model tree does " +
                       "not support collision " +
                       "detection" + currentNode.getName() +
                       " in " + currentNode.getLineNumber() +
                       " at " + currentNode.getCharPosition() +
                       " in " + currentNode.getFileName() + "\"");
  collisionDetector.detectCollidingChild(newNode.getName(),
                      parsable.getYangConstructType());
} else {
  throw new DataModelException("Error tree cloning " +
                     currentNode.getName() + " in" +
                     " " + currentNode.getLineNumber() +
                     " at " + currentNode.getCharPosition() +
                     " in " + currentNode.getFileName() + "\"");

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

/**
   * Adds the union node to the parent holder.
   *
   * @param listener listener's object
   * @param unionNode union node which needs to be added to parent
   */
  private static void addChildToParentNode(TreeWalkListener listener, YangUnion unionNode) {
    if (!(listener.getParsedDataStack().peek() instanceof YangNode)) {
      throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, UNION_DATA,
          "", ENTRY));
    } else {
      YangNode curNode = (YangNode) listener.getParsedDataStack().peek();
      try {
        curNode.addChild(unionNode);
      } catch (DataModelException e) {
        throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
            UNION_DATA, "", ENTRY, e.getMessage()));
      }
    }
  }
}

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