gpt4 book ai didi

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

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

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

XmlElement.getDomElement介绍

暂无

代码示例

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

public static String toString(final XmlElement xmlElement) {
  return toString(xmlElement.getDomElement(), false);
}

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

private ModifyAction getDefaultOperation(final XmlElement operationElement) throws DocumentedException {
  final NodeList elementsByTagName = operationElement.getDomElement().getElementsByTagName(DEFAULT_OPERATION_KEY);
  if(elementsByTagName.getLength() == 0) {
    return ModifyAction.MERGE;
  } else if(elementsByTagName.getLength() > 1) {
    throw new DocumentedException("Multiple " + DEFAULT_OPERATION_KEY + " elements",
        ErrorType.rpc, ErrorTag.unknown_attribute, ErrorSeverity.error);
  } else {
    return ModifyAction.fromXmlValue(elementsByTagName.item(0).getTextContent());
  }
}

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

private static Document extractNotificationContent(Document notification) throws DocumentedException {
  XmlElement root = XmlElement.fromDomElement(notification.getDocumentElement());
  XmlElement content = root.getOnlyChildElement();
  notification.removeChild(root.getDomElement());
  notification.appendChild(content.getDomElement());
  return notification;
}

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

private Element getPlaceholder(final Document innerResult)
    throws DocumentedException {
  final XmlElement rootElement = XmlElement.fromDomElementWithExpected(
      innerResult.getDocumentElement(), XmlMappingConstants.RPC_REPLY_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
}

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

private static Document filtered(XmlElement filter, Document originalReplyDocument) throws DocumentedException {
  Document result = XmlUtil.newDocument();
  // even if filter is empty, copy /rpc/data
  Element rpcReply = originalReplyDocument.getDocumentElement();
  Node rpcReplyDst = result.importNode(rpcReply, false);
  result.appendChild(rpcReplyDst);
  XmlElement dataSrc = XmlElement.fromDomElement(rpcReply).getOnlyChildElement("data", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  Element dataDst = (Element) result.importNode(dataSrc.getDomElement(), false);
  rpcReplyDst.appendChild(dataDst);
  addSubtree(filter, dataSrc, XmlElement.fromDomElement(dataDst));
  return result;
}

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

private Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
  final NodeList elementsByTagName = operationElement.getDomElement().getElementsByTagName(TARGET_KEY);
  // Direct lookup instead of using XmlElement class due to performance
  if (elementsByTagName.getLength() == 0) {
    throw new DocumentedException("Missing target element", ErrorType.rpc, ErrorTag.missing_attribute, ErrorSeverity.error);
  } else if (elementsByTagName.getLength() > 1) {
    throw new DocumentedException("Multiple target elements", ErrorType.rpc, ErrorTag.unknown_attribute, ErrorSeverity.error);
  } else {
    final XmlElement targetChildNode = XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
    return Datastore.valueOf(targetChildNode.getName());
  }
}

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

/**
 * Parses xml element rpc input into normalized node or null if rpc does not take any input
 * @param oElement rpc xml element
 * @param input input container schema node, or null if rpc does not take any input
 * @return parsed rpc into normalized node, or null if input schema is null
 */
@Nullable
private NormalizedNode<?, ?> rpcToNNode(final XmlElement oElement, @Nullable final ContainerSchemaNode input) {
  return input == null ? null : DomToNormalizedNodeParserFactory
      .getInstance(DomUtils.defaultValueCodecProvider(), schemaContext.getCurrentContext())
      .getContainerNodeParser()
      .parse(Collections.singletonList(oElement.getDomElement()), input);
}

代码示例来源: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-util

private static MatchingResult addSubtree2(XmlElement filter, XmlElement src, XmlElement dstParent) throws DocumentedException {
  Document document = dstParent.getDomElement().getOwnerDocument();
  MatchingResult matches = matches(src, filter);
  if (matches != MatchingResult.NO_MATCH && matches != MatchingResult.CONTENT_MISMATCH) {
    Element copied = (Element) document.importNode(src.getDomElement(), filterHasChildren == false);
    boolean shouldAppend = filterHasChildren == false;
    if (filterHasChildren) { // this implies TAG_MATCH
        copied = (Element) document.importNode(src.getDomElement(), true);
      dstParent.getDomElement().appendChild(copied);

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

private NormalizedNode parseIntoNormalizedNode(final DataSchemaNode schemaNode, final XmlElement element,
                        final DomToNormalizedNodeParserFactory.BuildingStrategyProvider editOperationStrategyProvider) {
  if (schemaNode instanceof ContainerSchemaNode) {
    return DomToNormalizedNodeParserFactory
        .getInstance(DomUtils.defaultValueCodecProvider(), schemaContext.getCurrentContext(), editOperationStrategyProvider)
        .getContainerNodeParser()
        .parse(Collections.singletonList(element.getDomElement()), (ContainerSchemaNode) schemaNode);
  } else if (schemaNode instanceof ListSchemaNode) {
    return DomToNormalizedNodeParserFactory
        .getInstance(DomUtils.defaultValueCodecProvider(), schemaContext.getCurrentContext(), editOperationStrategyProvider)
        .getMapNodeParser()
        .parse(Collections.singletonList(element.getDomElement()), (ListSchemaNode) schemaNode);
  } else {
    //this should never happen since edit-config on any other node type should not be possible nor makes sense
    LOG.debug("DataNode from module is not ContainerSchemaNode nor ListSchemaNode, aborting..");
  }
  throw new UnsupportedOperationException("implement exception if parse fails");
}

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