gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-19 10:49:31 27 4
gpt4 key购买 nike

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

YangEntityToResolveInfoImpl介绍

[英]Represents implementation of information about entity being resolved.
[中]表示有关正在解析的实体的信息的实现。

代码示例

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

private void addEntityToStack(T entity, YangNode holder) {
  YangEntityToResolveInfoImpl<T> unResolvedEntityInfo =
      new YangEntityToResolveInfoImpl<>();
  unResolvedEntityInfo.setEntityToResolve(entity);
  unResolvedEntityInfo.setHolderOfEntityToResolve(holder);
  addInPartialResolvedStack(unResolvedEntityInfo);
}

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

/**
 * Adds the unresolved entities to the resolution list.
 *
 * @param entityToResolve entity to resolve
 * @throws DataModelException a violation of data model rules
 */
private void addUnresolvedEntitiesToResolutionList(T entityToResolve)
    throws DataModelException {
  if (entityToResolve instanceof YangEntityToResolveInfoImpl) {
    YangEntityToResolveInfoImpl entityToResolveInfo
        = (YangEntityToResolveInfoImpl) entityToResolve;
    if (entityToResolveInfo.getEntityToResolve() instanceof YangLeafRef) {
      YangLeafRef leafref = (YangLeafRef) entityToResolveInfo
          .getEntityToResolve();
      YangNode parentNodeOfLeafref = entityToResolveInfo
          .getHolderOfEntityToResolve();
      leafref.setParentNode(parentNodeOfLeafref);
      if (leafref.getResolvableStatus() == UNRESOLVED) {
        leafref.setResolvableStatus(INTRA_FILE_RESOLVED);
      }
    }
    // Add resolution information to the list.
    YangResolutionInfoImpl resolutionInfoImpl = new YangResolutionInfoImpl<>(
        entityToResolveInfo.getEntityToResolve(),
        entityToResolveInfo.getHolderOfEntityToResolve(),
        entityToResolveInfo.getLineNumber(),
        entityToResolveInfo.getCharPosition());
    addResolutionInfo(resolutionInfoImpl);
  }
}

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

/**
 * Sets the information needed for adding the entity into resolution
 * list, such as line number, position number and cloned holder node.
 *
 * @param entity  resolvable entity
 * @param holder  cloned holder node
 * @param charPos character position
 * @param lineNum line number
 * @return resolvable entity after setting info
 */
private static YangEntityToResolveInfoImpl<?> setInformationInEntity(
    YangEntityToResolveInfoImpl<?> entity, YangNode holder,
    int charPos, int lineNum) {
  entity.setHolderOfEntityToResolve(holder);
  entity.setCharPosition(charPos);
  entity.setLineNumber(lineNum);
  return entity;
}

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

/**
 * Returns the derived info if the holder is typedef, the entity is type
 * and the effective type is leaf-ref; null otherwise.
 *
 * @return derived info
 */
private YangDerivedInfo<?> getValidResolvableType() {
  YangNode refNode = entityToResolveInfo.getHolderOfEntityToResolve();
  T entity = entityToResolveInfo.getEntityToResolve();
  if (!(refNode instanceof YangTypeDef) && entity instanceof YangType) {
    YangType<?> type = (YangType) entity;
    YangDerivedInfo<?> info =
        (YangDerivedInfo) type.getDataTypeExtendedInfo();
    YangDataTypes dataType = info.getEffectiveBuiltInType();
    if ((type.getResolvableStatus() == RESOLVED) &&
        (dataType == YangDataTypes.LEAFREF)) {
      return info;
    }
  }
  return null;
}

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

/**
 * Retrieves the next entity in the stack that needs to be resolved. It is
 * assumed that the caller ensures that the stack is not empty.
 *
 * @return next entity in the stack that needs to be resolved
 */
private T getCurEntityToResolveFromStack() {
  return partialResolvedStack.peek().getEntityToResolve();
}

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

.getHolderOfEntityToResolve();

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

/**
 * Returns resolvable entity when the type is derived. It sets needed
 * information to entity such as line number,position number and holder.
 * Returns null when identity is for inter grouping.
 *
 * @param type   derived YANG type
 * @param holder holder node
 * @param isLeaf leaf or leaf-list
 * @return entity to resolve for derived type
 */
private static YangEntityToResolveInfoImpl getDerivedResolvableEntity(
    YangType<?> type, YangNode holder, boolean isLeaf) {
  YangEntityToResolveInfoImpl<YangType<?>> derivedInfo =
      new YangEntityToResolveInfoImpl<>();
  if (type.isTypeForInterFileGroupingResolution()) {
    return null;
  }
  if (!isLeaf && type.isTypeNotResolvedTillRootNode()) {
    return null;
  }
  derivedInfo.setEntityToResolve(type);
  return setInformationInEntity(
      derivedInfo, holder, type.getCharPosition(),
      type.getLineNumber());
}

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

/**
 * Adds leaf-ref to the resolution list, with different context if
 * leaf-ref is defined under derived type. Leaf-ref must be resolved from
 * where the typedef is referenced.
 */
private void addDerivedRefTypeToRefTypeResolutionList()
    throws DataModelException {
  YangNode refNode = entityToResolveInfo.getHolderOfEntityToResolve();
  YangDerivedInfo info = getValidResolvableType();
  if (info == null) {
    return;
  }
  YangType<T> type =
      (YangType<T>) entityToResolveInfo.getEntityToResolve();
  T extType = (T) info.getReferredTypeDef().getTypeDefBaseType()
      .getDataTypeExtendedInfo();
  while (extType instanceof YangDerivedInfo) {
    info = (YangDerivedInfo) extType;
    extType = (T) info.getReferredTypeDef().getTypeDefBaseType()
        .getDataTypeExtendedInfo();
  }
  /*
   * Backup the leaf-ref info from derived type and deletes the derived
   * type info. Copies the backed up leaf-ref data to the actual type in
   * replacement of derived type. Adds to the resolution list in this
   * context.
   */
  addRefTypeInfo(extType, type, refNode);
}

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

@Override
public void resolveLinkingForResolutionInfo(YangReferenceResolver dataModelRootNode)
    throws DataModelException {
  curRefResolver = dataModelRootNode;
/*
   * Current node to resolve, it can be a YANG type, YANG uses or YANG if-feature or
   * YANG leafref or YANG base or YANG identityref.
   */
  T entityToResolve = entityToResolveInfo.getEntityToResolve();
  // Check if linking is already done
  if (entityToResolve instanceof Resolvable) {
    Resolvable resolvable = (Resolvable) entityToResolve;
    if (resolvable.getResolvableStatus() == RESOLVED) {
      /*
       * entity is already resolved, so nothing to do
       */
      return;
    }
  } else {
    throw new DataModelException(LINKER_ERROR);
  }
  // Push the initial entity to resolve in stack.
  addInPartialResolvedStack(entityToResolveInfo);
  linkAndResolvePartialResolvedStack();
  addDerivedRefTypeToRefTypeResolutionList();
}

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

YangNode node = entityToResolveInfo.getHolderOfEntityToResolve();
if (entityToResolve instanceof YangAugment &&
    !(node instanceof YangUses)) {
      leafRef.setResolvableStatus(INTER_FILE_LINKED);
      addUnResolvedLeafRefTypeToStack((T) leaf, entityToResolveInfo
          .getHolderOfEntityToResolve());
    } else {
      leafList = (YangLeafList) target;
      leafRef.setResolvableStatus(INTER_FILE_LINKED);
      addUnResolvedLeafRefTypeToStack(
          (T) leafList, entityToResolveInfo.getHolderOfEntityToResolve());

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

private void addUnResolvedTypeDataToStack(YangType refType, YangNode
    ancestorRefNode, T extendedInfo) {
  YangEntityToResolveInfoImpl<YangLeafRef<?>> unResolvedLeafRef =
      new YangEntityToResolveInfoImpl<>();
  YangEntityToResolveInfoImpl<YangType<?>> unResolvedTypeDef =
      new YangEntityToResolveInfoImpl<>();
  if (refType.getDataType() == YangDataTypes.LEAFREF) {
    unResolvedLeafRef.setEntityToResolve((YangLeafRef<?>) extendedInfo);
    unResolvedLeafRef.setHolderOfEntityToResolve(ancestorRefNode);
    addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedLeafRef);
  } else if (refType.getDataType() == YangDataTypes.DERIVED) {
    unResolvedTypeDef.setEntityToResolve(refType);
    unResolvedTypeDef.setHolderOfEntityToResolve(ancestorRefNode);
    addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedTypeDef);
  }
}

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

/**
 * Returns resolvable entity when the type is leaf-ref. It changes the
 * prefixes from grouping to uses, then changes the parent node to the
 * cloned node, sets needed information to entity such as line number,
 * position number and holder.
 *
 * @param type     YANG type of leaf-ref
 * @param yangUses YANG uses
 * @param holder   cloned holder
 * @return entity to resolve for leaf-ref
 * @throws DataModelException data model error
 */
private static YangEntityToResolveInfoImpl getLeafRefResolvableEntity(
    YangType type, YangUses yangUses, YangNode holder)
    throws DataModelException {
  YangEntityToResolveInfoImpl<YangLeafRef> leafRefInfo =
      new YangEntityToResolveInfoImpl<>();
  YangLeafRef leafRef = (YangLeafRef) type.getDataTypeExtendedInfo();
  // Conversion of prefixes in absolute path while cloning them.
  convertThePrefixesDuringChange(leafRef, yangUses);
  leafRef.setParentNode(holder);
  leafRefInfo.setEntityToResolve(leafRef);
  return setInformationInEntity(
      leafRefInfo, holder, leafRef.getCharPosition(),
      leafRef.getLineNumber());
}

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

@Override
public void linkInterFile(YangReferenceResolver dataModelRootNode)
    throws DataModelException {
  curRefResolver = dataModelRootNode;
  // Current node to resolve, it can be a YANG type or YANG uses.
  T entityToResolve = entityToResolveInfo.getEntityToResolve();
  // Check if linking is already done
  if (entityToResolve instanceof Resolvable) {
    Resolvable resolvable = (Resolvable) entityToResolve;
    if (resolvable.getResolvableStatus() == RESOLVED) {
      return;
    }
  } else {
    throw new DataModelException(UNRESOLVABLE);
  }
  if (entityToResolve instanceof YangXPathResolver &&
      !(entityToResolve instanceof YangLeafRef)) {
    //Process x-path linking.
    processXPathLinking(entityToResolve, dataModelRootNode);
  } else {
    // Push the initial entity to resolve in stack.
    addInPartialResolvedStack(entityToResolveInfo);
    // Inter file linking and resolution.
    linkInterFileAndResolve();
    addDerivedRefTypeToRefTypeResolutionList();
  }
}

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

/**
 * Creates a resolution information object with all the inputs.
 *
 * @param dataNode           current parsable data node
 * @param holderNode         parent YANG node
 * @param lineNumber         error line number
 * @param charPositionInLine error character position in line
 */
public YangResolutionInfoImpl(T dataNode, YangNode holderNode, int lineNumber,
               int charPositionInLine) {
  entityToResolveInfo = new YangEntityToResolveInfoImpl<>();
  entityToResolveInfo.setEntityToResolve(dataNode);
  entityToResolveInfo.setHolderOfEntityToResolve(holderNode);
  setLineNumber(lineNumber);
  setCharPosition(charPositionInLine);
  partialResolvedStack = new Stack<>();
}

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