本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.SchemaNode类的典型用法代码示例。如果您正苦于以下问题:Java SchemaNode类的具体用法?Java SchemaNode怎么用?Java SchemaNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SchemaNode类属于org.opendaylight.yangtools.yang.model.api包,在下文中一共展示了SchemaNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseDefaultConfigFile
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
private NormalizedNode<?, ?> parseDefaultConfigFile(final ConfigFileProcessor config, final String filename)
throws IOException, XMLStreamException {
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
try (InputStream resourceAsStream = new FileInputStream(new File(this.path, filename))) {
final XMLInputFactory factory = XMLInputFactory.newInstance();
final XMLStreamReader reader = factory.createXMLStreamReader(resourceAsStream);
final SchemaNode schemaNode = SchemaContextUtil
.findDataSchemaNode(this.schemaContext, config.getSchemaPath());
try (XmlParserStream xmlParser = XmlParserStream.create(streamWriter, this.schemaContext, schemaNode)) {
xmlParser.parse(reader);
} catch (final URISyntaxException | XMLStreamException | IOException | ParserConfigurationException
| SAXException e) {
LOG.warn("Failed to parse xml", e);
} finally {
reader.close();
}
}
return result.getResult();
}
示例2: emitUsesNode
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
private void emitUsesNode(final UsesNode usesNode) {
if (super.emitUses && !usesNode.isAddedByUses() && !usesNode.isAugmenting()) {
super.writer.startUsesNode(usesNode.getGroupingPath().getLastComponent());
/*
* FIXME: BUG-2444: whenNode / *(ifFeatureNode ) statusNode //
* Optional F : descriptionNode // Optional referenceNode //
* Optional
*/
for (final Entry<SchemaPath, SchemaNode> refine : usesNode.getRefines().entrySet()) {
emitRefine(refine);
}
for (final AugmentationSchemaNode aug : usesNode.getAugmentations()) {
emitUsesAugmentNode(aug);
}
super.writer.endNode();
}
}
示例3: emitRefine
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
private void emitRefine(final Entry<SchemaPath, SchemaNode> refine) {
final SchemaPath path = refine.getKey();
final SchemaNode value = refine.getValue();
super.writer.startRefineNode(path);
if (value instanceof LeafSchemaNode) {
emitRefineLeafNodes((LeafSchemaNode) value);
} else if (value instanceof LeafListSchemaNode) {
emitRefineLeafListNodes((LeafListSchemaNode) value);
} else if (value instanceof ListSchemaNode) {
emitRefineListNodes((ListSchemaNode) value);
} else if (value instanceof ChoiceSchemaNode) {
emitRefineChoiceNodes((ChoiceSchemaNode) value);
} else if (value instanceof CaseSchemaNode) {
emitRefineCaseNodes((CaseSchemaNode) value);
} else if (value instanceof ContainerSchemaNode) {
emitRefineContainerNodes((ContainerSchemaNode) value);
} else if (value instanceof AnyXmlSchemaNode) {
emitRefineAnyxmlNodes((AnyXmlSchemaNode) value);
}
super.writer.endNode();
}
示例4: findParentModuleOfReferencingType
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
private static Module findParentModuleOfReferencingType(final SchemaContext schemaContext,
final SchemaNode schemaNode) {
Preconditions.checkArgument(schemaContext != null, "Schema Context reference cannot be NULL!");
Preconditions.checkArgument(schemaNode instanceof TypedDataSchemaNode, "Unsupported node %s", schemaNode);
TypeDefinition<?> nodeType = ((TypedDataSchemaNode) schemaNode).getType();
if (nodeType.getBaseType() != null) {
while (nodeType.getBaseType() != null) {
nodeType = nodeType.getBaseType();
}
return schemaContext.findModule(nodeType.getQName().getModule()).orElse(null);
}
return SchemaContextUtil.findParentModule(schemaContext, schemaNode);
}
示例5: write
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
private SchemaOrderedNormalizedNodeWriter write(final NormalizedNode<?, ?> node, final SchemaNode dataSchemaNode)
throws IOException {
//Set current schemaNode
try (SchemaNodeSetter sns = new SchemaNodeSetter(dataSchemaNode)) {
if (node == null) {
return this;
}
if (wasProcessedAsCompositeNode(node)) {
return this;
}
if (wasProcessAsSimpleNode(node)) {
return this;
}
}
throw new IllegalStateException("It wasn't possible to serialize node " + node);
}
示例6: assertModifier
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
private static void assertModifier(final SchemaContext schemaContext, final ModifierKind expectedModifierKind,
final List<String> localNamePath) {
final SchemaNode findNode = findNode(schemaContext, localNamePath);
assertTrue(findNode instanceof LeafSchemaNode);
final LeafSchemaNode myLeaf = (LeafSchemaNode) findNode;
final TypeDefinition<? extends TypeDefinition<?>> type = myLeaf.getType();
assertTrue(type instanceof StringTypeDefinition);
final StringTypeDefinition stringType = (StringTypeDefinition) type;
final List<PatternConstraint> patternConstraints = stringType.getPatternConstraints();
assertEquals(1, patternConstraints.size());
final PatternConstraint patternConstraint = patternConstraints.iterator().next();
assertEquals(Optional.ofNullable(expectedModifierKind), patternConstraint.getModifier());
}
示例7: test
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
@Test
public void test() throws Exception {
SchemaContext context = TestUtils.parseYangSources("/bugs/bug4231");
assertNotNull(context);
QNameModule foo = QNameModule.create(new URI("foo"), Revision.of("2015-09-02"));
SchemaPath targetPath = SchemaPath
.create(true, QName.create(foo, "augment-target"))
.createChild(QName.create(foo, "my-container-in-grouping"))
.createChild(QName.create(foo, "l2"));
SchemaNode targetNode = SchemaContextUtil.findNodeInSchemaContext(
context, targetPath.getPathFromRoot());
assertNotNull(targetNode);
}
示例8: findDataSchemaNodeTest2
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
@Test
public void findDataSchemaNodeTest2() throws URISyntaxException, IOException, YangSyntaxErrorException,
ReactorException {
// findDataSchemaNode(final SchemaContext context, final Module module,
// final RevisionAwareXPath nonCondXPath) {
final SchemaContext context = TestUtils.parseYangSources("/schema-context-util-test");
final Module module = context.findModule(new URI("uri:my-module"), Revision.of("2014-10-07")).get();
final GroupingDefinition grouping = getGroupingByName(module, "my-grouping");
final SchemaNode testNode = grouping.getDataChildByName(QName.create(module.getQNameModule(),
"my-leaf-in-gouping2"));
final RevisionAwareXPath xpath = new RevisionAwareXPathImpl("my:my-grouping/my:my-leaf-in-gouping2", true);
final SchemaNode foundNode = SchemaContextUtil.findDataSchemaNode(context, module, xpath);
assertNotNull(foundNode);
assertNotNull(testNode);
assertEquals(testNode, foundNode);
}
示例9: findNodeInSchemaContextTheSameNameOfSiblingsTest
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
@Test
public void findNodeInSchemaContextTheSameNameOfSiblingsTest() throws URISyntaxException, IOException,
YangSyntaxErrorException, ReactorException {
final SchemaContext context = TestUtils.parseYangSources("/schema-context-util-test");
final Module myModule = context.findModule(new URI("uri:my-module"), Revision.of("2014-10-07")).get();
final ChoiceSchemaNode choice = (ChoiceSchemaNode) getRpcByName(myModule, "my-name").getInput()
.getDataChildByName(QName.create(myModule.getQNameModule(), "my-choice"));
final SchemaNode testNode = choice.findCaseNodes("case-two").iterator().next()
.getDataChildByName(QName.create(myModule.getQNameModule(), "two"));
final SchemaPath path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-name"),
QName.create(myModule.getQNameModule(), "input"), QName.create(myModule.getQNameModule(), "my-choice"),
QName.create(myModule.getQNameModule(), "case-two"), QName.create(myModule.getQNameModule(), "two"));
final SchemaNode foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());
assertNotNull(testNode);
assertNotNull(foundNode);
assertEquals(testNode, foundNode);
}
示例10: getDataNodeContainer
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
/**
* Since each case statement within a module must provide unique child nodes, it is allowed to wrap
* the actual configuration with a container node with name equal to case name.
*
* @param choiceCaseNode state or configuration case statement
* @return either choiceCaseNode or its only child container
*/
private static <HAS_CHILDREN_AND_QNAME extends DataNodeContainer & SchemaNode> HAS_CHILDREN_AND_QNAME getDataNodeContainer(final ChoiceCaseNode choiceCaseNode) {
Collection<DataSchemaNode> childNodes = choiceCaseNode.getChildNodes();
if (childNodes.size() == 1) {
DataSchemaNode onlyChild = childNodes.iterator().next();
if (onlyChild instanceof ContainerSchemaNode) {
ContainerSchemaNode onlyContainer = (ContainerSchemaNode) onlyChild;
if (Objects.equals(onlyContainer.getQName().getLocalName(), choiceCaseNode.getQName().getLocalName())) {
// the actual configuration is inside dummy container
return (HAS_CHILDREN_AND_QNAME) onlyContainer;
}
}
}
return (HAS_CHILDREN_AND_QNAME) choiceCaseNode;
}
示例11: findQNameFromGrouping
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
/**
* Find "proper" qname of unknown node in case it comes from a grouping
*/
private static QName findQNameFromGrouping(final DataNodeContainer subtree, final SchemaContext ctx, final UnknownSchemaNode unknownSchemaNode, final String localIdentityName) {
QName identityQName = null;
for (UsesNode usesNode : subtree.getUses()) {
SchemaNode dataChildByName = SchemaContextUtil.findDataSchemaNode(ctx, usesNode.getGroupingPath());
Module m = SchemaContextUtil.findParentModule(ctx, dataChildByName);
List<UnknownSchemaNode> unknownSchemaNodes = dataChildByName.getUnknownSchemaNodes();
if(Collections2.transform(unknownSchemaNodes, UNKNOWN_NODE_TO_STRING).contains(UNKNOWN_NODE_TO_STRING.apply(unknownSchemaNode))) {
identityQName = QName.create(dataChildByName.getQName(), localIdentityName);
}
}
return identityQName;
}
示例12: convertToJavaName
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
public static String convertToJavaName(final SchemaNode schemaNode,
final boolean capitalizeFirstLetter) {
for (final UnknownSchemaNode unknownNode : schemaNode.getUnknownSchemaNodes()) {
if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME
.equals(unknownNode.getNodeType())) {
final String value = unknownNode.getNodeParameter();
return convertToJavaName(value, capitalizeFirstLetter);
}
}
return convertToJavaName(schemaNode.getQName().getLocalName(),
capitalizeFirstLetter);
}
示例13: getType
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
public Type getType(final SchemaNode leaf, final TypeDefinition<?> type) {
Type javaType;
try {
javaType = this.typeProvider.javaTypeForSchemaDefinitionType(
type, leaf);
if (javaType == null) {
throw new IllegalArgumentException("Unknown type received for "
+ leaf.toString());
}
} catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Error while resolving type of "
+ leaf, e);
}
return javaType;
}
示例14: DataNormalizationOperation
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
protected DataNormalizationOperation(final T identifier, final SchemaNode schema) {
this.identifier = identifier;
if(schema instanceof DataSchemaNode) {
this.dataSchemaNode = Optional.of((DataSchemaNode) schema);
} else {
this.dataSchemaNode = Optional.absent();
}
}
示例15: startContainerNode
import org.opendaylight.yangtools.yang.model.api.SchemaNode; //导入依赖的package包/类
@SuppressWarnings("unused")
@Override
public final void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
final SchemaNode schema = tracker.startContainerNode(name);
// FIXME this code ignores presence for containers
// but datastore does as well and it needs be fixed first (2399)
context = new JSONStreamWriterNamedObjectContext(context, name, DEFAULT_EMIT_EMPTY_CONTAINERS);
}