• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java QNameModule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.opendaylight.yangtools.yang.common.QNameModule的典型用法代码示例。如果您正苦于以下问题:Java QNameModule类的具体用法?Java QNameModule怎么用?Java QNameModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QNameModule类属于org.opendaylight.yangtools.yang.common包,在下文中一共展示了QNameModule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: decomposeRpcService

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
static Collection<SchemaPath> decomposeRpcService(final Class<RpcService> service,
        final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
    final QNameModule moduleName = BindingReflections.getQNameModule(service);
    final Module module = schemaContext.findModuleByNamespaceAndRevision(moduleName.getNamespace(),
            moduleName.getRevision());
    LOG.debug("Resolved service {} to module {}", service, module);

    final Collection<RpcDefinition> rpcs = module.getRpcs();
    final Collection<SchemaPath> ret = new ArrayList<>(rpcs.size());
    for (RpcDefinition rpc : rpcs) {
        final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpc);
        if (filter.test(strategy)) {
            ret.add(rpc.getPath());
        }
    }

    return ret;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:RpcUtil.java


示例2: AttributeOperations

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
private AttributeOperations(final QNameModule namespace) {
    this.asPathContainer = new NodeIdentifier(QName.create(namespace, AsPath.QNAME.getLocalName()).intern());
    this.asPathSegments = new NodeIdentifier(QName.create(namespace, Segments.QNAME.getLocalName()).intern());
    this.asPathSequence = new NodeIdentifier(QName.create(namespace, "as-sequence").intern());
    this.asNumberQname = QName.create(namespace, "as-number").intern();

    this.clusterListContainer = new NodeIdentifier(QName.create(namespace, ClusterId.QNAME.getLocalName()).intern());
    this.clusterQname = QName.create(namespace, "cluster").intern();
    this.clusterListLeaf = new NodeIdentifier(this.clusterQname);
    this.clusterListPath = ImmutableList.of(this.clusterListContainer, this.clusterListLeaf);
    this.originatorIdContainer = new NodeIdentifier(QName.create(namespace, OriginatorId.QNAME.getLocalName()).intern());
    this.originatorIdLeaf = new NodeIdentifier(QName.create(namespace, "originator").intern());
    this.originatorIdPath = ImmutableList.of(this.originatorIdContainer, this.originatorIdLeaf);

    this.transitiveLeaf = new NodeIdentifier(QName.create(UnrecognizedAttributes.QNAME, "transitive").intern());
    this.transitiveCollection = TRANSITIVE_CACHE.getUnchecked(namespace);
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:18,代码来源:AttributeOperations.java


示例3: testInvalidNormalizedNodeValueType

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testInvalidNormalizedNodeValueType() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
            "/yang-xpath-functions-test/derived-from-function/foo.yang",
            "/yang-xpath-functions-test/derived-from-function/bar.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("should be QName"));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("bar-prefix", barModule);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToIdrefLeafNode());

    final Function derivedFromFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "derived-from");

    assertFalse(getDerivedFromResult(derivedFromFunction, normalizedNodeContext, "foo-prefix:id-a3"));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:25,代码来源:DerivedFromXPathFunctionTest.java


示例4: create

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
/**
 * Create a prefix {@link Converter} for {@link XPathExpressionException} defined in a particular YANG
 * {@link Module} .Instantiation requires establishing how a module's imports are mapped to actual modules
 * and their namespaces. This information is cached and used for improved lookups.
 *
 * @param ctx A SchemaContext
 * @param module Module in which the XPath is defined
 * @return A new Converter
 */
public static @Nonnull Converter<String, QNameModule> create(final SchemaContext ctx, final Module module) {
    // Always check for null ctx
    requireNonNull(ctx, "Schema context may not be null");

    // Use immutable map builder for detection of duplicates (which should never occur)
    final Builder<String, QNameModule> b = ImmutableBiMap.builder();
    b.put(module.getPrefix(), module.getQNameModule());

    for (ModuleImport i : module.getImports()) {
        final Optional<Module> mod = ctx.findModule(i.getModuleName(), i.getRevision());
        checkArgument(mod.isPresent(), "Unsatisfied import of %s by module %s", i, module);

        b.put(i.getPrefix(), mod.get().getQNameModule());
    }

    return Maps.asConverter(b.build());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:27,代码来源:PrefixConverters.java


示例5: testEnumValueFunction

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testEnumValueFunction() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
            "/yang-xpath-functions-test/enum-value-function/foo.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("major"));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("foo-prefix", fooModule);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToSeverityLeafNode("major"));

    final Function enumValueFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "enum-value");
    final int enumValueResult = (int) enumValueFunction.call(normalizedNodeContext, ImmutableList.of());
    assertEquals(5, enumValueResult);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:24,代码来源:EnumValueXPathFunctionTest.java


示例6: testInvalidNormalizedNodeValueType

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testInvalidNormalizedNodeValueType() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
            "/yang-xpath-functions-test/enum-value-function/foo.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(100));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("foo-prefix", fooModule);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToSeverityLeafNode(100));

    final Function enumValueFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "enum-value");
    final Double enumValueResult = (Double) enumValueFunction.call(normalizedNodeContext, ImmutableList.of());
    assertEquals(Double.NaN, enumValueResult, 0.001);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:24,代码来源:EnumValueXPathFunctionTest.java


示例7: write

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@VisibleForTesting
static void write(@Nonnull final XMLStreamWriter writer, @Nonnull final IdentityrefTypeDefinition type,
                  @Nonnull final Object value, final QNameModule parent) throws XMLStreamException {
    if (value instanceof QName) {
        final QName qname = (QName) value;

        //in case parent is present and same as element namespace write value without namespace
        if (qname.getNamespace().equals(parent.getNamespace())) {
            writer.writeCharacters(qname.getLocalName());
        } else {
            final String ns = qname.getNamespace().toString();
            final String prefix = "x";
            writer.writeNamespace(prefix, ns);
            writer.writeCharacters(prefix + ':' + qname.getLocalName());
        }

    } else {
        LOG.debug("Value of {}:{} is not a QName but {}", type.getQName().getNamespace(),
                type.getQName().getLocalName(), value.getClass());
        writer.writeCharacters(String.valueOf(value));
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:23,代码来源:XMLStreamWriterUtils.java


示例8: setUp

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Before
public void setUp() {
    barModuleQName = QNameModule.create(URI.create("bar"));
    myContainer1 = QName.create(barModuleQName, "my-container-1");
    myLeaf1 = QName.create(barModuleQName, "my-leaf-1");
    myAnyXMLDataBar = QName.create(barModuleQName, "my-anyxml-data");

    fooModuleQName = QNameModule.create(URI.create("foo"));
    myContainer2 = QName.create(fooModuleQName, "my-container-2");
    innerContainer = QName.create(fooModuleQName, "inner-container");
    myLeaf3 = QName.create(fooModuleQName, "my-leaf-3");
    myLeaf2 = QName.create(fooModuleQName, "my-leaf-2");
    myAnyXMLDataFoo = QName.create(fooModuleQName, "my-anyxml-data");

    schemaContext = YangParserTestUtils.parseYangResourceDirectory("/anyxml-support/yang");
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:17,代码来源:YangModeledAnyXMLDeserializationTest.java


示例9: testWriteIdentityRef

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testWriteIdentityRef() throws Exception {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(out);

    writer.writeStartElement("element");
    final QNameModule parent = QNameModule.create(URI.create("parent:uri"), Revision.of("2000-01-01"));
    XMLStreamWriterUtils.write(writer, null, QName.create(parent, "identity"), parent);
    writer.writeEndElement();

    writer.writeStartElement("elementDifferent");
    XMLStreamWriterUtils.write(writer, null, QName.create("different:namespace", "identity"), parent);
    writer.writeEndElement();

    writer.close();
    out.close();

    final String xmlAsString = new String(out.toByteArray()).replaceAll("\\s*", "");
    assertThat(xmlAsString, containsString("element>identity"));

    final Pattern prefixedIdentityPattern = Pattern.compile(".*\"different:namespace\">(.*):identity.*");
    final Matcher matcher = prefixedIdentityPattern.matcher(xmlAsString);
    assertTrue("Xml: " + xmlAsString + " should match: " + prefixedIdentityPattern, matcher.matches());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:25,代码来源:XmlStreamUtilsTest.java


示例10: testInvalidTypeOfCorrespondingSchemaNode

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
    final Set<String> setOfBits = ImmutableSet.of("UP", "PROMISCUOUS");

    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(BitIsSetXPathFunctionTest.class,
            "/yang-xpath-functions-test/bit-is-set-function/foo-invalid.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(setOfBits));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("foo-prefix", fooModule);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToFlagsLeafNode(setOfBits));

    final Function bitIsSetFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "bit-is-set");
    boolean bitIsSetResult = (boolean) bitIsSetFunction.call(normalizedNodeContext, ImmutableList.of("UP"));
    assertFalse(bitIsSetResult);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:26,代码来源:BitIsSetXPathFunctionTest.java


示例11: testDeviationsSupportedInSomeModules

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testDeviationsSupportedInSomeModules() throws Exception {
    final SetMultimap<QNameModule, QNameModule> modulesWithSupportedDeviations =
            ImmutableSetMultimap.<QNameModule, QNameModule>builder()
            .put(foo, bar)
            .put(foo, baz)
            .put(bar, baz)
            .build();

    final ListenableFuture<SchemaContext> lf = createSchemaContext(modulesWithSupportedDeviations, FOO, BAR, BAZ,
            FOOBAR);
    assertTrue(lf.isDone());
    final SchemaContext schemaContext = lf.get();
    assertNotNull(schemaContext);

    assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA)));
    assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB)));
    assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC)));
    assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA)));
    assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB)));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:22,代码来源:SchemaContextFactoryDeviationsTest.java


示例12: testInvalidTypeOfCorrespondingSchemaNode

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
            "/yang-xpath-functions-test/derived-from-function/bar-invalid.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(idC2Identity));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("bar-prefix", barModule);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToIdrefLeafNode());

    final Function derivedFromFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "derived-from");

    assertFalse(getDerivedFromResult(derivedFromFunction, normalizedNodeContext, "some-identity"));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:24,代码来源:DerivedFromXPathFunctionTest.java


示例13: getNamespaceURI

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Override
public String getNamespaceURI(final String prefix) {
    // API-mandated by NamespaceContext
    checkArgument(prefix != null);

    final String uri = uriToPrefix.inverse().get(prefix);
    if (uri != null) {
        return uri;
    }

    if (prefix.isEmpty()) {
        return localNamespaceURI();
    }

    final QNameModule module = StmtContextUtils.getModuleQNameByPrefix(ctx, prefix);
    return module == null ? null : module.getNamespace().toString();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:18,代码来源:StmtNamespaceContext.java


示例14: isDeviationSupported

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
private static boolean isDeviationSupported(final Mutable<DeviateKind, DeviateStatement,
        EffectiveStatement<DeviateKind, DeviateStatement>> deviateStmtCtx,
        final SchemaNodeIdentifier deviationTarget) {
    final SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules = deviateStmtCtx.getFromNamespace(
            ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES);
    if (modulesDeviatedByModules == null) {
        return true;
    }

    final QNameModule currentModule = deviateStmtCtx.getFromNamespace(ModuleCtxToModuleQName.class,
            deviateStmtCtx.getRoot());
    final QNameModule targetModule = deviationTarget.getLastComponent().getModule();

    final Set<QNameModule> deviationModulesSupportedByTargetModule = modulesDeviatedByModules.get(targetModule);
    if (deviationModulesSupportedByTargetModule != null) {
        return deviationModulesSupportedByTargetModule.contains(currentModule);
    }

    return false;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:21,代码来源:AbstractDeviateStatementSupport.java


示例15: adaptArgumentValue

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Override
public Collection<SchemaNodeIdentifier> adaptArgumentValue(
        final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement,
            EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx,
        final QNameModule targetModule) {
    final Builder<SchemaNodeIdentifier> builder = ImmutableSet.builder();
    boolean replaced = false;
    for (final SchemaNodeIdentifier arg : ctx.getStatementArgument()) {
        final QName qname = arg.getLastComponent();
        if (!targetModule.equals(qname.getModule())) {
            final QName newQname = ctx.getFromNamespace(QNameCacheNamespace.class,
                    QName.create(targetModule, qname.getLocalName()));
            builder.add(SchemaNodeIdentifier.SAME.createChild(newQname));
            replaced = true;
        } else {
            builder.add(arg);
        }
    }

    // This makes sure we reuse the collection when a grouping is
    // instantiated in the same module
    return replaced ? builder.build() : ctx.getStatementArgument();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:24,代码来源:KeyStatementSupport.java


示例16: checkContentSimpleTest

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
private static void checkContentSimpleTest(final SchemaContext context) {
    URI yangTypesNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-types");

    final Revision rev20100924 = Revision.of("2010-09-24");
    final Revision rev20130516 = Revision.of("2013-05-16");
    final Revision rev20130715 = Revision.of("2013-07-15");

    final QNameModule yangTypes20100924 = QNameModule.create(yangTypesNS, rev20100924);
    final QNameModule yangTypes20130516 = QNameModule.create(yangTypesNS, rev20130516);
    final QNameModule yangTypes20130715 = QNameModule.create(yangTypesNS, rev20130715);

    final QName dateTimeTypeDef20100924 = QName.create(yangTypes20100924, "date-and-time");
    final QName dateTimeTypeDef20130516 = QName.create(yangTypes20130516, "date-and-time");
    final QName dateTimeTypeDef20130715 = QName.create(yangTypes20130715, "date-and-time");

    Module yangTypesModule20100924 = context.findModule("ietf-yang-types", rev20100924).get();
    Module yangTypesModule20130516 = context.findModule("ietf-yang-types", rev20130516).get();
    Module yangTypesModule20130715 = context.findModule("ietf-yang-types", rev20130715).get();
    assertTrue(findTypeDef(yangTypesModule20100924, dateTimeTypeDef20100924));
    assertTrue(findTypeDef(yangTypesModule20130516, dateTimeTypeDef20130516));
    assertTrue(findTypeDef(yangTypesModule20130715, dateTimeTypeDef20130715));

    checkNetconfMonitoringModuleSimpleTest(context, rev20130715, dateTimeTypeDef20130715);
    checkInterfacesModuleSimpleTest(context, rev20100924, dateTimeTypeDef20100924);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:26,代码来源:MoreRevisionsTest.java


示例17: checkInterfacesModuleSimpleTest

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
private static void checkInterfacesModuleSimpleTest(final SchemaContext context,
        final Revision rev20100924, final QName dateTimeTypeDef20100924) {
    URI interfacesNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-interfaces");
    Revision rev20121115 = Revision.of("2012-11-15");
    final QNameModule interfacesNS20121115 = QNameModule.create(interfacesNS, rev20121115);
    QName lastChange = QName.create(interfacesNS20121115, "last-change");

    Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get();
    DataSchemaNode leafLastChange = interfacesModule20121115.getDataChildByName(lastChange);
    assertNotNull(leafLastChange);

    assertTrue(leafLastChange instanceof LeafSchemaNode);
    QName lastChangeTypeQName = ((LeafSchemaNode) leafLastChange).getType().getQName();
    assertEquals(dateTimeTypeDef20100924, lastChangeTypeQName);

    Set<ModuleImport> imports = interfacesModule20121115.getImports();
    assertEquals(1, imports.size());
    ModuleImport interfacesImport = imports.iterator().next();
    assertEquals("ietf-yang-types", interfacesImport.getModuleName());
    assertEquals(Optional.of(rev20100924), interfacesImport.getRevision());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:22,代码来源:MoreRevisionsTest.java


示例18: test

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void test() throws Exception {
    final SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug2872");
    assertNotNull(schema);

    final QNameModule bug2872module = QNameModule.create(URI.create("bug2872"), Revision.of("2016-06-08"));
    final QName foo = QName.create(bug2872module, "bar");

    final DataSchemaNode dataSchemaNode = schema.getDataChildByName(foo);
    assertTrue(dataSchemaNode instanceof LeafSchemaNode);
    final LeafSchemaNode myLeaf = (LeafSchemaNode) dataSchemaNode;

    final TypeDefinition<?> type = myLeaf.getType();
    assertTrue(type instanceof EnumTypeDefinition);
    final EnumTypeDefinition myEnum = (EnumTypeDefinition) type;

    final List<EnumTypeDefinition.EnumPair> values = myEnum.getValues();
    assertEquals(2, values.size());

    final List<String> valueNames = new ArrayList<>();
    for (EnumTypeDefinition.EnumPair pair : values) {
        valueNames.add(pair.getName());
    }
    assertTrue(valueNames.contains("value-one"));
    assertTrue(valueNames.contains("value-two"));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:27,代码来源:Bug2872Test.java


示例19: test

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的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


示例20: testInvalidTypeOfCorrespondingSchemaNode

import org.opendaylight.yangtools.yang.common.QNameModule; //导入依赖的package包/类
@Test
public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
            "/yang-xpath-functions-test/enum-value-function/foo-invalid.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("major"));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("foo-prefix", fooModule);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToSeverityLeafNode("major"));

    final Function enumValueFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "enum-value");
    final Double enumValueResult = (Double) enumValueFunction.call(normalizedNodeContext, ImmutableList.of());
    assertEquals(Double.NaN, enumValueResult, 0.001);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:24,代码来源:EnumValueXPathFunctionTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ItemIdValue类代码示例发布时间:2022-05-22
下一篇:
Java RequestFinishHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap