org.opendaylight.controller.netconf.util.xml.XmlElement.getOnlyChildElementWithSameNamespaceOptionally()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getOnlyChildElementWithSameNamespaceOptionally()方法的一些代码示例,展示了XmlElement.getOnlyChildElementWithSameNamespaceOptionally()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlElement.getOnlyChildElementWithSameNamespaceOptionally()方法的具体详情如下:
包路径:org.opendaylight.controller.netconf.util.xml.XmlElement
类名称:XmlElement
方法名:getOnlyChildElementWithSameNamespaceOptionally

XmlElement.getOnlyChildElementWithSameNamespaceOptionally介绍

暂无

代码示例

代码示例来源:origin: org.opendaylight.controller/netconf-notifications-impl

private static StreamNameType parseStreamIfPresent(final XmlElement operationElement) throws NetconfDocumentedException {
  final Optional<XmlElement> stream = operationElement.getOnlyChildElementWithSameNamespaceOptionally("stream");
  return stream.isPresent() ? new StreamNameType(stream.get().getTextContent()) : NetconfNotificationManager.BASE_STREAM_NAME;
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

public static Collection<String> extractCapabilitiesFromHello(Document doc) throws NetconfDocumentedException {
    XmlElement responseElement = XmlElement.fromDomDocument(doc);
    // Extract child element <capabilities> from <hello> with or without(fallback) the same namespace
    Optional<XmlElement> capabilitiesElement = responseElement
        .getOnlyChildElementWithSameNamespaceOptionally(XmlNetconfConstants.CAPABILITIES)
        .or(responseElement
            .getOnlyChildElementOptionally(XmlNetconfConstants.CAPABILITIES));

    List<XmlElement> caps = capabilitiesElement.get().getChildElements(XmlNetconfConstants.CAPABILITY);
    return Collections2.transform(caps, new Function<XmlElement, String>() {

      @Override
      public String apply(@Nonnull XmlElement input) {
        // Trim possible leading/tailing whitespace
        try {
          return input.getTextContent().trim();
        } catch (NetconfDocumentedException e) {
          LOG.trace("Error fetching input text content",e);
          return null;
        }
      }
    });

  }
}

代码示例来源:origin: org.opendaylight.controller/netconf-notifications-impl

@Override
protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws NetconfDocumentedException {
  operationElement.checkName(CREATE_SUBSCRIPTION);
  operationElement.checkNamespace(CreateSubscriptionInput.QNAME.getNamespace().toString());
  // FIXME reimplement using CODEC_REGISTRY and parse everything into generated class instance
  // Waiting ofr https://git.opendaylight.org/gerrit/#/c/13763/
  // FIXME filter could be supported same way as netconf server filters get and get-config results
  final Optional<XmlElement> filter = operationElement.getOnlyChildElementWithSameNamespaceOptionally("filter");
  Preconditions.checkArgument(filter.isPresent() == false, "Filter element not yet supported");
  // Replay not supported
  final Optional<XmlElement> startTime = operationElement.getOnlyChildElementWithSameNamespaceOptionally("startTime");
  Preconditions.checkArgument(startTime.isPresent() == false, "StartTime element not yet supported");
  // Stop time not supported
  final Optional<XmlElement> stopTime = operationElement.getOnlyChildElementWithSameNamespaceOptionally("stopTime");
  Preconditions.checkArgument(stopTime.isPresent() == false, "StopTime element not yet supported");
  final StreamNameType streamNameType = parseStreamIfPresent(operationElement);
  Preconditions.checkNotNull(netconfSession);
  // Premature streams are allowed (meaning listener can register even if no provider is available yet)
  if(notifications.isStreamAvailable(streamNameType) == false) {
    LOG.warn("Registering premature stream {}. No publisher available yet for session {}", streamNameType, getNetconfSessionIdForReporting());
  }
  final NotificationListenerRegistration notificationListenerRegistration =
      notifications.registerNotificationListener(streamNameType, new NotificationSubscription(netconfSession));
  subscriptions.add(notificationListenerRegistration);
  return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
}

代码示例来源:origin: org.opendaylight.controller/config-netconf-connector

.getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.TEST_OPTION_KEY);
if (testOptionElementOpt.isPresent()) {
  String testOptionValue = testOptionElementOpt.get().getTextContent();
    .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.ERROR_OPTION_KEY);
if (errorOptionElement.isPresent()) {
  String errorOptionParsed = errorOptionElement.get().getTextContent();
    .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.DEFAULT_OPERATION_KEY);
if (defaultContent.isPresent()) {
  String mergeStrategyString = defaultContent.get().getTextContent();

代码示例来源:origin: org.opendaylight.controller/sal-netconf-connector

Preconditions.checkArgument(XmlElement.fromDomDocument(message.getDocument()).getOnlyChildElementWithSameNamespaceOptionally("ok").isPresent(),
    "Unexpected content in response of rpc: %s, %s", rpcDefinition.getQName(), message);
normalizedNode = null;

相关文章