gpt4 book ai didi

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

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

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

XmlElement.getTextContent介绍

暂无

代码示例

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

@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 boolean prefixedContentMatches(final XmlElement filter, final XmlElement src) throws DocumentedException {
  final Map.Entry<String, String> prefixToNamespaceOfFilter;
  final Map.Entry<String, String> prefixToNamespaceOfSrc;
  try {
    prefixToNamespaceOfFilter = filter.findNamespaceOfTextContent();
    prefixToNamespaceOfSrc = src.findNamespaceOfTextContent();
  } catch (IllegalArgumentException e) {
    //if we can't find namespace of prefix - it's not a prefix, so it doesn't match
    return false;
  }
  final String prefix = prefixToNamespaceOfFilter.getKey();
  // If this is not a prefixed content, we do not need to continue since content do not match
  if (prefix.equals(XmlElement.DEFAULT_NAMESPACE_PREFIX)) {
    return false;
  }
  // Namespace mismatch
  if (!prefixToNamespaceOfFilter.getValue().equals(prefixToNamespaceOfSrc.getValue())) {
    return false;
  }
  final String unprefixedFilterContent = filter.getTextContent().substring(prefixToNamespaceOfFilter.getKey().length() + 1);
  final String unprefixedSrcContnet = src.getTextContent().substring(prefixToNamespaceOfSrc.getKey().length() + 1);
  // Finally compare unprefixed content
  return unprefixedFilterContent.equals(unprefixedSrcContnet);
}

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

/**
 * Search for element's attributes defining namespaces. Look for the one
 * namespace that matches prefix of element's text content. E.g.
 *
 * <pre>
 * &lt;type
 * xmlns:th-java="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl"&gt;th-java:threadfactory-naming&lt;/type&gt;
 * </pre>
 *
 * returns {"th-java","urn:.."}. If no prefix is matched, then default
 * namespace is returned with empty string as key. If no default namespace
 * is found value will be null.
 */
public Map.Entry<String/* prefix */, String/* namespace */> findNamespaceOfTextContent() throws DocumentedException {
  Map<String, String> namespaces = extractNamespaces();
  String textContent = getTextContent();
  int indexOfColon = textContent.indexOf(':');
  String prefix;
  if (indexOfColon > -1) {
    prefix = textContent.substring(0, indexOfColon);
  } else {
    prefix = DEFAULT_NAMESPACE_PREFIX;
  }
  if (!namespaces.containsKey(prefix)) {
    throw new IllegalArgumentException("Cannot find namespace for " + XmlUtil.toString(element) + ". Prefix from content is "
        + prefix + ". Found namespaces " + namespaces);
  }
  return Maps.immutableEntry(prefix, namespaces.get(prefix));
}

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

GetSchemaEntry(final XmlElement getSchemaElement) throws DocumentedException {
    getSchemaElement.checkName(GET_SCHEMA);
    getSchemaElement.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING);
    XmlElement identifierElement = null;
    try {
      identifierElement = getSchemaElement.getOnlyChildElementWithSameNamespace(IDENTIFIER);
    } catch (final DocumentedException e) {
      LOG.trace("Can't get identifier element as only child element with same namespace due to ",e);
      throw DocumentedException.wrap(e);
    }
    identifier = identifierElement.getTextContent();
    final Optional<XmlElement> versionElement = getSchemaElement
        .getOnlyChildElementWithSameNamespaceOptionally(VERSION);
    if (versionElement.isPresent()) {
      version = Optional.of(versionElement.get().getTextContent());
    } else {
      version = Optional.absent();
    }
  }
}

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

.getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.TEST_OPTION_KEY);
if (testOptionElementOpt.isPresent()) {
  String testOptionValue = testOptionElementOpt.get().getTextContent();
  testOption = TestOption.getFromXmlName(testOptionValue);
} else {
    .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.ERROR_OPTION_KEY);
if (errorOptionElement.isPresent()) {
  String errorOptionParsed = errorOptionElement.get().getTextContent();
  if (!errorOptionParsed.equals(EditConfigXmlParser.DEFAULT_ERROR_OPTION)){
    throw new UnsupportedOperationException("Only " + EditConfigXmlParser.DEFAULT_ERROR_OPTION
    .getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.DEFAULT_OPERATION_KEY);
if (defaultContent.isPresent()) {
  String mergeStrategyString = defaultContent.get().getTextContent();
  LOG.trace("Setting merge strategy to {}", mergeStrategyString);
  editStrategyType = EditStrategyType.valueOf(mergeStrategyString);

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

.getTextContent(), netconfOperationName, netconfOperationNamespace);

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