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

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

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

XmlElement.toString介绍

暂无

代码示例

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

public String getNamespaceAttribute() throws MissingNameSpaceException {
  String attribute = element.getAttribute(XmlUtil.XMLNS_ATTRIBUTE_KEY);
  if (attribute == null || attribute.equals(DEFAULT_NAMESPACE_PREFIX)){
    throw new MissingNameSpaceException(String.format("Element %s must specify namespace",
        toString()),
        DocumentedException.ErrorType.application,
        DocumentedException.ErrorTag.operation_failed,
        DocumentedException.ErrorSeverity.error);
  }
  return attribute;
}

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

public XmlElement getOnlyChildElement() throws DocumentedException {
  List<XmlElement> children = getChildElements();
  if (children.size() != 1){
    throw new DocumentedException(String.format( "One element expected in %s but was %s", toString(),
        children.size()),
        DocumentedException.ErrorType.application,
        DocumentedException.ErrorTag.invalid_value,
        DocumentedException.ErrorSeverity.error);
  }
  return children.get(0);
}

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

public XmlElement getOnlyChildElement(String childName) throws DocumentedException {
  List<XmlElement> nameElements = getChildElements(childName);
  if (nameElements.size() != 1){
    throw new DocumentedException("One element " + childName + " expected in " + toString(),
        DocumentedException.ErrorType.application,
        DocumentedException.ErrorTag.invalid_value,
        DocumentedException.ErrorSeverity.error);
  }
  return nameElements.get(0);
}

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

public XmlElement getOnlyChildElement(final String childName, String namespace) throws DocumentedException {
  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 DocumentedException(String.format("One element %s:%s expected in %s but was %s", namespace,
        childName, toString(), children.size()),
        DocumentedException.ErrorType.application,
        DocumentedException.ErrorTag.invalid_value,
        DocumentedException.ErrorSeverity.error);
  }
  return children.get(0);
}

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

/**
 * Recursively checks filter elements against the schema. Returns tree of nodes QNames as they appear in filter.
 * @param element element to check
 * @param parentNodeSchema parent node schema
 * @param tree parent node tree
 * @return tree
 * @throws ValidationException if filter content is not valid
 */
private FilterTree validateNode(XmlElement element, DataSchemaNode parentNodeSchema, FilterTree tree) throws ValidationException {
  final List<XmlElement> childElements = element.getChildElements();
  for (XmlElement childElement : childElements) {
    try {
      final Deque<DataSchemaNode> path = findSchemaNodeByNameAndNamespace(parentNodeSchema, childElement.getName(), new URI(childElement.getNamespace()));
      if (path.isEmpty()) {
        throw new ValidationException(element, childElement);
      }
      FilterTree subtree = tree;
      for (DataSchemaNode dataSchemaNode : path) {
          subtree = subtree.addChild(dataSchemaNode);
      }
      final DataSchemaNode childSchema = path.getLast();
      validateNode(childElement, childSchema, subtree);
    } catch (URISyntaxException | MissingNameSpaceException e) {
      throw new RuntimeException("Wrong namespace in element + " + childElement.toString());
    }
  }
  return tree;
}

相关文章