gpt4 book ai didi

com.yahoo.text.XML.getValue()方法的使用及代码示例

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

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

XML.getValue介绍

[英]Gets the string contents of the given Element. Returns "", never null if the element is null, or has no content
[中]获取给定元素的字符串内容。返回“”,如果元素为null或没有内容,则从不为null

代码示例

代码示例来源:origin: com.yahoo.vespa/config-model

private static String getBinding(Element e) {
  String binding = XML.getValue(e);
  if (! binding.endsWith("/")) {
    log.warning("Adding a trailing '/' to the document-api binding: " + binding + " -> " + binding + "/");
    binding = binding + "/";
  }
  return binding;
}

代码示例来源:origin: com.yahoo.vespa/config-model

public static Collection<String> valuesFromElements(Element parent, String elementName) {
  List<String> symbols = new ArrayList<>();
  for (Element symbol : XML.getChildren(parent, elementName)) {
    symbols.add(XML.getValue(symbol).trim());
  }
  return symbols;
}

代码示例来源:origin: com.yahoo.vespa/config-model

private String getPath(Element servletElement) {
  Element pathElement = XML.getChild(servletElement, "path");
  return XML.getValue(pathElement);
}

代码示例来源:origin: com.yahoo.vespa/container-search

private Object readFieldValue(Element field, String name, String targetDescription, QueryProfileRegistry registry) {
  Element ref = XML.getChild(field,"ref");
  if (ref != null) {
    String referencedName = XML.getValue(ref);
    QueryProfile referenced = registry.getComponent(referencedName);
    if (referenced == null)
      throw new IllegalArgumentException("Could not find query profile '" + referencedName + "' referenced as '" +
                        name + "' in " + targetDescription);
    return referenced;
  }
  else {
    return XML.getValue(field);
  }
}

代码示例来源:origin: com.yahoo.vespa/container-search

private Map<String,String> readParameters(Element containingElement) {
  List<Element> parameterElements=XML.getChildren(containingElement,"parameter");
  if (parameterElements.size()==0) return Collections.emptyMap(); // Shortcut
  Map<String,String> parameters=new LinkedHashMap<>();
  for (Element parameter : parameterElements) {
    String key=parameter.getAttribute("name");
    String value=XML.getValue(parameter);
    parameters.put(key,value);
  }
  return parameters;
}

代码示例来源:origin: com.yahoo.vespa/config-model

private Map<String, String> getServletConfig(Element servletElement) {
    Map<String, String> servletConfig = new HashMap<>();

    Element servletConfigElement = XML.getChild(servletElement, "servlet-config");
    XML.getChildren(servletConfigElement).forEach( parameter ->
        servletConfig.put(parameter.getTagName(), XML.getValue(parameter))
    );

    return servletConfig;
  }
}

代码示例来源:origin: com.yahoo.vespa/config-model

private static void putFilterConfig(Element filterConfigElement, FilterConfigProvider filterConfigProvider) {
  for (Element e : XML.getChildren(filterConfigElement)) {
    filterConfigProvider.putConfig(e.getTagName(), XML.getValue(e));
  }
}

代码示例来源:origin: com.yahoo.vespa/config-model

private List<Binding> readFilterBindings(Element filteringSpec) {
  List<Binding> result = new ArrayList<>();
  for (Element child: XML.getChildren(filteringSpec)) {
    String tagName = child.getTagName();
    if ((tagName.equals("request-chain") || tagName.equals("response-chain"))) {
      ComponentSpecification chainId = XmlHelper.getIdRef(child);
      for (Element bindingSpec: XML.getChildren(child, "binding")) {
        String binding = XML.getValue(bindingSpec);
        result.add(new Binding(chainId, binding));
      }
    }
  }
  return result;
}

代码示例来源:origin: com.yahoo.vespa/config-model

private void addRoutingAliases(ContainerCluster cluster, Element spec, Environment environment) {
  if (environment != Environment.prod) return;
  Element aliases = XML.getChild(spec, "aliases");
  for (Element alias : XML.getChildren(aliases, "service-alias")) {
    cluster.serviceAliases().add(XML.getValue(alias));
  }
  for (Element alias : XML.getChildren(aliases, "endpoint-alias")) {
    cluster.endpointAliases().add(XML.getValue(alias));
  }
}

代码示例来源:origin: com.yahoo.vespa/config-model-api

private DeclaredZone readDeclaredZone(Environment environment, Optional<AthenzService> athenzService, Element regionTag) {
  return new DeclaredZone(environment, Optional.of(RegionName.from(XML.getValue(regionTag).trim())),
              readActive(regionTag), athenzService);
}

代码示例来源:origin: com.yahoo.vespa/config-model

private RestApiContext.BundleInfo getBundle(Element bundleElement) {
  RestApiContext.BundleInfo bundle = new RestApiContext.BundleInfo(bundleElement.getAttribute("bundle"));
  for (Element packageElement : XML.getChildren(bundleElement, "package"))
    bundle.addPackageToScan(XML.getValue(packageElement));
  return bundle;
}

代码示例来源:origin: com.yahoo.vespa/config-model-api

/**
 * Returns a ValidationOverrides instance with the content of the given XML string.
 * An empty ValidationOverrides is returned if the argument is empty.
 *
 * @param xmlForm the string which optionally contains a validation-overrides XML structure
 * @return a ValidationOverrides from the argument
 * @throws IllegalArgumentException if the validation-allows.xml file exists but is invalid
 */
public static ValidationOverrides fromXml(String xmlForm) {
  if ( xmlForm.isEmpty()) return ValidationOverrides.empty;
  try {
    // Assume valid structure is ensured by schema validation
    Element root = XML.getDocument(xmlForm).getDocumentElement();
    List<ValidationOverrides.Allow> overrides = new ArrayList<>();
    for (Element allow : XML.getChildren(root, "allow")) {
      Instant until = LocalDate.parse(allow.getAttribute("until"), DateTimeFormatter.ISO_DATE)
          .atStartOfDay().atZone(ZoneOffset.UTC).toInstant()
          .plus(Duration.ofDays(1)); // Make the override valid *on* the "until" date
      Optional<ValidationId> validationId = ValidationId.from(XML.getValue(allow));
      if (validationId.isPresent()) // skip unknown ids as they may be valid for other model versions
        overrides.add(new ValidationOverrides.Allow(validationId.get(), until));
    }
    return new ValidationOverrides(overrides, xmlForm);
  }
  catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("validation-overrides is invalid", e);
  }
}

代码示例来源:origin: com.yahoo.vespa/config-model

@Override
protected Handler doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element handlerElement) {
  Handler<? super Component<?, ?>> handler = getHandler(handlerElement);
  for (Element binding : XML.getChildren(handlerElement, "binding"))
    handler.addServerBindings(XML.getValue(binding));
  for (Element clientBinding : XML.getChildren(handlerElement, "clientBinding"))
    handler.addClientBindings(XML.getValue(clientBinding));
  DomComponentBuilder.addChildren(deployState, ancestor, handlerElement, handler);
  return handler;
}

代码示例来源:origin: com.yahoo.vespa/config-model

@Override
  protected Handler doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element clientElement) {
    Handler<? super Component<?, ?>> client = getHandler(clientElement);

    for (Element binding : XML.getChildren(clientElement, "binding"))
      client.addClientBindings(XML.getValue(binding));

    for (Element serverBinding : XML.getChildren(clientElement, "serverBinding"))
      client.addServerBindings(XML.getValue(serverBinding));

    DomComponentBuilder.addChildren(deployState, ancestor, clientElement, client);

    return client;
  }
}

代码示例来源:origin: com.yahoo.vespa/config-model

SimpleComponent getSslConfigComponents(String serverName, Element serverSpec) {
    Element sslConfigurator = XML.getChild(serverSpec, "ssl");
    Element sslProviderConfigurator = XML.getChild(serverSpec, "ssl-provider");

    if (sslConfigurator != null) {
      String privateKeyFile = XML.getValue(XML.getChild(sslConfigurator, "private-key-file"));
      String certificateFile = XML.getValue(XML.getChild(sslConfigurator, "certificate-file"));
      Optional<String> caCertificateFile = XmlHelper.getOptionalChildValue(sslConfigurator, "ca-certificates-file");
      Optional<String> clientAuthentication = XmlHelper.getOptionalChildValue(sslConfigurator, "client-authentication");
      return new DefaultSslProvider(
          serverName,
          privateKeyFile,
          certificateFile,
          caCertificateFile.orElse(null),
          clientAuthentication.orElse(null));
    } else if (sslProviderConfigurator != null) {
      String className = sslProviderConfigurator.getAttribute("class");
      String bundle = sslProviderConfigurator.getAttribute("bundle");
      return new CustomSslProvider(serverName, className, bundle);
    } else {
      return new DummySslProvider(serverName);
    }
  }
}

代码示例来源:origin: com.yahoo.vespa/container-search

queryProfile.setDimensions(toArray(XML.getValue(dimensions)));

代码示例来源:origin: com.yahoo.vespa/config-model

/**
 * Parse leaf value in an xml tree
 */
private void parseLeaf(Element element, ConfigPayloadBuilder payloadBuilder, String parentName) {
  String name = extractName(element);
  String value = XML.getValue(element);
  if (value == null) {
    throw new ConfigurationRuntimeException("Element '" + name + "' must have either children or a value");
  }
  if (element.hasAttribute("index")) {
    // Check for legacy (pre Vespa 6) usage
    throw new IllegalArgumentException("The 'index' attribute on config elements is not supported - use <item>");
  } else if (element.hasAttribute("operation")) {
    // leaf array, currently the only supported operation is 'append'
    verifyLegalOperation(element);
    ConfigPayloadBuilder.Array a = payloadBuilder.getArray(name);
    a.append(value);
  } else if ("item".equals(name)) {
    if (parentName == null)
      throw new ConfigurationRuntimeException("<item> is a reserved keyword for array and map elements");
    if (element.hasAttribute("key")) {
      payloadBuilder.getMap(parentName).put(element.getAttribute("key"), value);
    } else {
      payloadBuilder.getArray(parentName).append(value);
    }
  } else {
    // leaf scalar, e.g. <intVal>3</intVal>
    payloadBuilder.setField(name, value);
  }
}

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