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


Java QName类代码示例

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


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

示例1: executeList

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Override
public void executeList() {
    final LogicalDatastoreType dsType = getDataStoreType();
    final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
    final YangInstanceIdentifier pid =
            YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();

    try (DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction()) {
        for (int l = 0; l < outerListElem; l++) {
            YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
            Optional<NormalizedNode<?,?>> optionalDataObject;
            CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> submitFuture = tx.read(dsType, yid);
            try {
                optionalDataObject = submitFuture.checkedGet();
                if (optionalDataObject != null && optionalDataObject.isPresent()) {
                    txOk++;
                }
            } catch (final ReadFailedException e) {
                LOG.warn("failed to ....", e);
                txError++;
            }
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:25,代码来源:TxchainDomRead.java

示例2: resolveIdentity

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Override
public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final IdentityAttributeRef identityRef,
        final Class<T> expectedBaseClass) {
    final QName qName = QName.create(identityRef.getqNameOfIdentity());
    final Class<?> deserialized = this.bindingContextProvider.getBindingContext().getIdentityClass(qName);
    if (deserialized == null) {
        throw new IllegalStateException("Unable to retrieve identity class for " + qName + ", null response from "
                + this.bindingContextProvider.getBindingContext());
    }
    if (expectedBaseClass.isAssignableFrom(deserialized)) {
        return (Class<T>) deserialized;
    }
    LOG.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.", identityRef,
            deserialized, expectedBaseClass);
    throw new IllegalArgumentException(
            "Deserialized identity " + deserialized + " cannot be cast to " + expectedBaseClass);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:DependencyResolverImpl.java

示例3: testReadingIdentities_threadsJavaModule

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Test
public void testReadingIdentities_threadsJavaModule() {
    Map<String /* identity name */, Optional<QName>> expectedIdentitiesToBases = new HashMap<String, Optional<QName>>(){
        private static final long serialVersionUID = 1L;

        {
            put(ModuleMXBeanEntryTest.EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
            put(ModuleMXBeanEntryTest.ASYNC_EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
            put(ModuleMXBeanEntryTest.THREADFACTORY_NAMING_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
            put(ModuleMXBeanEntryTest.THREADPOOL_DYNAMIC_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
            put("thread-rpc-context", Optional.<QName>absent());
            put(ModuleMXBeanEntryTest.THREADPOOL_REGISTRY_IMPL_NAME, Optional.of(MODULE_TYPE_Q_NAME));
        }
    };

    assertAllIdentitiesAreExpected(threadsJavaModule,
            expectedIdentitiesToBases);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:SchemaContextTest.java

示例4: mapAttribute

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Override
public Optional<MappedDependency> mapAttribute(final Object value) {
    if (value == null) {
        return Optional.absent();
    }

    String expectedClass = getOpenType().getClassName();
    String realClass = value.getClass().getName();
    Preconditions.checkArgument(realClass.equals(expectedClass),
            "Type mismatch, expected " + expectedClass + " but was " + realClass);
    Util.checkType(value, ObjectName.class);

    ObjectName on = (ObjectName) value;

    String refName = ObjectNameUtil.getReferenceName(on);

    // we want to use the exact service name that was configured in xml so services
    // that are referencing it can be resolved
    return Optional.of(new MappedDependency(namespace,
            QName.create(ObjectNameUtil.getServiceQName(on)).getLocalName(), refName));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:ObjectNameAttributeMappingStrategy.java

示例5: getModuleSource

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Override
public String getModuleSource(final org.opendaylight.yangtools.yang.model.api.ModuleIdentifier moduleIdentifier) {
    final CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> source = this.sourceProvider
            .getSource(SourceIdentifier.create(moduleIdentifier.getName(),
                    Optional.fromNullable(QName.formattedRevision(moduleIdentifier.getRevision()))));

    try {
        final YangTextSchemaSource yangTextSchemaSource = source.checkedGet();
        try (InputStream inStream = yangTextSchemaSource.openStream()) {
            return new String(ByteStreams.toByteArray(inStream), StandardCharsets.UTF_8);
        }
    } catch (SchemaSourceException | IOException e) {
        LOG.warn("Unable to provide source for {}", moduleIdentifier, e);
        throw new IllegalArgumentException("Unable to provide source for " + moduleIdentifier, e);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:YangStoreSnapshot.java

示例6: ChoiceNodeNormalization

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
protected ChoiceNodeNormalization(final ChoiceSchemaNode schema) {
    super(new NodeIdentifier(schema.getQName()),schema);
    final ImmutableMap.Builder<QName, DataNormalizationOperation<?>> byQNameBuilder = ImmutableMap.builder();
    final ImmutableMap.Builder<PathArgument, DataNormalizationOperation<?>> byArgBuilder = ImmutableMap.builder();

    for (final ChoiceCaseNode caze : schema.getCases()) {
        for (final DataSchemaNode cazeChild : caze.getChildNodes()) {
            final DataNormalizationOperation<?> childOp = fromDataSchemaNode(cazeChild);
            byArgBuilder.put(childOp.getIdentifier(), childOp);
            for (final QName qname : childOp.getQNameIdentifiers()) {
                byQNameBuilder.put(qname, childOp);
            }
        }
    }
    byQName = byQNameBuilder.build();
    byArg = byArgBuilder.build();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:DataNormalizationOperation.java

示例7: testSendSliceableMessageRequest

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testSendSliceableMessageRequest() {
    final ClientActorConfig config = AccessClientUtil.newMockClientActorConfig();
    doReturn(5).when(config).getMaximumMessageSliceSize();
    context = new ClientActorContext(contextProbe.ref(), PERSISTENCE_ID, system, CLIENT_ID, config);
    connection = createConnection();

    final Consumer<Response<?, ?>> callback = mock(Consumer.class);

    final TransactionIdentifier identifier =
            new TransactionIdentifier(new LocalHistoryIdentifier(CLIENT_ID, 0L), 0L);
    ModifyTransactionRequestBuilder reqBuilder =
            new ModifyTransactionRequestBuilder(identifier, replyToProbe.ref());
    reqBuilder.addModification(new TransactionWrite(YangInstanceIdentifier.EMPTY, Builders.containerBuilder()
            .withNodeIdentifier(YangInstanceIdentifier.NodeIdentifier.create(
                    QName.create("namespace", "localName"))).build()));
    reqBuilder.setSequence(0L);
    final Request<?, ?> request = reqBuilder.build();
    connection.sendRequest(request, callback);

    backendProbe.expectMsgClass(MessageSlice.class);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:ConnectedClientConnectionTest.java

示例8: testOnEntityOwnershipChangedWithListenerEx

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Test
public void testOnEntityOwnershipChangedWithListenerEx() {
    DOMEntityOwnershipListener mockListener = mock(DOMEntityOwnershipListener.class);

    DOMEntity entity1 = new DOMEntity("test", YangInstanceIdentifier.of(QName.create("test", "id1")));
    doThrow(new RuntimeException("mock")).when(mockListener).ownershipChanged(
            ownershipChange(entity1, false, true, true));
    DOMEntity entity2 = new DOMEntity("test", YangInstanceIdentifier.of(QName.create("test", "id2")));
    doNothing().when(mockListener).ownershipChanged(ownershipChange(entity2, true, false, false));

    TestActorRef<EntityOwnershipListenerActor> listenerActor = actorFactory.createTestActor(
            EntityOwnershipListenerActor.props(mockListener), actorFactory.generateActorId("listener"));

    listenerActor.tell(new DOMEntityOwnershipChange(entity1, EntityOwnershipChangeState.from(
            false, true, true)), ActorRef.noSender());
    listenerActor.tell(new DOMEntityOwnershipChange(entity2, EntityOwnershipChangeState.from(
            true, false, false)), ActorRef.noSender());

    verify(mockListener, timeout(5000)).ownershipChanged(ownershipChange(entity2, true, false, false));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:EntityOwnershipListenerActorTest.java

示例9: getMapEntryNodeChild

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
protected MapEntryNode getMapEntryNodeChild(DataContainerNode<? extends PathArgument> parent, QName childMap,
        QName child, Object key, boolean expectPresent) {
    Optional<DataContainerChild<? extends PathArgument, ?>> childNode =
            parent.getChild(new NodeIdentifier(childMap));
    assertEquals("Missing " + childMap.toString(), true, childNode.isPresent());

    MapNode entityTypeMapNode = (MapNode) childNode.get();
    Optional<MapEntryNode> entityTypeEntry = entityTypeMapNode.getChild(new NodeIdentifierWithPredicates(
            childMap, child, key));
    if (expectPresent && !entityTypeEntry.isPresent()) {
        fail("Missing " + childMap.toString() + " entry for " + key + ". Actual: " + entityTypeMapNode.getValue());
    } else if (!expectPresent && entityTypeEntry.isPresent()) {
        fail("Found unexpected " + childMap.toString() + " entry for " + key);
    }

    return entityTypeEntry.isPresent() ? entityTypeEntry.get() : null;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:AbstractEntityOwnershipTest.java

示例10: normalizedNodeToJsonStreamTransformation

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
/**
 * Returns a Normalized Node as a JSON String
 * @param writer - Writer to use
 * @param scPath - Schema Context Path for the Normalized Node
 * @param inputStructure - A Normalized Node
 * @return a String representing the Normalized Node
 * @throws IOException - if an error was encountered when writing the string
 */
public String normalizedNodeToJsonStreamTransformation(final Writer writer,
        SchemaPath scPath,
        final NormalizedNode<?, ?> inputStructure) throws IOException {
	QName lastcomp = scPath.getLastComponent();
	URI ns = lastcomp.getNamespace();
    final NormalizedNodeStreamWriter jsonStream = JSONNormalizedNodeStreamWriter.
            createExclusiveWriter(JSONCodecFactory.create(context), scPath, scPath.getLastComponent().getNamespace(),
                JsonWriterFactory.createJsonWriter(writer));
    final NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(jsonStream);
    nodeWriter.write(inputStructure);

    nodeWriter.close();
    return writer.toString();
}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:23,代码来源:FpcCodecUtils.java

示例11: addKeyValue

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
/**
 * Adds a Key Value to the map for a specific uri value.
 * @param map - current QName to Object mapping
 * @param node - DataSchemaNode
 * @param uriValue - uri value to add
 * @throws Exception if error occurs during Uri decoding.
 */
private void addKeyValue(final HashMap<QName, Object> map, final DataSchemaNode node, final String uriValue)
        throws Exception {
    Preconditions.checkNotNull(uriValue);
    Preconditions.checkArgument((node instanceof LeafSchemaNode));

    final String urlDecoded = urlPathArgDecode(uriValue);
    TypeDefinition<?> typedef = ((LeafSchemaNode) node).getType();
    final TypeDefinition<?> baseType = resolveBaseTypeFrom(typedef);
    if (baseType instanceof LeafrefTypeDefinition) {
        typedef = SchemaContextUtil.getBaseTypeForLeafRef((LeafrefTypeDefinition) baseType, globalSchema, node);
    }

    Object decoded = deserialize(typedef, urlDecoded);
    String additionalInfo = "";
    if (decoded == null) {
        if ((baseType instanceof IdentityrefTypeDefinition)) {
            decoded = toQName(urlDecoded);
            additionalInfo = "For key which is of type identityref it should be in format module_name:identity_name.";
        }
    }

    if (decoded == null) {
        throw new Exception(uriValue + " from URI can't be resolved. " + additionalInfo);
    }

    map.put(node.getQName(), decoded);
}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:35,代码来源:NameResolver.java

示例12: toQName

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
/**
 * Returns the QName of a string
 * @param name - string containing the module and node name
 * @return QName of the string or null if no module could be found for the input
 */
private QName toQName(final String name) {
    if (globalSchema == null) {
        return null;
    }
    final String module = toModuleName(name);
    final String node = toNodeName(name);
    final Module m = globalSchema.findModuleByName(module, null);
    return m == null ? null : QName.create(m.getQNameModule(), node);
}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:15,代码来源:NameResolver.java

示例13: executeList

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Override
public void executeList() {
    final LogicalDatastoreType dsType = getDataStoreType();
    final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
    final YangInstanceIdentifier pid =
            YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();

    try (DOMDataReadOnlyTransaction tx = domDataBroker.newReadOnlyTransaction()) {
        for (int l = 0; l < outerListElem; l++) {
            YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, olId, l));
            CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> submitFuture = tx.read(dsType, yid);
            try {
                Optional<NormalizedNode<?,?>> optionalDataObject = submitFuture.checkedGet();
                if (optionalDataObject != null && optionalDataObject.isPresent()) {
                    NormalizedNode<?, ?> ret = optionalDataObject.get();
                    LOG.trace("optionalDataObject is {}", ret);
                    txOk++;
                } else {
                    txError++;
                    LOG.warn("optionalDataObject is either null or .isPresent is false");
                }
            } catch (final ReadFailedException e) {
                LOG.warn("failed to ....", e);
                txError++;
            }
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:29,代码来源:SimpletxDomRead.java

示例14: testNormalizedNodeStreaming

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
@Test
public void testNormalizedNodeStreaming() throws IOException {

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos));

    NormalizedNode<?, ?> testContainer = createTestContainer();
    nnout.writeNormalizedNode(testContainer);

    QName toaster = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","toaster");
    QName darknessFactor = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","darknessFactor");
    QName description = QName.create("http://netconfcentral.org/ns/toaster","2009-11-20","description");
    ContainerNode toasterNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(toaster))
            .withChild(ImmutableNodes.leafNode(darknessFactor, "1000"))
            .withChild(ImmutableNodes.leafNode(description, largeString(20))).build();

    ContainerNode toasterContainer = Builders.containerBuilder()
            .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)).withChild(toasterNode).build();
    nnout.writeNormalizedNode(toasterContainer);

    NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(
        bos.toByteArray()));

    NormalizedNode<?,?> node = nnin.readNormalizedNode();
    Assert.assertEquals(testContainer, node);

    node = nnin.readNormalizedNode();
    Assert.assertEquals(toasterContainer, node);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:30,代码来源:NormalizedNodeStreamReaderWriterTest.java

示例15: NameConflictException

import org.opendaylight.yangtools.yang.common.QName; //导入依赖的package包/类
public NameConflictException(String conflictingName,
        QName firstDefinedParentQName, QName secondDefinedParentQName) {
    super(String.format(messageBlueprint, conflictingName,
            firstDefinedParentQName, secondDefinedParentQName));
    this.conflictingName = conflictingName;
    this.firstParentQName = firstDefinedParentQName;
    this.secondParentQName = secondDefinedParentQName;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:NameConflictException.java


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