本文整理了Java中org.onosproject.yang.compiler.datamodel.YangInclude
类的一些代码示例,展示了YangInclude
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangInclude
类的具体详情如下:
包路径:org.onosproject.yang.compiler.datamodel.YangInclude
类名称:YangInclude
[英]Represents the information about the included sub-modules.
[中]表示有关包含的子模块的信息。
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
@Override
public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
throws DataModelException {
// Run through the included list to add references.
for (YangInclude yangInclude : getIncludeList()) {
YangSubModule subModule = yangInclude
.addReferenceToInclude(yangNodeSet);
// Check if the referred sub-modules parent is self
if (!subModule.getBelongsTo().getModuleNode().equals(this)) {
yangInclude.reportIncludeError();
}
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
String includedSubModuleName = getSubModuleName();
Date includedSubModuleRevision = getRevision();
YangNode subModuleNode = null;
if (getRevision() == null) {
setIncludedNode(subModuleNode);
return (YangSubModule) subModuleNode;
.getRevision().getRevDate()
.equals(includedSubModuleRevision)) {
setIncludedNode(subModuleNode);
return (YangSubModule) subModuleNode;
exception.setLine(getLineNumber());
exception.setCharPosition(getCharPosition());
exception.setFileName(getFileName());
throw exception;
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Process linking using include list.
*
* @param root root node
* @param tempPathName temporary path node name
* @return linked target node
*/
private YangNode getIncludedNode(YangNode root, String tempPathName) {
List<YangInclude> includeList;
if (root instanceof YangModule) {
includeList = ((YangModule) root).getIncludeList();
} else {
includeList = ((YangSubModule) root).getIncludeList();
}
for (YangInclude included : includeList) {
if (verifyChildNode(included.getIncludedNode(), tempPathName)) {
return included.getIncludedNode();
}
}
return null;
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
/**
* Reports an error when included sub-module doesn't meet condition that
* "included sub-modules should belong module, as defined by the
* "belongs-to" statement or sub-modules are only allowed to include other
* sub-modules belonging to the same module.
*
* @throws DataModelException a violation in data model rule
*/
public void reportIncludeError() throws DataModelException {
DataModelException exception = new DataModelException("YANG file error : Included sub-module " +
getSubModuleName() + "doesn't belongs to parent module also it doesn't belongs" +
"to sub-module belonging to the same parent module.");
exception.setLine(getLineNumber());
exception.setCharPosition(getCharPosition());
exception.setFileName(getFileName());
throw exception;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* It is called when parser receives an input matching the grammar rule
* (include), perform validations and update the data model tree.
*
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processIncludeEntry(TreeWalkListener listener, IncludeStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, INCLUDE_DATA, ctx.identifier().getText(),
ENTRY);
String identifier = getValidIdentifier(ctx.identifier().getText(), INCLUDE_DATA, ctx);
YangInclude includeNode = new YangInclude();
includeNode.setSubModuleName(identifier);
// Set the line number and character position in line for the belongs to.
int errorLine = ctx.getStart().getLine();
int errorPosition = ctx.getStart().getCharPositionInLine();
includeNode.setLineNumber(errorLine);
includeNode.setCharPosition(errorPosition);
includeNode.setFileName(listener.getFileName());
listener.getParsedDataStack().push(includeNode);
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
@Override
public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
throws DataModelException {
// Run through the included list to add references.
for (YangInclude yangInclude : getIncludeList()) {
YangSubModule subModule = yangInclude.addReferenceToInclude(yangNodeSet);
// Check if the referred sub-modules parent is self
if (!Objects.equals(subModule.getBelongsTo().getModuleNode(), getBelongsTo()
.getModuleNode())) {
yangInclude.reportIncludeError();
}
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Returns the referred node, by finding in the list of included nodes,
* inside the given node.
*
* @param node YANG node
* @return referred node inside included node
*/
private YangNode getFromIncludeList(YangNode node) {
List<YangInclude> incList = ((YangReferenceResolver) node)
.getIncludeList();
YangNode refNode = null;
if (incList != null && !incList.isEmpty()) {
for (YangInclude inc : incList) {
refNode = getLinkedNode(inc.getIncludedNode());
if (refNode != null) {
break;
}
}
}
return refNode;
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Searches in sub-module node.
*
* @param root root node
* @return target linked node
*/
private YangNode searchInSubModule(YangNode root) {
List<YangInclude> includeList;
YangNode tempNode;
if (root instanceof YangModule) {
includeList = ((YangModule) root).getIncludeList();
} else {
includeList = ((YangSubModule) root).getIncludeList();
}
for (YangInclude included : includeList) {
tempNode = parseData(included.getIncludedNode());
if (tempNode != null) {
return tempNode;
}
}
return null;
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
YangNode includedNode = yangInclude.getIncludedNode();
if (curNodePriority >= includedNode.getPriority()) {
includedNode.setPriority(curNodePriority + 1);
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Finds and resolves with include list.
*
* @return true if resolved, false otherwise
* @throws DataModelException a violation in data model rule
*/
private boolean resolveWithInclude() throws DataModelException {
/*
* Run through all the nodes in include list and search for referred
* typedef/grouping at the root level.
*/
for (YangInclude yangInclude : curRefResolver.getIncludeList()) {
YangNode inc = yangInclude.getIncludedNode();
YangNode linkedNode = getLinkedNode(inc);
if (linkedNode == null) {
linkedNode = getFromIncludeList(inc);
}
if (linkedNode != null) {
return addUnResolvedRefToStack(linkedNode);
}
}
// If referred node can't be found return false.
return false;
}
内容来源于网络,如有侵权,请联系作者删除!