本文整理了Java中org.onosproject.yang.compiler.datamodel.YangDerivedInfo
类的一些代码示例,展示了YangDerivedInfo
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangDerivedInfo
类的具体详情如下:
包路径:org.onosproject.yang.compiler.datamodel.YangDerivedInfo
类名称:YangDerivedInfo
[英]Represents the derived information.
[中]表示派生的信息。
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
addPatternRes(pattern);
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
throwError();
if (getReferredTypeDef().getTypeDefBaseType()
.getResolvableStatus() == INTRA_FILE_RESOLVED) {
return INTRA_FILE_RESOLVED;
.getDataTypeExtendedInfo()).getEffectiveBuiltInType();
YangDerivedInfo refDerivedInfo = (YangDerivedInfo<?>) baseType.getDataTypeExtendedInfo();
T extendedInfo = (T) refDerivedInfo.getResolvedExtendedInfo();
return getResolveStatusForRangeRestrictionType(extendedInfo);
} else if (effectiveBuiltInType == STRING) {
return getResolveStatusForString(extendedInfo);
} else if (effectiveBuiltInType == BINARY) {
return getResolveStatusForBinary(extendedInfo);
} else if (effectiveBuiltInType == DECIMAL64) {
if (extendedInfo == null) {
resolveRangeRestriction(null);
} else {
if (!(extendedInfo instanceof YangRangeRestriction)) {
throwError();
resolveRangeRestriction((YangRangeRestriction) extendedInfo);
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
YangType<?> baseType = getReferredTypeDef().getTypeDefBaseType();
YangDataTypes type = baseType.getDataType();
T extended = (T) baseType.getDataTypeExtendedInfo();
ResolvableStatus resolvableStatus = resolveTypeDerivedInfo(baseType);
if (resolvableStatus != null) {
return resolvableStatus;
return getResolveStatusForRangeRestrictionType(extended);
} else if (effectiveBuiltInType == STRING) {
return getResolveStatusForString(extended);
} else if (effectiveBuiltInType == BINARY) {
return getResolveStatusForBinary(extended);
} else if (effectiveBuiltInType == DECIMAL64) {
return getResolveStatusForDecimal64(extended);
throw new DataModelException(getErrorMsg(
"YANG file error: Restrictions can't be applied to a " +
"given type ", "type.", getLineNumber(),
getCharPosition(), getFileName() + "\""));
getLineNumber(), getCharPosition(), getFileName() + "\""));
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
private void throwError() throws DataModelException {
throw new DataModelException(getErrorMsg(
"Linker error: Referred typedef restriction info is of invalid ",
"type.", getLineNumber(), getCharPosition(), getFileName() + "\""));
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
/**
* Resolves the binary restrictions.
*
* @param refLr referred length restriction of typedef
* @throws DataModelException a violation in data model rule
*/
private void resolveBinaryRestriction(YangRangeRestriction refLr)
throws DataModelException {
if (rangeRes != null || !(patternResList == null ||
patternResList.isEmpty())) {
throw new DataModelException(getErrorMsg(
"YANG file error: for binary range restriction or " +
"pattern restriction is not allowed.", "type.",
getLineNumber(), getCharPosition(), getFileName()));
}
// Get the final resolved length restriction
YangRangeRestriction lr = resolveLengthRestriction(refLr);
// Set the length restriction.
resolvedExtendedInfo = (T) lr;
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
return processLengthRes(null, getLineNumber(), getCharPosition(),
false, lengthRes, getFileName());
refLr, getLineNumber(), getCharPosition(), true,
lengthRes, getFileName());
resolveLengthAndRangeRestriction(refLr, curLr);
return curLr;
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
if (extended != null) {
if (((YangDecimal64) extended).getRangeRestrictedExtendedInfo() == null) {
resolveRangeRestriction(null);
if (!(((YangDecimal64) extended)
.getRangeRestrictedExtendedInfo() instanceof YangRangeRestriction)) {
throwError();
resolveRangeRestriction((YangRangeRestriction) (
(YangDecimal64) extended).getRangeRestrictedExtendedInfo());
throw new DataModelException(getErrorMsg(
"Linker error: Unable to find type extended info " +
"for decimal64.", "type.", getLineNumber(),
getCharPosition(), getFileName() + "\""));
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
YangDataTypes dataType = ((YangDerivedInfo) getDataTypeExtendedInfo()).getEffectiveBuiltInType();
if (isOfRangeRestrictedType(dataType)) {
if (((YangDerivedInfo) getDataTypeExtendedInfo()).getResolvedExtendedInfo() == null) {
getDataObjectFromString(value,
((YangDerivedInfo) getDataTypeExtendedInfo())
.getEffectiveBuiltInType());
} else {
if (!((YangRangeRestriction) ((YangDerivedInfo) getDataTypeExtendedInfo())
.getResolvedExtendedInfo()).isValidValueString(value)) {
throw new DataTypeException("YANG file error : Input value \"" + value
+ "\" is not a valid " + dataType);
.getResolvedExtendedInfo();
if (info != null) {
if (info instanceof YangStringRestriction) {
.getReferredTypeDef();
YangType type = prevTypedef.getTypeList().iterator().next();
YangBits bits = (YangBits) type.getDataTypeExtendedInfo();
getDataTypeExtendedInfo()).getResolvedExtendedInfo())) {
throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
dataType);
YangTypeDef typedef = derivedInfo.getReferredTypeDef();
YangType<YangDecimal64> decimal64Type =
(YangType<YangDecimal64>) typedef.getTypeList().iterator().next();
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
.getDataTypeExtendedInfo()).getReferredTypeDef()
.getTypeList().get(0);
return getObject(rt, v, rt.getDataType());
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
yangDerivedInfo.setLineNumber(ctx.getStart().getLine());
yangDerivedInfo.setCharPosition(ctx.getStart().getCharPositionInLine());
yangDerivedInfo.setFileName(listener.getFileName());
((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
yangDerivedInfo.setLineNumber(ctx.getStart().getLine());
yangDerivedInfo.setCharPosition(ctx.getStart().getCharPositionInLine());
yangDerivedInfo.setFileName(listener.getFileName());
((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
yangDerivedInfo.setLineNumber(ctx.getStart().getLine());
yangDerivedInfo.setCharPosition(ctx.getStart().getCharPositionInLine());
yangDerivedInfo.setFileName(listener.getFileName());
((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
yangDerivedInfo.setLineNumber(ctx.getStart().getLine());
yangDerivedInfo.setCharPosition(ctx.getStart().getCharPositionInLine());
yangDerivedInfo.setFileName(listener.getFileName());
((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
代码示例来源: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-datamodel
throw new DataModelException(getErrorMsg(
"YANG file error: Range restriction should't be present for" +
" string data type.", ".", getLineNumber(),
getCharPosition(), getFileName()));
YangRangeRestriction lr = resolveLengthRestriction(refRr);
List<YangPatternRestriction> pr = resolvePatternRestriction(refPr);
curSr.setCharPosition(getCharPosition());
curSr.setFileName(getFileName());
curSr.setLineNumber(getLineNumber());
curSr.setLengthRestriction(lr);
curSr.setPatternResList(pr);
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
"YANG file error: Length/Pattern restriction should't be " +
"present for int/uint/decimal data type.", "type.",
getLineNumber(), getCharPosition(), getFileName()));
processRangeRestriction(null, getLineNumber(),
getCharPosition(), false, rangeRes,
effectiveBuiltInType, getFileName());
resolvedExtendedInfo = (T) curRangeRestriction;
return;
processRangeRestriction(refRangeRestriction, getLineNumber(),
getCharPosition(), true, rangeRes,
effectiveBuiltInType, getFileName());
resolveLengthAndRangeRestriction(refRangeRestriction, curRangeRestriction);
resolvedExtendedInfo = (T) curRangeRestriction;
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
.getDataTypeExtendedInfo()).getReferredTypeDef()
.getTypeList().get(0);
return getLeafType(rt, v, rt.getDataType());
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
/**
* Resolves the length/range self and referred restriction, to check whether
* the all the range interval in self restriction is stricter than the
* referred typedef's restriction.
*
* @param refRestriction referred restriction
* @param curRestriction self restriction
*/
private void resolveLengthAndRangeRestriction(YangRangeRestriction refRestriction,
YangRangeRestriction curRestriction)
throws DataModelException {
for (Object curInterval : curRestriction.getAscendingRangeIntervals()) {
if (!(curInterval instanceof YangRangeInterval)) {
throw new DataModelException(getErrorMsg(
"Linker error: Current range intervals not processed correctly.",
"type.", getLineNumber(), getCharPosition(), getFileName()));
}
try {
refRestriction.isValidInterval((YangRangeInterval)
curInterval, getFileName());
} catch (DataModelException e) {
throw new DataModelException(getErrorMsg(
e.getMessage(), "type.", getLineNumber(), getCharPosition(),
getFileName()));
}
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
case DERIVED:
return getLeafTypeByDataType(type, ((YangDerivedInfo) type
.getDataTypeExtendedInfo()).getEffectiveBuiltInType());
case LEAFREF:
return getLeafTypeByDataType(type, ((YangLeafRef) type
代码示例来源: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
/**
* 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-parser
YangDerivedInfo<?> info = (YangDerivedInfo<?>) type
.getDataTypeExtendedInfo();
info.addPatternRes(patRes);
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!