本文整理了Java中org.onosproject.yang.compiler.datamodel.YangType.getDataTypeExtendedInfo()
方法的一些代码示例,展示了YangType.getDataTypeExtendedInfo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangType.getDataTypeExtendedInfo()
方法的具体详情如下:
包路径:org.onosproject.yang.compiler.datamodel.YangType
类名称:YangType
方法名:getDataTypeExtendedInfo
[英]Returns the data type meta data.
[中]返回元数据的数据类型。
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
/**
* Returns the object for given data type with respective value.
*
* @param type data type of value
* @param leafValue value
* @return object of data type containing the value
*/
private static Object parseUnionTypeInfo(YangType type, String leafValue) {
Iterator<YangType<?>> it = ((YangUnion) type.getDataTypeExtendedInfo())
.getTypeList().listIterator();
while (it.hasNext()) {
YangType t = it.next();
try {
return getObject(t, leafValue, t.getDataType());
} catch (IllegalArgumentException e) {
continue;
}
}
throw new IllegalArgumentException("Invalid value of data: " + leafValue);
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
private static YangNamespace getUnionValNamespace(YangType type,
String leafValue) {
Iterator<YangType<?>> it = ((YangUnion) type.getDataTypeExtendedInfo())
.getTypeList().listIterator();
while (it.hasNext()) {
YangType t = it.next();
try {
getObject(t, leafValue, t.getDataType());
return getValueNamespace(t, leafValue, t.getDataType());
} catch (IllegalArgumentException e) {
continue;
}
}
throw new IllegalArgumentException("Invalid value of data: " + leafValue);
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
/**
* Returns the leaf type for given data type with respective value.
*
* @param type data type of value
* @param leafValue value
* @return leaf type of data type containing the value
*/
private static LeafType parseUnionLeafType(YangType type, String
leafValue) {
Iterator<YangType<?>> it = ((YangUnion) type.getDataTypeExtendedInfo())
.getTypeList().listIterator();
while (it.hasNext()) {
YangType t = it.next();
try {
getObject(t, leafValue, t.getDataType());
return getLeafType(t, leafValue, t.getDataType());
} catch (IllegalArgumentException e) {
continue;
}
}
throw new IllegalArgumentException("Invalid value of data");
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-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-compiler-linker
/**
* Adds the unresolved constructs to stack which has to be resolved for leafref.
*
* @param leavesInfo YANG leaf or leaf list which holds the type
* @param ancestorRefNode holder of the YANG leaf or leaf list
*/
private void addUnResolvedLeafRefTypeToStack(T leavesInfo, YangNode ancestorRefNode) {
YangType refType;
T extendedInfo;
if (leavesInfo instanceof YangLeaf) {
YangLeaf leaf = (YangLeaf) leavesInfo;
refType = leaf.getDataType();
} else {
YangLeafList leafList = (YangLeafList) leavesInfo;
refType = leafList.getDataType();
}
extendedInfo = (T) refType.getDataTypeExtendedInfo();
addUnResolvedTypeDataToStack(refType, ancestorRefNode, extendedInfo);
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
case DERIVED:
return getLeafTypeByDataType(type, ((YangDerivedInfo) type
.getDataTypeExtendedInfo()).getEffectiveBuiltInType());
case LEAFREF:
return getLeafTypeByDataType(type, ((YangLeafRef) type
.getDataTypeExtendedInfo()).getEffectiveDataType()
.getDataType());
case INSTANCE_IDENTIFIER:
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
/**
* Validates the requested data-type resolve type in empty or not.
*
* @param dataType the data type
* @return true, for empty resolved data-type; false otherwise
* @deprecated use LeafContextUtil.getLeafType instead
*/
@Deprecated
public static boolean validateEmptyDataType(YangType dataType) {
switch (dataType.getDataType()) {
case DERIVED:
return ((YangDerivedInfo) dataType.getDataTypeExtendedInfo())
.getEffectiveBuiltInType().equals(EMPTY);
case LEAFREF:
YangType type = ((YangLeafRef) dataType
.getDataTypeExtendedInfo())
.getEffectiveDataType();
if (type.getDataType() == DERIVED) {
return ((YangDerivedInfo) type.getDataTypeExtendedInfo())
.getEffectiveBuiltInType().equals(EMPTY);
}
return ((YangLeafRef) dataType.getDataTypeExtendedInfo())
.getEffectiveDataType().getDataType().equals(EMPTY);
case UNION:
return false;
default:
return dataType.getDataType().equals(EMPTY);
}
}
代码示例来源: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
/**
* 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-datamodel
case IDENTITYREF:
YangIdentity refId = ((YangIdentityRef) typeInfo
.getDataTypeExtendedInfo()).getReferredIdentity();
return getReferIdNamespace(refId, v);
case LEAFREF:
YangType refType = ((YangLeafRef) typeInfo
.getDataTypeExtendedInfo()).getEffectiveDataType();
return getValueNamespace(refType, v, refType.getDataType());
case DERIVED:
.getDataTypeExtendedInfo()).getReferredTypeDef()
.getTypeList().get(0);
return getValueNamespace(rt, v, rt.getDataType());
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Performs validation and updates the data model tree.
* It is called when parser exits from grammar rule (decimal64).
*
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processDecimal64Exit(TreeWalkListener listener,
Decimal64SpecificationContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, DECIMAL64_DATA, "", EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
if (tmpNode instanceof YangType) {
YangType<YangDecimal64<YangRangeRestriction>> typeNode =
(YangType<YangDecimal64<YangRangeRestriction>>) tmpNode;
YangDecimal64<YangRangeRestriction> decimal64Node = typeNode.getDataTypeExtendedInfo();
try {
decimal64Node.validateRange();
} catch (DataModelException e) {
throw new ParserException(e);
}
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, DECIMAL64_DATA, "", EXIT));
}
}
}
代码示例来源: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-parser
/**
* It is called when parser enters grammar rule (fraction-digits), it perform
* validations and updates the data model tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processFractionDigitsEntry(TreeWalkListener listener,
FractionDigitStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, FRACTION_DIGITS_DATA,
ctx.fraction().getText(), ENTRY);
int value = getValidFractionDigits(ctx);
Parsable tmpNode = listener.getParsedDataStack().peek();
if (tmpNode instanceof YangType) {
YangType<YangDecimal64<YangRangeRestriction>> typeNode =
(YangType<YangDecimal64<YangRangeRestriction>>) tmpNode;
YangDecimal64 decimal64Node = typeNode.getDataTypeExtendedInfo();
decimal64Node.setFractionDigit(value);
if (!decimal64Node.isValidFractionDigit()) {
throw new ParserException(constructErrorMsg(ctx, INVALID_CONTENT));
}
} else {
throw new ParserException(constructErrorMsg(ctx, INVALID_HOLDER));
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
String dataTypeName = null;
if (dataType.getDataType() == ENUMERATION) {
YangEnumeration enumNode = (YangEnumeration) dataType.getDataTypeExtendedInfo();
dataTypeName = enumNode.getName();
} else if (dataType.getDataType() == UNION) {
YangUnion unionNode = (YangUnion) dataType.getDataTypeExtendedInfo();
dataTypeName = unionNode.getName();
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Returns referred typedef/grouping node.
*
* @return referred typedef/grouping node
* @throws DataModelException a violation in data model rule
*/
private T getRefNode() throws DataModelException {
T entity = getCurEntityToResolveFromStack();
if (entity instanceof YangType) {
YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>)
((YangType<?>) entity).getDataTypeExtendedInfo();
return (T) derivedInfo.getReferredTypeDef();
}
if (entity instanceof YangUses) {
return (T) ((YangUses) entity).getRefGroup();
}
if (entity instanceof YangIfFeature) {
return (T) ((YangIfFeature) entity).getReferredFeatureHolder();
}
if (entity instanceof YangLeafRef) {
return (T) ((YangLeafRef) entity).getReferredLeafOrLeafList();
}
if (entity instanceof YangBase) {
return (T) ((YangBase) entity).getReferredIdentity();
}
if (entity instanceof YangIdentityRef) {
return (T) ((YangIdentityRef) entity).getReferredIdentity();
}
throw new DataModelException(LINKER_ERROR);
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
.getDataTypeExtendedInfo();
info.setRangeRes(ranRes);
info.setFileName(lis.getFileName());
if (dataType == DECIMAL64) {
YangDecimal64 deci64 = (YangDecimal64) type
.getDataTypeExtendedInfo();
ranRes = processRangeRestriction(
deci64.getDefaultRangeRestriction(), line, pos, true,
if (dataType == DECIMAL64) {
((YangDecimal64<YangRangeRestriction>) type
.getDataTypeExtendedInfo())
.setRangeRestrictedExtendedInfo(ranRes);
} else {
代码示例来源:origin: org.onosproject/onos-yang-compiler-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-compiler-linker
YangDerivedInfo<?> derivedInfo =
(YangDerivedInfo<?>) ((YangType<?>) entity)
.getDataTypeExtendedInfo();
derivedInfo.setReferredTypeDef((YangTypeDef) refNode);
} else if (entity instanceof YangUses) {
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
.getDataTypeExtendedInfo();
if (strRes == null) {
strRes = new YangStringRestriction();
} else {
YangDerivedInfo<?> info = (YangDerivedInfo<?>) type
.getDataTypeExtendedInfo();
info.addPatternRes(patRes);
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
.getDataTypeExtendedInfo();
info.setLengthRes(lenRes);
info.setFileName(lis.getFileName());
.getDataTypeExtendedInfo();
if (strRes == null) {
strRes = new YangStringRestriction();
内容来源于网络,如有侵权,请联系作者删除!