gpt4 book ai didi

org.onosproject.yang.compiler.datamodel.YangNode.getName()方法的使用及代码示例

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

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

YangNode.getName介绍

暂无

代码示例

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

/**
 * Sets parent context of data node.
 */
public void setParentContext() {
  if (this instanceof SchemaDataNode) {
    SchemaContext t = getParentSchemaContext(this.getParent());
    if (t != null) {
      parentContext = t;
    }
    // As rpc and anydata node is not leaf holder
    if (nodeType != RPC_NODE && nodeType != ANYDATA_NODE) {
      ((YangLeavesHolder) this).setLeafParentContext();
    }
    // setting the schema Id
    schemaId = new SchemaId(getName(), getNameSpace()
        .getModuleNamespace());
  } else if (this instanceof YangCase || this instanceof YangAugment) {
    ((YangLeavesHolder) this).setLeafParentContext();
  }
}

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

/**
 * Detects node collision of augment children nodes, leaves and leaf-lists
 * with target node's children nodes.
 *
 * @param aug YANG augment's child
 * @param tgt target node's child
 * @param aL  augment leaves
 * @param aLl augment leaf lists
 */
private static void detectNodeCollision(YangNode aug, YangNode tgt,
                    List<YangLeaf> aL,
                    List<YangLeafList> aLl) {
  while (tgt != null) {
    detectCollision(tgt.getName(), aug.getName(), aug, TARGET_NODE);
    detectLeafCollision(tgt.getName(), tgt, aL);
    detectLeafListCollision(tgt.getName(), tgt, aLl);
    tgt = tgt.getNextSibling();
  }
}

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

@Override
public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier)
    throws DataModelException {
  YangSchemaNodeContextInfo childSchemaContext =
      ysnContextInfoMap.get(dataNodeIdentifier);
  if (childSchemaContext == null) {
    throw new DataModelException("Requested " +
                       dataNodeIdentifier.getName() +
                       " is not child in " +
                       getName());
  }
  return childSchemaContext;
}

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

/**
 * Returns YANG module id for a given YANG module node.
 *
 * @param module YANG module
 * @return YANG module id for a given YANG module node
 */
public static YangModuleId processModuleId(YangNode module) {
  String rev = getDateInStringFormat(module);
  return new DefaultYangModuleId(module.getName(), rev);
}

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

/**
 * Returns the node from the parent node by matching it with the atomic
 * name. If no child node matches the name then it returns null.
 *
 * @param curNode    current node
 * @param identifier atomic name
 * @return node to be traversed
 */
private static YangNode getNode(YangNode curNode,
                YangNodeIdentifier identifier) {
  YangNode node = curNode;
  while (node != null) {
    if (node.getName().equals(identifier.getName())) {
      return node;
    }
    node = node.getNextSibling();
  }
  return null;
}

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

/**
 * Searches augment node in root node by name of the augment. For intra
 * file augment, target augment name without prefix is taken and checked.
 *
 * @param root    root node
 * @param augName current augment name
 * @return target augment node
 */
private YangNode searchAugmentNode(YangNode root, String augName) {
  YangNode node = root;
  node = node.getChild();
  while (node != null) {
    if (node instanceof YangAugment) {
      String name = ((YangAugment) node).getPrefixRemovedName();
      if (node.getName().equals(augName) || name.equals(augName)) {
        return node;
      }
    }
    node = node.getNextSibling();
  }
  return null;
}

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

/**
 * Checks if the current reference node name and the name in the base/identityref base are equal.
 *
 * @param curRefNode the node where the reference is pointed
 * @param name       name of the base in the base/identityref base
 * @return status of the match between the name
 * @throws DataModelException a violation of data model rules
 */
private boolean isReferredNodeForIdentity(YangNode curRefNode, String name)
    throws DataModelException {
  T entity = getCurEntityToResolveFromStack();
  if (entity instanceof YangIdentityRef || entity instanceof YangBase) {
    //Check if name of node name matches with the current reference node.
    return curRefNode.getName().contentEquals(name);
  } else {
    throw new DataModelException(getErrorMsg(
        INVALID_ENTITY, curRefNode.getName(), curRefNode.getLineNumber(),
        curRefNode.getCharPosition(), curRefNode.getFileName()));
  }
}

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

/**
 * Finds the referred grouping node at the root level of imported/included node.
 *
 * @param refNode module/sub-module node
 * @return referred grouping
 */
private YangNode findRefGrouping(YangNode refNode) {
  YangNode tmpNode = refNode.getChild();
  while (tmpNode != null) {
    if (tmpNode instanceof YangGrouping) {
      if (tmpNode.getName()
          .equals(((YangUses) getCurEntityToResolveFromStack())
                  .getName())) {
        return tmpNode;
      }
    }
    tmpNode = tmpNode.getNextSibling();
  }
  return null;
}

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

/**
 * Finds the referred typedef node at the root level of imported/included node.
 *
 * @param refNode module/sub-module node
 * @return referred typedef
 */
private YangNode findRefTypedef(YangNode refNode) {
  YangNode tmpNode = refNode.getChild();
  while (tmpNode != null) {
    if (tmpNode instanceof YangTypeDef) {
      if (tmpNode.getName()
          .equals(((YangType) getCurEntityToResolveFromStack())
                  .getDataTypeName())) {
        return tmpNode;
      }
    }
    tmpNode = tmpNode.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;
  }
}

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

/**
 * Resolved inter-jar dependencies.
 *
 * @param dependentSchema dependent schema list
 */
private void addSchemaToFileSet(Set<YangNode> dependentSchema) {
  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());
    dependentFileInfo.setInterJar(true);
    yangFileInfoSet.add(dependentFileInfo);
  }
}

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

/**
 * Finds the referred identity node at the root level of imported/included node.
 *
 * @param refNode module/sub-module node
 * @return referred identity
 */
private YangNode findRefIdentity(YangNode refNode) {
  YangNode tmpNode = refNode.getChild();
  while (tmpNode != null) {
    if (tmpNode instanceof YangIdentity) {
      if (tmpNode.getName()
          .equals(((YangBase) getCurEntityToResolveFromStack())
                  .getBaseIdentifier().getName())) {
        return tmpNode;
      }
    }
    tmpNode = tmpNode.getNextSibling();
  }
  return null;
}

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

/**
 * Finds the referred identity node at the root level of imported/included node.
 *
 * @param refNode module/sub-module node
 * @return referred identity
 */
private YangNode findRefIdentityRef(YangNode refNode) {
  YangNode tmpNode = refNode.getChild();
  while (tmpNode != null) {
    if (tmpNode instanceof YangIdentity) {
      if (tmpNode.getName()
          .equals(((YangIdentityRef) getCurEntityToResolveFromStack())
                  .getBaseIdentity().getName())) {
        return tmpNode;
      }
    }
    tmpNode = tmpNode.getNextSibling();
  }
  return null;
}

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

/**
 * Resolves sub-module linking by linking sub module with parent module.
 *
 * @param yangNodeSet set of YANG files info
 * @throws LinkerException fails to link sub-module to parent module
 */
public void linkSubModulesToParentModule(Set<YangNode> yangNodeSet)
    throws LinkerException {
  for (YangNode yangNode : yangNodeSet) {
    if (yangNode instanceof YangSubModule) {
      try {
        ((YangSubModule) yangNode).linkWithModule(getYangNodeSet());
      } catch (DataModelException e) {
        String errorInfo = "Error in file: " + yangNode.getName() + " in " +
            yangNode.getFileName() + " at " +
            "line: " + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
            + e.getLocalizedMessage();
        throw new LinkerException(errorInfo, e);
        // TODO add file path in exception message in util manager.
      }
    }
  }
}

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