gpt4 book ai didi

org.onosproject.yangutils.datamodel.YangType.getDataType()方法的使用及代码示例

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

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

YangType.getDataType介绍

[英]Returns the type of data.
[中]返回数据的类型。

代码示例

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

/**
 * Sets the default require instance value as true when the type is instance identifier.
 *
 * @param type type to which the value has to be set
 */
private static void setDefaultRequireInstanceForInstanceIdentifier(YangType<?> type) {
  if (type.getDataType() == YangDataTypes.INSTANCE_IDENTIFIER) {
    ((YangType<Boolean>) type).setDataTypeExtendedInfo(true);
  }
}

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

switch (dataType.getDataType()) {
  case DERIVED:
    return ((YangDerivedInfo) dataType.getDataTypeExtendedInfo())
        .getDataTypeExtendedInfo())
        .getEffectiveDataType();
    if (type.getDataType() == YangDataTypes.DERIVED) {
      return ((YangDerivedInfo) type.getDataTypeExtendedInfo())
          .getEffectiveBuiltInType().equals(EMPTY);
        .getEffectiveDataType().getDataType().equals(EMPTY);
        .getTypeList().contains(EMPTY);
  default:
    return dataType.getDataType().equals(EMPTY);

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

while (potentialTypeNode != null) {
  String dataTypeName = null;
  if (dataType.getDataType() == YangDataTypes.ENUMERATION) {
    YangEnumeration enumNode = (YangEnumeration) dataType.getDataTypeExtendedInfo();
    dataTypeName = enumNode.getName();
  } else if (dataType.getDataType() == YangDataTypes.UNION) {
    YangUnion unionNode = (YangUnion) dataType.getDataTypeExtendedInfo();
    dataTypeName = unionNode.getName();

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

if (currentListOfLeaves != null) {
  for (YangLeaf leaf : currentListOfLeaves) {
    if (leaf.getDataType().getDataType() == YangDataTypes.ENUMERATION
        || leaf.getDataType().getDataType() == YangDataTypes.UNION) {
      try {
        YangType<?> clonedType = leaf.getDataType().clone();
if (currentListOfLeafList != null) {
  for (YangLeafList leafList : currentListOfLeafList) {
    if (leafList.getDataType().getDataType() == YangDataTypes.ENUMERATION
        || leafList.getDataType().getDataType() == YangDataTypes.UNION) {
      try {
        YangType<?> clonedType = leafList.getDataType().clone();

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

/**
 * Returns resolvable entity under union. When types under union have
 * identity-ref, derived and union, the function call is done recursively
 * to get resolvable entity and adds it to list.
 *
 * @param type   union YANG type
 * @param isLeaf leaf or leaf-list
 * @return resolvable entity list after setting info
 * @throws DataModelException data model error
 */
private static List<YangEntityToResolveInfoImpl> getUnionResolvableEntity(
    YangType type, boolean isLeaf) throws DataModelException {
  YangUnion union = (YangUnion) type.getDataTypeExtendedInfo();
  List<YangType<?>> typeList = union.getTypeList();
  List<YangEntityToResolveInfoImpl> unionList = new ArrayList<>();
  List<YangEntityToResolveInfoImpl> entity;
  for (YangType unionType : typeList) {
    entity = getUnresolvedTypeList(unionType.getDataType(),
                    unionType, union, null, isLeaf);
    if (nonEmpty(entity)) {
      unionList.addAll(entity);
    }
  }
  return unionList;
}

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

/**
 * Returns types that has to be resolved for a single leaf/leaf-list.
 * Identifies the object to be leaf/leaf-list and assigns respective
 * parameters to resolve the types under leaf/leaf-list.
 *
 * @param clonedObj  leaf/leaf-list object
 * @param holderNode holder node
 * @param yangUses   YANG uses
 * @return list of resolvable entities in a leaf/leaf-list
 * @throws DataModelException data model error
 */
private static List<YangEntityToResolveInfoImpl> getTypesToBeResolved(
    Object clonedObj, YangNode holderNode,
    YangUses yangUses) throws DataModelException {
  YangType type;
  if (clonedObj instanceof YangLeaf) {
    YangLeaf clonedLeaf = (YangLeaf) clonedObj;
    type = clonedLeaf.getDataType();
    return getUnresolvedTypeList(type.getDataType(), type, holderNode,
                   yangUses, true);
  }
  YangLeafList clonedLeafList = (YangLeafList) clonedObj;
  type = clonedLeafList.getDataType();
  return getUnresolvedTypeList(type.getDataType(), type, holderNode,
                 yangUses, false);
}

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

switch (getDataType()) {
  case INT8:
  case INT16:
  case UINT64: {
    if (getDataTypeExtendedInfo() == null) {
      getDataObjectFromString(value, getDataType());
    } else {
      if (!((YangRangeRestriction) getDataTypeExtendedInfo()).isValidValueString(value)) {
        throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
                          getDataType());
        .isValidStringOnPatternRestriction(value))) {
      throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
                        getDataType());
    if (!(value.equals(DataModelUtils.TRUE) || value.equals(DataModelUtils.FALSE))) {
      throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
                        getDataType());
                        getDataType());
    if (bits.fromString(value) == null) {
      throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
                        getDataType());
    if (!isValidBinary(value, (YangRangeRestriction) getDataTypeExtendedInfo())) {
      throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
                        getDataType());

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

/**
 * Adds YANG type to type list.
 *
 * @param yangType YANG type to be added to list
 * @throws DataModelException union member type must not be one of the
 *                            built-in types "empty" or "leafref"
 */
public void addType(YangType<?> yangType)
    throws DataModelException {
  YangDataTypes type = yangType.getDataType();
  String msg = "Union member type must not be one of the built-in types" +
      " \"empty\" or \"leafref\"";
  switch (type) {
    case EMPTY:
    case LEAFREF:
      throw new DataModelException(getErrorMsg(
          msg, getName(), getLineNumber(), getCharPosition(),
          getFileName()));
    default:
      typeList.add(yangType);
  }
}

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

GeneratedYangParser.RangeStatementContext ctx) {
if (type.getDataType() == DERIVED) {
  ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
      .setRangeRestrictionString(ctx.range().getText());
if (!(isOfRangeRestrictedType(type.getDataType())) && (type.getDataType() != DECIMAL64)) {
  ParserException parserException = new ParserException("YANG file error: Range restriction can't be " +
                                 "applied to a given type");
  if (type.getDataType() == DECIMAL64) {
    YangDecimal64 yangDecimal64 = (YangDecimal64) type.getDataTypeExtendedInfo();
    rangeRestriction =
                    ctx.getStart().getCharPositionInLine(),
                    true, ctx.range().getText(),
                    type.getDataType(), listener.getFileName());
  } else {
    rangeRestriction =
                    false, ctx.range()
                        .getText(), type
                        .getDataType(),
                    listener.getFileName());
  if (type.getDataType() == DECIMAL64) {
    ((YangDecimal64<YangRangeRestriction>) type.getDataTypeExtendedInfo())
        .setRangeRestrictedExtendedInfo(rangeRestriction);

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

/**
   * Performs validation and updates the data model tree.
   * It is called when parser exits from grammar rule (range).
   *
   * @param listener listener's object
   * @param ctx      context object of the grammar rule
   */
  public static void processRangeRestrictionExit(TreeWalkListener listener,
                          GeneratedYangParser.RangeStatementContext ctx) {

    // Check for stack to be non empty.
    checkStackIsNotEmpty(listener, MISSING_HOLDER, RANGE_DATA, ctx.range().getText(), EXIT);

    Parsable tmpData = listener.getParsedDataStack().peek();
    if (tmpData instanceof YangRangeRestriction) {
      listener.getParsedDataStack().pop();
    } else if (tmpData instanceof YangType
        && ((YangType) tmpData).getDataType() == DERIVED) {
      // TODO : need to handle in linker
    } else {
      throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, RANGE_DATA,
                                  ctx.range().getText(), EXIT));
    }
  }
}

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

GeneratedYangParser.PatternStatementContext ctx) {
if (type.getDataType() != YangDataTypes.STRING && type.getDataType() != YangDataTypes.DERIVED) {
if (type.getDataType() == YangDataTypes.STRING) {
  YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
  if (stringRestriction == null) {

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

/**
   * Performs validation and updates the data model tree.
   * It is called when parser exits from grammar rule (length).
   *
   * @param listener listener's object
   * @param ctx      context object of the grammar rule
   */
  public static void processLengthRestrictionExit(TreeWalkListener listener,
                          GeneratedYangParser.LengthStatementContext ctx) {

    // Check for stack to be non empty.
    checkStackIsNotEmpty(listener, MISSING_HOLDER, LENGTH_DATA, ctx.length().getText(), EXIT);

    Parsable tmpData = listener.getParsedDataStack().peek();
    if (tmpData instanceof YangRangeRestriction) {
      listener.getParsedDataStack().pop();
    } else if (tmpData instanceof YangType
        && ((YangType) tmpData).getDataType() == DERIVED) {
      // TODO : need to handle in linker
    } else {
      throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LENGTH_DATA,
                                  ctx.length().getText(), EXIT));
    }
  }
}

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

@Override
public Object resolve()
    throws DataModelException {
  /*
   * Check whether the data type is derived.
   */
  if (getDataType() != DERIVED) {
    throw new DataModelException("Linker Error: Resolve should only be called for derived data types. "
                       + " in " +
                       getLineNumber() + " at " +
                       getCharPosition()
                       + " in " + getFileName() + "\"");
  }
  // Check if the derived info is present.
  YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo();
  if (derivedInfo == null) {
    throw new DataModelException("Linker Error: Derived information is missing. " + " in " +
                       getLineNumber() + " at " +
                       getCharPosition()
                       + " in " + getFileName() + "\"");
  }
  // Initiate the resolution
  try {
    setResolvableStatus(derivedInfo.resolve());
  } catch (DataModelException e) {
    throw new DataModelException(e.getMessage());
  }
  return null;
}

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

/**
 * Performs validation and updates the data model tree.
 * It is called when parser exits from grammar rule (pattern).
 *
 * @param listener listener's object
 * @param ctx      context object of the grammar rule
 */
public static void processPatternRestrictionExit(TreeWalkListener listener,
                         GeneratedYangParser.PatternStatementContext ctx) {
  // Check for stack to be non empty.
  checkStackIsNotEmpty(listener, MISSING_HOLDER, PATTERN_DATA, ctx.string().getText(), EXIT);
  Parsable tmpData = listener.getParsedDataStack().peek();
  if (tmpData instanceof YangStringRestriction) {
    listener.getParsedDataStack().pop();
  } else if (tmpData instanceof YangType
      && ((YangType) tmpData).getDataType() == DERIVED) {
    // TODO : need to handle in linker
  } else {
    throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, PATTERN_DATA,
                                ctx.string().getText(), EXIT));
  }
}

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

GeneratedYangParser.LengthStatementContext ctx) {
if (type.getDataType() == DERIVED) {
  ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
      .setLengthRestrictionString(ctx.length().getText());
if (type.getDataType() != STRING && type.getDataType() != BINARY) {
  ParserException parserException =
      new ParserException(
if (type.getDataType() == STRING) {
  YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
  if (stringRestriction == null) {

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

for (YangLeaf leaf : leaves) {
  if (key.equals(leaf.getName())) {
    if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) {
      throw new DataModelException(" A leaf that is part of the key must not be the built-in " +
          "type \"empty\"." +

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

YangType baseType = yangLeaf.getDataType();
if (baseType.getDataType() == LEAFREF) {
  YangLeafRef referredLeafRefInfo = (YangLeafRef) (yangLeaf.getDataType().getDataTypeExtendedInfo());
} else if (baseType.getDataType() == YangDataTypes.DERIVED) {
YangType baseType = yangLeafList.getDataType();
if (baseType.getDataType() == LEAFREF) {
  YangLeafRef referredLeafRefInfo = (YangLeafRef) yangLeafList.getDataType().getDataTypeExtendedInfo();
} else if (baseType.getDataType() == YangDataTypes.DERIVED) {

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

if (((YangType) curData).getDataType() == YangDataTypes.INSTANCE_IDENTIFIER) {

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

YangDataTypes type = baseType.getDataType();
T extended = (T) baseType.getDataTypeExtendedInfo();

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