本文整理汇总了Java中org.onosproject.yangutils.datamodel.YangType类的典型用法代码示例。如果您正苦于以下问题:Java YangType类的具体用法?Java YangType怎么用?Java YangType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
YangType类属于org.onosproject.yangutils.datamodel包,在下文中一共展示了YangType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isReferredNode
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Checks if the potential referred node is the actual referred node.
*
* @param potentialReferredNode typedef/grouping node
* @return true if node is of resolve type otherwise false
* @throws DataModelException a violation of data model rules
*/
private boolean isReferredNode(YangNode potentialReferredNode)
throws DataModelException {
if (getCurrentEntityToResolveFromStack() instanceof YangType) {
if (potentialReferredNode instanceof YangTypeDef) {
/*
* Check if name of node name matches with the entity being
* resolved
*/
return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
}
} else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
if (potentialReferredNode instanceof YangGrouping) {
/*
* Check if name of node name matches with the entity being
* resolved
*/
return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
}
} else {
throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
}
return false;
}
示例2: isNodeNameSameAsResolutionInfoName
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Checks if node name is same as name in resolution info, i.e. name of
* typedef/grouping is same as name of type/uses.
*
* @param node typedef/grouping node
* @return true if node name is same as name in resolution info, otherwise
* false
* @throws DataModelException a violation of data model rules
*/
private boolean isNodeNameSameAsResolutionInfoName(YangNode node)
throws DataModelException {
if (getCurrentEntityToResolveFromStack() instanceof YangType) {
if (node.getName().contentEquals(
((YangType<?>) getCurrentEntityToResolveFromStack())
.getDataTypeName())) {
return true;
}
} else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
if (node.getName().contentEquals(
((YangUses) getCurrentEntityToResolveFromStack()).getName())) {
return true;
}
} else {
throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
}
return false;
}
示例3: addReferredEntityLink
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Adds reference of grouping/typedef in uses/type.
*
* @param referredNode grouping/typedef node being referred
* @param linkedStatus linked status if success.
* @throws DataModelException a violation of data model rules
*/
private void addReferredEntityLink(YangNode referredNode, ResolvableStatus linkedStatus)
throws DataModelException {
if (getCurrentEntityToResolveFromStack() instanceof YangType) {
YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) ((YangType<?>) getCurrentEntityToResolveFromStack())
.getDataTypeExtendedInfo();
derivedInfo.setReferredTypeDef((YangTypeDef) referredNode);
} else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
((YangUses) getCurrentEntityToResolveFromStack())
.setRefGroup((YangGrouping) referredNode);
} else {
throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
}
// Sets the resolution status in inside the type/uses.
((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(linkedStatus);
}
示例4: addUnresolvedRecursiveReferenceToStack
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Checks if type/grouping has further reference to typedef/ unresolved
* uses. Add it to the partial resolve stack and return the status of
* addition to stack.
*
* @param referredNode grouping/typedef node
* @throws DataModelException a violation of data model rules
*/
private void addUnresolvedRecursiveReferenceToStack(YangNode referredNode)
throws DataModelException {
if (getCurrentEntityToResolveFromStack() instanceof YangType) {
/*
* Checks if typedef type is derived
*/
if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType() == YangDataTypes.DERIVED) {
YangEntityToResolveInfoImpl<YangType<?>> unResolvedEntityInfo = new YangEntityToResolveInfoImpl<>();
unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode)
.getTypeDefBaseType());
unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode);
addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedEntityInfo);
}
} else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
/*
* Search if the grouping has any un resolved uses child, if so
* return true, else return false.
*/
addUnResolvedUsesToStack(referredNode);
} else {
throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
}
}
示例5: getEntityPrefix
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Retrieves the prefix of the entity.
*
* @return entities prefix
* @throws LinkerException linker error
*/
public String getEntityPrefix()
throws LinkerException {
if (getEntityToResolve() == null) {
return null;
}
String prefix;
T entityToBeResolved = getEntityToResolve();
if (entityToBeResolved instanceof YangType) {
prefix = ((YangType<?>) entityToBeResolved).getPrefix();
} else if (entityToBeResolved instanceof YangUses) {
prefix = ((YangUses) entityToBeResolved).getPrefix();
} else {
throw new LinkerException("Linker Exception: Entity to resolved is other than type/uses");
}
return prefix;
}
示例6: processPatternRestrictionEntry
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* It is called when parser receives an input matching the grammar
* rule (pattern), performs validation and updates the data model
* tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processPatternRestrictionEntry(TreeWalkListener listener,
GeneratedYangParser.PatternStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, PATTERN_DATA, ctx.string().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
if (tmpData.getYangConstructType() == TYPE_DATA) {
YangType type = (YangType) tmpData;
setPatternRestriction(listener, type, ctx);
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, PATTERN_DATA,
ctx.string().getText(), ENTRY));
}
}
示例7: processPatternRestrictionExit
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* 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));
}
}
示例8: processLengthRestrictionEntry
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* It is called when parser receives an input matching the grammar
* rule (length), performs validation and updates the data model
* tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processLengthRestrictionEntry(TreeWalkListener listener,
GeneratedYangParser.LengthStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LENGTH_DATA, ctx.length().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
if (tmpData.getYangConstructType() == TYPE_DATA) {
YangType type = (YangType) tmpData;
setLengthRestriction(listener, type, ctx);
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LENGTH_DATA,
ctx.length().getText(), ENTRY));
}
}
示例9: processLengthRestrictionExit
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* 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));
}
}
示例10: processRangeRestrictionEntry
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* It is called when parser receives an input matching the grammar
* rule (range), performs validation and updates the data model
* tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processRangeRestrictionEntry(TreeWalkListener listener,
GeneratedYangParser.RangeStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, RANGE_DATA, ctx.range().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
if (tmpData.getYangConstructType() == TYPE_DATA) {
YangType type = (YangType) tmpData;
setRangeRestriction(listener, type, ctx);
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, RANGE_DATA,
ctx.range().getText(), ENTRY));
}
}
示例11: processRangeRestrictionExit
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* 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));
}
}
示例12: addTypeInfoToTempFiles
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Adds all the type in the current data model node as part of the generated
* temporary file.
*
* @param yangTypeHolder YANG java data model node which has type info, eg union /
* typedef
* @param pluginConfig plugin configurations for naming conventions
* @throws IOException IO operation fail
*/
public void addTypeInfoToTempFiles(YangTypeHolder yangTypeHolder, YangPluginConfig pluginConfig)
throws IOException {
List<YangType<?>> typeList = yangTypeHolder.getTypeList();
if (typeList != null) {
for (YangType<?> yangType : typeList) {
if (!(yangType instanceof YangJavaType)) {
throw new TranslatorException("Type does not have Java info");
}
YangJavaType<?> javaType = (YangJavaType<?>) yangType;
javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver());
String typeName = javaType.getDataTypeName();
typeName = getCamelCase(typeName, pluginConfig.getConflictResolver());
JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData(
javaType.getJavaQualifiedInfo(),
typeName, javaType,
getIsQualifiedAccessOrAddToImportList(javaType.getJavaQualifiedInfo()),
false);
addJavaSnippetInfoToApplicableTempFiles((YangNode) yangTypeHolder, javaAttributeInfo,
pluginConfig);
}
}
}
示例13: getTypDefsPackage
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Returns java package for typedef node.
*
* @param type YANG type
* @param conflictResolver object of YANG to java naming conflict util
* @return java package for typedef node
*/
private static String getTypDefsPackage(YangType<?> type, YangToJavaNamingConflictUtil conflictResolver) {
Object var = type.getDataTypeExtendedInfo();
if (!(var instanceof YangDerivedInfo)) {
throw new TranslatorException("type should have been derived.");
}
if (!(((YangDerivedInfo<?>) var).getReferredTypeDef() instanceof YangTypeDef)) {
throw new TranslatorException("derived info is not an instance of typedef.");
}
YangJavaTypeDef typedef = (YangJavaTypeDef) ((YangDerivedInfo<?>) var).getReferredTypeDef();
if (typedef.getJavaFileInfo().getPackage() == null) {
return getPackageFromParent(typedef.getParent(), conflictResolver);
}
return typedef.getJavaFileInfo().getPackage();
}
示例14: addResolutionInfo
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Add a resolution information.
*
* @param resolutionInfo information about the YANG construct which has to be resolved
* @throws DataModelException a violation of data model rules
*/
public static void addResolutionInfo(YangResolutionInfo resolutionInfo)
throws DataModelException {
/* get the module node to add maintain the list of nested reference */
YangNode curNode = resolutionInfo.getEntityToResolveInfo()
.getHolderOfEntityToResolve();
while (!(curNode instanceof YangReferenceResolver)) {
curNode = curNode.getParent();
if (curNode == null) {
throw new DataModelException("Internal datamodel error: Datamodel tree is not correct");
}
}
YangReferenceResolver resolutionNode = (YangReferenceResolver) curNode;
if (resolutionInfo.getEntityToResolveInfo()
.getEntityToResolve() instanceof YangType) {
resolutionNode.addToResolutionList(resolutionInfo,
ResolvableType.YANG_DERIVED_DATA_TYPE);
} else {
resolutionNode.addToResolutionList(resolutionInfo,
ResolvableType.YANG_USES);
}
}
示例15: isTypeEmpty
import org.onosproject.yangutils.datamodel.YangType; //导入依赖的package包/类
/**
* Returns the value as true if direct or referred type from leafref or
* derived points to empty data type; false otherwise.
*
* @param fieldValue value of the leaf
* @param dataType type of the leaf
* @return true if type is empty; false otherwise.
*/
private boolean isTypeEmpty(String fieldValue, YangType<?> dataType) {
if (fieldValue.equals(TRUE) || fieldValue.equals(FALSE)) {
switch (dataType.getDataType()) {
case EMPTY:
return true;
case LEAFREF:
YangLeafRef leafRef =
(YangLeafRef) dataType.getDataTypeExtendedInfo();
return isTypeEmpty(fieldValue,
leafRef.getEffectiveDataType());
case DERIVED:
YangDerivedInfo info =
(YangDerivedInfo) dataType
.getDataTypeExtendedInfo();
YangDataTypes type = info.getEffectiveBuiltInType();
return type == EMPTY;
default:
return false;
}
}
return false;
}