gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-21 02:19:05 25 4
gpt4 key购买 nike

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

XmlElement.fromDomDocument介绍

暂无

代码示例

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

public static boolean isOKMessage(Document document) throws NetconfDocumentedException {
  return isOKMessage(XmlElement.fromDomDocument(document));
}

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

public static boolean isErrorMessage(Document document) throws NetconfDocumentedException {
  return isErrorMessage(XmlElement.fromDomDocument(document));
}

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

public static Document checkIsMessageOk(Document response) throws DocumentedException {
  XmlElement element = XmlElement.fromDomDocument(response);
  Preconditions.checkState(element.getName().equals(XmlMappingConstants.RPC_REPLY_KEY));
  element = element.getOnlyChildElement();
  if (element.getName().equals(XmlNetconfConstants.OK)) {
    return response;
  }
  LOG.warn("Can not load last configuration. Operation failed.");
  throw new IllegalStateException("Can not load last configuration. Operation failed: "
      + XmlUtil.toString(response));
}

代码示例来源:origin: org.opendaylight.netconf/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 (DocumentedException e) {
          LOG.trace("Error fetching input text content",e);
          return null;
        }
      }
    });

  }
}

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

private static Document filteredNotification(XmlElement filter, Document originalNotification) throws DocumentedException {
  Document result = XmlUtil.newDocument();
  XmlElement dataSrc = XmlElement.fromDomDocument(originalNotification);
  Element dataDst = (Element) result.importNode(dataSrc.getDomElement(), false);
  for (XmlElement filterChild : filter.getChildElements()) {
    addSubtree2(filterChild, dataSrc.getOnlyChildElement(), XmlElement.fromDomElement(dataDst));
  }
  if(dataDst.getFirstChild() != null) {
    result.appendChild(dataDst.getFirstChild());
    return result;
  } else {
    return null;
  }
}

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

@Override
public final void startExiCommunication(final NetconfMessage startExiMessage) {
  final EXIParameters exiParams;
  try {
    exiParams = EXIParameters.fromXmlElement(XmlElement.fromDomDocument(startExiMessage.getDocument()));
  } catch (final EXIOptionsException e) {
    LOG.warn("Unable to parse EXI parameters from {} on session {}", startExiMessage, this, e);
    throw new IllegalArgumentException("Cannot parse options", e);
  }
  final NetconfEXICodec exiCodec = new NetconfEXICodec(exiParams.getOptions());
  final NetconfMessageToEXIEncoder exiEncoder;
  try {
    exiEncoder = NetconfMessageToEXIEncoder.create(exiCodec);
  } catch (EXIOptionsException | TransmogrifierException e) {
    LOG.warn("Failed to instantiate EXI encoder for {} on session {}", exiCodec, this, e);
    throw new IllegalStateException("Cannot instantiate encoder for options", e);
  }
  final NetconfEXIToMessageDecoder exiDecoder;
  try {
    exiDecoder = NetconfEXIToMessageDecoder.create(exiCodec);
  } catch (EXIOptionsException e) {
    LOG.warn("Failed to instantiate EXI decodeer for {} on session {}", exiCodec, this, e);
    throw new IllegalStateException("Cannot instantiate encoder for options", e);
  }
  addExiHandlers(exiDecoder, exiEncoder);
  LOG.debug("Session {} EXI handlers added to pipeline", this);
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com