gpt4 book ai didi

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

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

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

YangAugment介绍

[英]Representation of data model node to maintain information defined in YANG augment.
[中]表示数据模型节点,以维护YANG augment中定义的信息。

代码示例

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

@Override
public void setLeafNameSpaceAndAddToParentSchemaMap() {
  // Add namespace for all leafs.
  for (YangLeaf yangLeaf : getListOfLeaf()) {
    yangLeaf.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
  }
  // Add namespace for all leaf list.
  for (YangLeafList yangLeafList : getListOfLeafList()) {
    yangLeafList
        .setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
  }
}

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

@Override
public void detectSelfCollision(String identifierName,
                YangConstructType dataType)
    throws DataModelException {
  if (getName().equals(identifierName)) {
    throw new DataModelException(
        "YANG file error: Duplicate input identifier detected, " +
            "same as input \"" +
            getName() + " in " +
            getLineNumber() + " at " +
            getCharPosition() +
            " in " + getFileName() + "\"");
  }
}

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

@Override
public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
    YangSchemaNodeContextInfo ctxInfo) throws DataModelException {
  getYsnContextInfoMap().put(schemaNodeIdentifier, ctxInfo);
  YangSchemaNodeContextInfo ctxInfo1 = new YangSchemaNodeContextInfo();
  ctxInfo1.setSchemaNode(ctxInfo.getSchemaNode());
  ctxInfo1.setContextSwitchedNode(this);
  if (getAugmentedNode() != null) {
    if (getAugmentedNode() instanceof YangChoice) {
      ctxInfo1.setContextSwitchedNode(
          ctxInfo.getContextSwitchedNode());
    }
    getAugmentedNode().addToChildSchemaMap(schemaNodeIdentifier,
                        ctxInfo1);
  }
}

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

@Override
public void setNameSpaceAndAddToParentSchemaMap() {
  // Get parent namespace and set namespace for self node.
  YangNode parent = getParent();
  if (parent instanceof YangUses) {
    parent = parent.getParent();
  }
  setNameSpace(parent.getNameSpace());
  /*
   * Check if node contains leaf/leaf-list, if yes add namespace for leaf
   * and leaf list.
   */
  setLeafNameSpaceAndAddToParentSchemaMap();
}

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

YangNode child = augment.getChild();
List<YangNode> childNodes = new ArrayList<>();
List<YangNode> caseNodes = new ArrayList<>();
augment.setChild(null);
  augment.addChild(javaCase);
  node.setParent(javaCase);
  javaCase.addChild(node);
  augment.addChild(node);
  node.setParent(augment);
if (augment.getListOfLeaf() != null) {
  for (YangLeaf leaf : augment.getListOfLeaf()) {
    YangCase javaCase = getYangCaseNode(JAVA_GENERATION);
    javaCase.setName(leaf.getName());
    javaCase.addLeaf(leaf);
    augment.addChild(javaCase);
  augment.getListOfLeaf().clear();
if (augment.getListOfLeafList() != null) {
  for (YangLeafList leafList : augment.getListOfLeafList()) {
    YangCase javaCase = getYangCaseNode(JAVA_GENERATION);
    javaCase.setName(leafList.getName());
    javaCase.addLeafList(leafList);
    augment.addChild(javaCase);

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

private void resolveUsesAugment(T entity, YangNode node) {
  YangXpathLinker<T> linker = new YangXpathLinker<T>();
  YangAugment aug = (YangAugment) entity;
  YangNode tgt = linker.processUsesAugLinking(aug.getTargetNode(),
                        (YangUses) node);
  if (tgt != null) {
    if (tgt instanceof YangAugmentableNode) {
      //TODO: collision detection
      ((YangAugmentableNode) tgt).addAugmentation(aug);
      aug.setAugmentedNode(tgt);
      setAugmentedFlagInAncestors(tgt);
      Resolvable resolvable = (Resolvable) entity;
      resolvable.setResolvableStatus(RESOLVED);
      if (tgt instanceof YangInput) {
        linker.addInModuleIfInput(aug, node);
      }
    } else {
      throw new LinkerException(getErrorMsg(
          INVALID_TARGET + tgt.getNodeType(),
          aug.getName(), aug.getLineNumber(),
          aug.getCharPosition(), aug.getFileName()));
    }
  }
}

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

YangNode aChild = aug.getChild();
YangNode tChild = tgt.getChild();
List<YangLeaf> aL = aug.getListOfLeaf();
List<YangLeafList> aLl = aug.getListOfLeafList();

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

YangAugment augment) {
List<YangLeaf> logLeaves = logical.getListOfLeaf();
List<YangLeafList> logLl = logical.getListOfLeafList();
List<YangLeaf> augLeaves = augment.getListOfLeaf();
List<YangLeafList> augLl = augment.getListOfLeafList();

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

/**
 * Adds the resolved augment from the cloned uses.
 *
 * @param uses YANG uses
 * @param aug  cloned augment
 * @throws DataModelException data model error
 */
public static void addUnresolvedAugment(YangUses uses, YangAugment aug)
    throws DataModelException {
  if (uses.getCurrentGroupingDepth() == 0) {
    List<YangEntityToResolveInfoImpl> infoList = new LinkedList<>();
    YangEntityToResolveInfoImpl info =
        new YangEntityToResolveInfoImpl<>();
    aug.setResolvableStatus(UNRESOLVED);
    info.setEntityToResolve(aug);
    info = setInformationInEntity(info, aug.getParent(),
                   aug.getCharPosition(),
                   aug.getLineNumber());
    infoList.add(info);
    uses.addEntityToResolve(infoList);
  }
}

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

try {
  YangAugment augment = (YangAugment) info.clone(
      null, false, true);
  augment.setParent(info.getParent());
  augment.setAugmentedNode(clonedNode);

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

YangAugment augment,
                   YangNode lastChild) {
YangNode augChild = augment.getChild();
while (augChild != null) {
  if (lastChild == logical) {
          constructExtendedListenerErrorMessage(
              UNHANDLED_PARSED_DATA, AUGMENT_DATA,
              augment.getName(), ENTRY, e.getMessage()));

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

/**
 * Checks for the augment name name collision. If there are augments with
 * the same name present, then the new augment will be set with a logical
 * node.
 *
 * @param root augment parent node
 * @param aug  YANG augment node
 */
public static void checkAugNameCollision(YangNode root, YangAugment aug) {
  YangNode child = root.getChild();
  while (child != null) {
    if (child instanceof YangAugment) {
      if (child.getName().equals(aug.getName())) {
        aug.setLogicalNode((YangAugment) child);
      }
    }
    child = child.getNextSibling();
  }
}

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

/**
 * Checks if the augment node is a duplicate node. If the augment is
 * duplicate, then it adds all its children to the logical node.
 *
 * @param augment YANG augment
 * @return true if it is a duplicate node; false otherwise
 */
public static boolean isDuplicateNode(YangAugment augment) {
  YangAugment logical = augment.getLogicalNode();
  if (logical == null) {
    return false;
  }
  YangNode lastChild = logical;
  YangNode child = logical.getChild();
  while (child != null) {
    lastChild = child;
    child = child.getNextSibling();
  }
  addChildToLogicalNode(logical, augment, lastChild);
  addLeafAndLeafList(logical, augment);
  return true;
}

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

YangNode node = augment.getAugmentedNode();
for (YangAtomicPath atomicPath : augment.getTargetNode()) {
  if (atomicPath.getNodeIdentifier().getPrefix() != null &&
      !atomicPath.getNodeIdentifier().getPrefix().equals(EMPTY_STRING)) {

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

/**
 * Returns the parent data node schema context for given yang node.
 *
 * @param node yang node
 * @return yang node
 */
public static YangNode getParentSchemaContext(YangNode node) {
  while (!(node instanceof SchemaDataNode) && node != null) {
    if (node.getYangSchemaNodeType() == YANG_AUGMENT_NODE) {
      node = ((YangAugment) node).getAugmentedNode();
      continue;
    }
    node = node.getParent();
  }
  return node;
}

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

/**
 * Performs validations and update the data model tree when parser exits
 * from grammar rule (augment).
 *
 * @param listener listener's object
 * @param ctx      context object of the grammar rule
 */
public static void processAugmentExit(TreeWalkListener listener,
                   AugmentStatementContext ctx) {
  //Check for stack to be non empty.
  checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA,
             ctx.augment().getText(), EXIT);
  if (!(listener.getParsedDataStack().peek() instanceof YangAugment)) {
    throw new ParserException(constructListenerErrorMessage(
        MISSING_CURRENT_HOLDER, AUGMENT_DATA,
        ctx.augment().getText(), EXIT));
  }
  YangAugment augment = (YangAugment) listener.getParsedDataStack().pop();
  boolean isDup = isDuplicateNode(augment);
  if (isDup) {
    removeAugment(augment);
  } else {
    Token txt = ctx.getStart();
    YangResolutionInfoImpl<YangAugment> info =
        new YangResolutionInfoImpl<>(augment, augment.getParent(),
                       txt.getLine(),
                       txt.getCharPositionInLine());
    addToResolution(info, ctx);
  }
}

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

YangAugment augment = (YangAugment) entityToResolve;
targetNode = xPathLinker
    .processXpathLinking(augment.getTargetNode(), (YangNode)
        root, AUGMENT_LINKING);
if (targetNode != null) {
                 (YangNode) root);
    ((YangAugmentableNode) targetNode).addAugmentation(augment);
    augment.setAugmentedNode(targetNode);
    setAugmentedFlagInAncestors(targetNode);
    Resolvable resolvable = (Resolvable) entityToResolve;
    throw new LinkerException(getErrorMsg(
        INVALID_TARGET + targetNode.getNodeType(),
        augment.getName(), augment.getLineNumber(),
        augment.getCharPosition(), augment.getFileName()));
      FAILED_TO_LINK, augment.getName(), augment
          .getLineNumber(), augment.getCharPosition(),
      augment.getFileName()));

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

@Override
public void setLeafParentContext() {
  // Add parent context for all leafs.
  for (YangLeaf yangLeaf : getListOfLeaf()) {
    yangLeaf.setParentContext(getParentSchemaContext(this));
  }
  // Add parent context for all leaf list.
  for (YangLeafList yangLeafList : getListOfLeafList()) {
    yangLeafList.setParentContext(getParentSchemaContext(this));
  }
}

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

if (curParent instanceof YangAugment) {
  YangAugment augment = (YangAugment) curParent;
  curParent = augment.getAugmentedNode();
  curCount = curCount + 1;

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