Search in sources :

Example 16 with AnyxmlSchemaNode

use of org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode in project yangtools by opendaylight.

the class IfFeatureResolutionTest method testAllFeaturesSupported.

@Test
public void testAllFeaturesSupported() throws ReactorException {
    final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild().addSources(FOO_MODULE, BAR_MODULE).buildEffective();
    assertNotNull(schemaContext);
    final Module testModule = schemaContext.findModules("foo").iterator().next();
    assertNotNull(testModule);
    assertEquals(11, testModule.getChildNodes().size());
    final ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-a"));
    assertNotNull(testContainerA);
    final LeafSchemaNode testLeafA = (LeafSchemaNode) testContainerA.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-a"));
    assertNotNull(testLeafA);
    final ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-b"));
    assertNotNull(testContainerB);
    final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-b"));
    assertNotNull(testLeafB);
    final ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-c"));
    assertNotNull(testContainerC);
    final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-c"));
    assertNotNull(testLeafC);
    final ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-d"));
    assertNotNull(testContainerD);
    final LeafSchemaNode testLeafD = (LeafSchemaNode) testContainerD.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-d"));
    assertNotNull(testLeafD);
    final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-e"));
    assertNotNull(testContainerE);
    final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
    assertNotNull(testSubContainerE);
    final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-e"));
    assertNotNull(testLeafE);
    final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-f"));
    assertNotNull(testContainerF);
    final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.getDataChildByName(QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
    assertNotNull(testSubContainerF);
    final ContainerSchemaNode testSubSubContainerF = (ContainerSchemaNode) testSubContainerF.getDataChildByName(QName.create(testModule.getQNameModule(), "test-subsubcontainer-f"));
    assertNotNull(testSubSubContainerF);
    final LeafSchemaNode testLeafF = (LeafSchemaNode) testSubSubContainerF.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-f"));
    assertNotNull(testLeafF);
    final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-g"));
    assertNotNull(testContainerG);
    assertEquals(2, testContainerG.getAvailableAugmentations().size());
    final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-g"));
    assertNotNull(testLeafG);
    final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
    assertNotNull(augmentingTestLeafG);
    final AnyxmlSchemaNode augmentingTestAnyxmlG = (AnyxmlSchemaNode) testContainerG.getDataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
    assertNotNull(augmentingTestAnyxmlG);
    final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-h"));
    assertNotNull(testContainerH);
    assertEquals(1, testContainerH.getUses().size());
    ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerH.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
    assertNotNull(testGroupingSubContainer);
    LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
    assertNotNull(testGroupingLeaf);
    final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-i"));
    assertNotNull(testContainerI);
    assertEquals(1, testContainerI.getUses().size());
    testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
    assertNotNull(testGroupingSubContainer);
    testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
    assertNotNull(testGroupingLeaf);
    final ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-j"));
    assertNotNull(testContainerJ);
    final LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-j"));
    assertNotNull(testLeafJ);
    final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-k"));
    assertNotNull(testContainerK);
    assertEquals(1, testContainerK.getUses().size());
    testGroupingSubContainer = (ContainerSchemaNode) testContainerK.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
    assertNotNull(testGroupingSubContainer);
    assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
    final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
    assertNotNull(augmentingTestGroupingLeaf);
    final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
    assertNotNull(augmentingTestGroupingLeaf2);
    testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
    assertNotNull(testGroupingLeaf);
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) Module(org.opendaylight.yangtools.yang.model.api.Module) AnyxmlSchemaNode(org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode) Test(org.junit.Test)

Example 17 with AnyxmlSchemaNode

use of org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode in project yangtools by opendaylight.

the class IfFeatureResolutionTest method testNoFeaturesSupported.

@Test
public void testNoFeaturesSupported() throws ReactorException {
    final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild().addSources(FOO_MODULE, BAR_MODULE).setSupportedFeatures(ImmutableSet.of()).buildEffective();
    assertNotNull(schemaContext);
    final Module testModule = schemaContext.findModules("foo").iterator().next();
    assertNotNull(testModule);
    assertEquals(6, testModule.getChildNodes().size());
    final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-e"));
    assertNotNull(testContainerE);
    final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
    assertNotNull(testSubContainerE);
    final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.dataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-e"));
    assertNull(testLeafE);
    final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-f"));
    assertNotNull(testContainerF);
    final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.dataChildByName(QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
    assertNull(testSubContainerF);
    final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-g"));
    assertNotNull(testContainerG);
    assertEquals(1, testContainerG.getAvailableAugmentations().size());
    final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-g"));
    assertNotNull(testLeafG);
    final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.dataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
    assertNull(augmentingTestLeafG);
    final AnyxmlSchemaNode augmentingTestAnyxmlG = (AnyxmlSchemaNode) testContainerG.getDataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
    assertNotNull(augmentingTestAnyxmlG);
    final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-h"));
    assertNotNull(testContainerH);
    assertEquals(0, testContainerH.getChildNodes().size());
    assertEquals(0, testContainerH.getUses().size());
    final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-i"));
    assertNotNull(testContainerI);
    assertEquals(1, testContainerI.getUses().size());
    ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
    assertNotNull(testGroupingSubContainer);
    LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
    assertNull(testGroupingLeaf);
    final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-k"));
    assertNotNull(testContainerK);
    assertEquals(1, testContainerK.getUses().size());
    testGroupingSubContainer = (ContainerSchemaNode) testContainerK.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
    assertNotNull(testGroupingSubContainer);
    assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
    final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
    assertNull(augmentingTestGroupingLeaf);
    final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
    assertNull(augmentingTestGroupingLeaf2);
    testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
    assertNull(testGroupingLeaf);
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) Module(org.opendaylight.yangtools.yang.model.api.Module) AnyxmlSchemaNode(org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode) Test(org.junit.Test)

Example 18 with AnyxmlSchemaNode

use of org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode in project yangtools by opendaylight.

the class IfFeatureResolutionTest method testSomeFeaturesSupported.

@Test
public void testSomeFeaturesSupported() throws ReactorException {
    final Set<QName> supportedFeatures = ImmutableSet.of(QName.create("foo-namespace", "test-feature-1"), QName.create("foo-namespace", "test-feature-2"), QName.create("foo-namespace", "test-feature-3"), QName.create("bar-namespace", "imp-feature"));
    final SchemaContext schemaContext = RFC7950Reactors.defaultReactor().newBuild().addSources(FOO_MODULE, BAR_MODULE).setSupportedFeatures(supportedFeatures).buildEffective();
    assertNotNull(schemaContext);
    final Module testModule = schemaContext.findModule("foo").get();
    assertEquals(9, testModule.getChildNodes().size());
    final ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.dataChildByName(QName.create(testModule.getQNameModule(), "test-container-a"));
    assertNull(testContainerA);
    final ContainerSchemaNode testContainerB = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-b"));
    assertNotNull(testContainerB);
    final LeafSchemaNode testLeafB = (LeafSchemaNode) testContainerB.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-b"));
    assertNotNull(testLeafB);
    final ContainerSchemaNode testContainerC = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-c"));
    assertNotNull(testContainerC);
    final LeafSchemaNode testLeafC = (LeafSchemaNode) testContainerC.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-c"));
    assertNotNull(testLeafC);
    final ContainerSchemaNode testContainerD = (ContainerSchemaNode) testModule.dataChildByName(QName.create(testModule.getQNameModule(), "test-container-d"));
    assertNull(testContainerD);
    final ContainerSchemaNode testContainerE = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-e"));
    assertNotNull(testContainerE);
    final ContainerSchemaNode testSubContainerE = (ContainerSchemaNode) testContainerE.getDataChildByName(QName.create(testModule.getQNameModule(), "test-subcontainer-e"));
    assertNotNull(testSubContainerE);
    final LeafSchemaNode testLeafE = (LeafSchemaNode) testSubContainerE.dataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-e"));
    assertNull(testLeafE);
    final ContainerSchemaNode testContainerF = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-f"));
    assertNotNull(testContainerF);
    final ContainerSchemaNode testSubContainerF = (ContainerSchemaNode) testContainerF.dataChildByName(QName.create(testModule.getQNameModule(), "test-subcontainer-f"));
    assertNull(testSubContainerF);
    final ContainerSchemaNode testContainerG = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-g"));
    assertNotNull(testContainerG);
    assertEquals(1, testContainerG.getAvailableAugmentations().size());
    final LeafSchemaNode testLeafG = (LeafSchemaNode) testContainerG.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-g"));
    assertNotNull(testLeafG);
    final LeafSchemaNode augmentingTestLeafG = (LeafSchemaNode) testContainerG.dataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-leaf-g"));
    assertNull(augmentingTestLeafG);
    final AnyxmlSchemaNode augmentingTestAnyxmlG = (AnyxmlSchemaNode) testContainerG.getDataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-anyxml-g"));
    assertNotNull(augmentingTestAnyxmlG);
    final ContainerSchemaNode testContainerH = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-h"));
    assertNotNull(testContainerH);
    assertEquals(0, testContainerH.getChildNodes().size());
    assertEquals(0, testContainerH.getUses().size());
    final ContainerSchemaNode testContainerI = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-i"));
    assertNotNull(testContainerI);
    assertEquals(1, testContainerI.getUses().size());
    ContainerSchemaNode testGroupingSubContainer = (ContainerSchemaNode) testContainerI.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
    assertNotNull(testGroupingSubContainer);
    final LeafSchemaNode testGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-leaf"));
    assertNull(testGroupingLeaf);
    final ContainerSchemaNode testContainerJ = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-j"));
    assertNotNull(testContainerJ);
    final LeafSchemaNode testLeafJ = (LeafSchemaNode) testContainerJ.getDataChildByName(QName.create(testModule.getQNameModule(), "test-leaf-j"));
    assertNotNull(testLeafJ);
    final ContainerSchemaNode testContainerK = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "test-container-k"));
    assertNotNull(testContainerK);
    assertEquals(1, testContainerK.getUses().size());
    testGroupingSubContainer = (ContainerSchemaNode) testContainerK.getDataChildByName(QName.create(testModule.getQNameModule(), "test-grouping-subcontainer"));
    assertNotNull(testGroupingSubContainer);
    assertEquals(1, testGroupingSubContainer.getAvailableAugmentations().size());
    final LeafSchemaNode augmentingTestGroupingLeaf = (LeafSchemaNode) testGroupingSubContainer.getDataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf"));
    assertNotNull(augmentingTestGroupingLeaf);
    final LeafSchemaNode augmentingTestGroupingLeaf2 = (LeafSchemaNode) testGroupingSubContainer.dataChildByName(QName.create(testModule.getQNameModule(), "augmenting-test-grouping-leaf-2"));
    assertNull(augmentingTestGroupingLeaf2);
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) Module(org.opendaylight.yangtools.yang.model.api.Module) AnyxmlSchemaNode(org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode) Test(org.junit.Test)

Example 19 with AnyxmlSchemaNode

use of org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode in project yangtools by opendaylight.

the class XmlParserStream method parse.

/**
 * This method parses the XML source and emits node events into a NormalizedNodeStreamWriter based on the
 * YANG-modeled data contained in the XML source.
 *
 * @param reader
 *              StAX reader which is to used to walk through the XML source
 * @return
 *              instance of XmlParserStream
 * @throws XMLStreamException
 *              if a well-formedness error or an unexpected processing condition occurs while parsing the XML
 * @throws URISyntaxException
 *              if the namespace URI of an XML element contains a syntax error
 * @throws IOException
 *              if an error occurs while parsing the value of an anyxml node
 * @throws SAXException
 *              if an error occurs while parsing the value of an anyxml node
 */
public XmlParserStream parse(final XMLStreamReader reader) throws XMLStreamException, URISyntaxException, IOException, SAXException {
    if (reader.hasNext()) {
        reader.nextTag();
        final AbstractNodeDataWithSchema<?> nodeDataWithSchema;
        if (parentNode instanceof ContainerLike) {
            nodeDataWithSchema = new ContainerNodeDataWithSchema((ContainerLike) parentNode);
        } else if (parentNode instanceof ListSchemaNode) {
            nodeDataWithSchema = new ListNodeDataWithSchema((ListSchemaNode) parentNode);
        } else if (parentNode instanceof AnyxmlSchemaNode) {
            nodeDataWithSchema = new AnyXmlNodeDataWithSchema((AnyxmlSchemaNode) parentNode);
        } else if (parentNode instanceof LeafSchemaNode) {
            nodeDataWithSchema = new LeafNodeDataWithSchema((LeafSchemaNode) parentNode);
        } else if (parentNode instanceof LeafListSchemaNode) {
            nodeDataWithSchema = new LeafListNodeDataWithSchema((LeafListSchemaNode) parentNode);
        } else if (parentNode instanceof AnydataSchemaNode) {
            nodeDataWithSchema = new AnydataNodeDataWithSchema((AnydataSchemaNode) parentNode);
        } else {
            throw new IllegalStateException("Unsupported schema node type " + parentNode.getClass() + ".");
        }
        read(reader, nodeDataWithSchema, reader.getLocalName());
        nodeDataWithSchema.write(writer);
    }
    return this;
}
Also used : ContainerLike(org.opendaylight.yangtools.yang.model.api.ContainerLike) LeafListNodeDataWithSchema(org.opendaylight.yangtools.yang.data.util.LeafListNodeDataWithSchema) ListNodeDataWithSchema(org.opendaylight.yangtools.yang.data.util.ListNodeDataWithSchema) LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) AnydataNodeDataWithSchema(org.opendaylight.yangtools.yang.data.util.AnydataNodeDataWithSchema) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) LeafNodeDataWithSchema(org.opendaylight.yangtools.yang.data.util.LeafNodeDataWithSchema) ContainerNodeDataWithSchema(org.opendaylight.yangtools.yang.data.util.ContainerNodeDataWithSchema) AnyxmlSchemaNode(org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode) LeafListNodeDataWithSchema(org.opendaylight.yangtools.yang.data.util.LeafListNodeDataWithSchema) ListSchemaNode(org.opendaylight.yangtools.yang.model.api.ListSchemaNode) LeafListSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode) AnydataSchemaNode(org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode) AnyXmlNodeDataWithSchema(org.opendaylight.yangtools.yang.data.util.AnyXmlNodeDataWithSchema)

Example 20 with AnyxmlSchemaNode

use of org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode in project yangtools by opendaylight.

the class XmlParserStream method translateValueByType.

private Object translateValueByType(final Object value, final DataSchemaNode node, final NamespaceContext namespaceCtx) {
    if (node instanceof AnyxmlSchemaNode) {
        checkArgument(value instanceof Document);
        /*
             * FIXME: Figure out some YANG extension dispatch, which will reuse JSON parsing or XML parsing -
             *        anyxml is not well-defined in JSON.
             */
        return new DOMSource(((Document) value).getDocumentElement());
    }
    if (node instanceof AnydataSchemaNode) {
        checkArgument(value instanceof Document);
        return new DOMSourceAnydata(new DOMSource(((Document) value).getDocumentElement()));
    }
    checkArgument(node instanceof TypedDataSchemaNode);
    checkArgument(value instanceof String);
    return codecs.codecFor((TypedDataSchemaNode) node, stack).parseValue(namespaceCtx, (String) value);
}
Also used : TypedDataSchemaNode(org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode) DOMSource(javax.xml.transform.dom.DOMSource) Document(org.w3c.dom.Document) AnydataSchemaNode(org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode) AnyxmlSchemaNode(org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode)

Aggregations

AnyxmlSchemaNode (org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode)22 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)15 Test (org.junit.Test)13 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)13 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)12 AnydataSchemaNode (org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode)10 ChoiceSchemaNode (org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode)10 Module (org.opendaylight.yangtools.yang.model.api.Module)10 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)8 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)7 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)6 CaseSchemaNode (org.opendaylight.yangtools.yang.model.api.CaseSchemaNode)5 AugmentationSchemaNode (org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode)4 GroupingDefinition (org.opendaylight.yangtools.yang.model.api.GroupingDefinition)4 DataNodeContainer (org.opendaylight.yangtools.yang.model.api.DataNodeContainer)3 TypedDataSchemaNode (org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)2 QName (org.opendaylight.yangtools.yang.common.QName)2 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)2