gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-27 12:57:05 26 4
gpt4 key购买 nike

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

XmlElement.getChildElementsWithinNamespace介绍

暂无

代码示例

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

public List<XmlElement> getChildElementsWithinNamespace(final String childName, String namespace) {
  return Lists.newArrayList(Collections2.filter(getChildElementsWithinNamespace(namespace),
      new Predicate<XmlElement>() {
        @Override
        public boolean apply(XmlElement xmlElement) {
          return xmlElement.getName().equals(childName);
        }
      }));
}

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

public Optional<XmlElement> getOnlyChildElementOptionally(final String childName, final String namespace) {
  List<XmlElement> children = getChildElementsWithinNamespace(namespace);
  children = Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
    @Override
    public boolean apply(XmlElement xmlElement) {
      return xmlElement.getName().equals(childName);
    }
  }));
  if (children.size() != 1){
    return Optional.absent();
  }
  return Optional.of(children.get(0));
}

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

public List<XmlElement> getChildElementsWithSameNamespace(final String childName) throws MissingNameSpaceException {
  List<XmlElement> children = getChildElementsWithinNamespace(getNamespace());
  return Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
    @Override
    public boolean apply(XmlElement xmlElement) {
      return xmlElement.getName().equals(childName);
    }
  }));
}

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

public Optional<XmlElement> getOnlyChildElementWithSameNamespaceOptionally(final String childName) {
  Optional<String> namespace = getNamespaceOptionally();
  if (namespace.isPresent()) {
    List<XmlElement> children = getChildElementsWithinNamespace(namespace.get());
    children = Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
      @Override
      public boolean apply(XmlElement xmlElement) {
        return xmlElement.getName().equals(childName);
      }
    }));
    if (children.size() != 1){
      return Optional.absent();
    }
    return Optional.of(children.get(0));
  }
  return Optional.absent();
}

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

private List<XmlElement> getConfigNodes(XmlElement moduleElement, String moduleNamespace, String name,
    List<XmlElement> recognisedChildren, List<XmlElement> typeAndName) throws NetconfDocumentedException {
  List<XmlElement> foundConfigNodes = moduleElement.getChildElementsWithinNamespace(name, moduleNamespace);
  if (foundConfigNodes.isEmpty()) {
    LOG.debug("No config nodes {}:{} found in {}", moduleNamespace, name, moduleElement);
    LOG.debug("Trying lookup of config nodes without specified namespace");
    foundConfigNodes = moduleElement.getChildElementsWithinNamespace(name,
        XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
    // In case module type or name element is not present in config it
    // would be matched with config type or name
    // We need to remove config type and name from available module
    // config elements
    foundConfigNodes.removeAll(typeAndName);
    LOG.debug("Found {} config nodes {} without specified namespace in {}", foundConfigNodes.size(), name,
        moduleElement);
  } else {
    List<XmlElement> foundWithoutNamespaceNodes = moduleElement.getChildElementsWithinNamespace(name,
        XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
    foundWithoutNamespaceNodes.removeAll(typeAndName);
    if (!foundWithoutNamespaceNodes.isEmpty()){
      throw new NetconfDocumentedException(String.format("Element %s present multiple times with different namespaces: %s, %s", name, foundConfigNodes,
          foundWithoutNamespaceNodes),
          NetconfDocumentedException.ErrorType.application,
          NetconfDocumentedException.ErrorTag.invalid_value,
          NetconfDocumentedException.ErrorSeverity.error);
    }
  }
  recognisedChildren.addAll(foundConfigNodes);
  return foundConfigNodes;
}

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

public XmlElement getOnlyChildElement(final String childName, String namespace) throws NetconfDocumentedException {
  List<XmlElement> children = getChildElementsWithinNamespace(namespace);
  children = Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
    @Override
    public boolean apply(XmlElement xmlElement) {
      return xmlElement.getName().equals(childName);
    }
  }));
  if (children.size() != 1){
    throw new NetconfDocumentedException(String.format("One element %s:%s expected in %s but was %s", namespace,
        childName, toString(), children.size()),
        NetconfDocumentedException.ErrorType.application,
        NetconfDocumentedException.ErrorTag.invalid_value,
        NetconfDocumentedException.ErrorSeverity.error);
  }
  return children.get(0);
}

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