当前位置: 首页>>代码示例>>Java>>正文


Java SchemaContextUtil.findNodeInSchemaContext方法代码示例

本文整理汇总了Java中org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaContextUtil.findNodeInSchemaContext方法的具体用法?Java SchemaContextUtil.findNodeInSchemaContext怎么用?Java SchemaContextUtil.findNodeInSchemaContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opendaylight.yangtools.yang.model.util.SchemaContextUtil的用法示例。


在下文中一共展示了SchemaContextUtil.findNodeInSchemaContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findNodeInSchemaContextTheSameNameOfSiblingsTest

import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; //导入方法依赖的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);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:22,代码来源:SchemaContextUtilTest.java

示例2: test

import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; //导入方法依赖的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);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:18,代码来源:Bug4231Test.java

示例3: setup

import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
    fooModule = QNameModule.create(URI.create("foo-namespace"));
    parentContainer = QName.create(fooModule, "parent-container");

    bazModule = QNameModule.create(URI.create("baz-namespace"));
    outerContainer = QName.create(bazModule, "outer-container");

    myContainer1 = QName.create(bazModule, "my-container-1");
    myKeyedList = QName.create(bazModule, "my-keyed-list");
    myKeyLeaf = QName.create(bazModule, "my-key-leaf");
    myLeafInList1 = QName.create(bazModule, "my-leaf-in-list-1");
    myLeafInList2 = QName.create(bazModule, "my-leaf-in-list-2");
    myLeaf1 = QName.create(bazModule, "my-leaf-1");
    myLeafList = QName.create(bazModule, "my-leaf-list");

    myContainer2 = QName.create(bazModule, "my-container-2");
    innerContainer = QName.create(bazModule, "inner-container");
    myLeaf2 = QName.create(bazModule, "my-leaf-2");
    myLeaf3 = QName.create(bazModule, "my-leaf-3");
    myChoice = QName.create(bazModule, "my-choice");
    myLeafInCase2 = QName.create(bazModule, "my-leaf-in-case-2");

    myContainer3 = QName.create(bazModule, "my-container-3");
    myDoublyKeyedList = QName.create(bazModule, "my-doubly-keyed-list");
    myFirstKeyLeaf = QName.create(bazModule, "my-first-key-leaf");
    mySecondKeyLeaf = QName.create(bazModule, "my-second-key-leaf");
    myLeafInList3 = QName.create(bazModule, "my-leaf-in-list-3");

    schemaContext = YangParserTestUtils.parseYangResourceDirectory("/");
    parentContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext,
            ImmutableList.of(parentContainer));
    outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext,
            ImmutableList.of(outerContainer));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:36,代码来源:XmlToNormalizedNodesTest.java

示例4: test

import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/dom-reader-test");
    final ContainerSchemaNode outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil
            .findNodeInSchemaContext(schemaContext, ImmutableList.of(QName.create("foo-ns", "top-cont")));
    assertNotNull(outerContainerSchema);

    // deserialization
    final Document doc = loadDocument("/dom-reader-test/foo.xml");
    final DOMSource inputXml = new DOMSource(doc.getDocumentElement());
    XMLStreamReader domXMLReader = new DOMSourceXMLStreamReader(inputXml);

    final NormalizedNodeResult result = new NormalizedNodeResult();
    final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
    final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, outerContainerSchema);
    xmlParser.parse(domXMLReader);
    final NormalizedNode<?, ?> transformedInput = result.getResult();
    assertNotNull(transformedInput);

    // serialization
    //final StringWriter writer = new StringWriter();
    final DOMResult domResult = new DOMResult(UntrustedXML.newDocumentBuilder().newDocument());
    final XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
    outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
    final XMLStreamWriter xmlStreamWriter = outputFactory.createXMLStreamWriter(domResult);

    final NormalizedNodeStreamWriter xmlNormalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(
            xmlStreamWriter, schemaContext);

    final NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(
            xmlNormalizedNodeStreamWriter);
    normalizedNodeWriter.write(transformedInput);

    //final String serializedXml = writer.toString();
    final String serializedXml = toString(domResult.getNode());
    assertFalse(serializedXml.isEmpty());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:38,代码来源:DOMSourceXMLStreamReaderTest.java

示例5: getCorrespondingTypedSchemaNode

import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; //导入方法依赖的package包/类
private static TypedDataSchemaNode getCorrespondingTypedSchemaNode(final SchemaContext schemaContext,
        final NormalizedNodeContext currentNodeContext) {
    Iterator<NormalizedNodeContext> ancestorOrSelfAxisIterator;
    try {
        ancestorOrSelfAxisIterator = currentNodeContext.getContextSupport().getNavigator()
                .getAncestorOrSelfAxisIterator(currentNodeContext);
    } catch (UnsupportedAxisException ex) {
        throw new JaxenRuntimeException(ex);
    }

    final Deque<QName> schemaPathToCurrentNode = new ArrayDeque<>();
    while (ancestorOrSelfAxisIterator.hasNext()) {
        final NormalizedNode<?, ?> nextNode = ancestorOrSelfAxisIterator.next().getNode();
        if (!(nextNode instanceof MapNode) && !(nextNode instanceof LeafSetNode)
                && !(nextNode instanceof AugmentationNode)) {
            schemaPathToCurrentNode.addFirst(nextNode.getNodeType());
        }
    }

    final SchemaNode schemaNode = SchemaContextUtil.findNodeInSchemaContext(schemaContext, schemaPathToCurrentNode);

    Preconditions.checkNotNull(schemaNode, "Node %s does not have a corresponding SchemaNode in the SchemaContext.",
            currentNodeContext.getNode());
    Preconditions.checkState(schemaNode instanceof TypedDataSchemaNode, "Node %s must be a leaf or a leaf-list.",
            currentNodeContext.getNode());
    return (TypedDataSchemaNode) schemaNode;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:28,代码来源:YangFunctionContext.java

示例6: findNodeInSchemaContextTest3

import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; //导入方法依赖的package包/类
@Test
public void findNodeInSchemaContextTest3() 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();

    SchemaNode testNode = myModule.getDataChildByName(QName.create(myModule.getQNameModule(), "my-container"));

    SchemaPath path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-container"));
    SchemaNode foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());

    assertNotNull(testNode);
    assertNotNull(foundNode);
    assertEquals(testNode, foundNode);

    testNode = getRpcByName(myModule, "my-rpc");

    path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-rpc"));
    foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());

    assertNotNull(testNode);
    assertNotNull(foundNode);
    assertEquals(testNode, foundNode);

    testNode = myModule.getNotifications().iterator().next();

    path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-notification"));
    foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());

    assertNotNull(testNode);
    assertNotNull(foundNode);
    assertEquals(testNode, foundNode);

    testNode = getGroupingByName(myModule, "my-grouping");

    path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-grouping"));
    foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());

    assertNotNull(testNode);
    assertNotNull(foundNode);
    assertEquals(testNode, foundNode);

    testNode = myModule.getDataChildByName(QName.create(myModule.getQNameModule(), "my-choice"));

    path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-choice"));
    foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());

    assertNotNull(testNode);
    assertNotNull(foundNode);
    assertEquals(testNode, foundNode);

    testNode = ((ContainerSchemaNode) myModule.getDataChildByName(QName.create(myModule.getQNameModule(),
            "my-container"))).getDataChildByName(QName.create(myModule.getQNameModule(), "my-list"));

    path = SchemaPath.create(true, QName.create(myModule.getQNameModule(), "my-container"),
            QName.create(myModule.getQNameModule(), "my-list"));
    foundNode = SchemaContextUtil.findNodeInSchemaContext(context, path.getPathFromRoot());

    assertNotNull(testNode);
    assertNotNull(foundNode);
    assertEquals(testNode, foundNode);

}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:66,代码来源:SchemaContextUtilTest.java


注:本文中的org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。