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

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

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

XML.getChildren介绍

[英]Returns the child Element objects from a w3c dom spec
[中]返回w3c dom规范中的子元素对象

代码示例

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

private Optional<Element> findChildById(Element parent, String id) {
  for (Element child : XML.getChildren(parent))
    if (id.equals(child.getAttribute("id"))) return Optional.of(child);
  return Optional.empty();
}

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

/**
 * If the top level is &lt;services&gt;, it contains a list of services elements,
 * otherwise, the top level tag is a single service.
 */
private List<Element> getServiceElements(Element servicesRoot) {
  if (servicesRoot.getTagName().equals("services"))
    return XML.getChildren(servicesRoot);
  List<Element> singleServiceList = new ArrayList<>(1);
  singleServiceList.add(servicesRoot);
  return singleServiceList;
}

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

private void readComponents(DeployState deployState, AbstractConfigProducer ancestor,
              Collection<ComponentType<T>> componentTypes,
              List<Element> elementsContainingComponentElems,
              Map<String, ComponentType> outerComponentTypeByComponentName) {
  for (ComponentType<T> componentType : componentTypes) {
    for (Element elemContainingComponentElems : elementsContainingComponentElems) {
      for (Element componentElement : XML.getChildren(elemContainingComponentElems, componentType.name)) {
        readComponent(deployState, ancestor, componentElement, componentType, outerComponentTypeByComponentName);
      }
    }
  }
}

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

private String[] serverBindings(Element searchElement, String... defaultBindings) {
  List<Element> bindings = XML.getChildren(searchElement, "binding");
  if (bindings.isEmpty())
    return defaultBindings;
  return toBindingList(bindings);
}

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

private List<FederationSearcherModel.TargetSpec> readSources(Element searcherSpec) {
  List<FederationSearcherModel.TargetSpec> sources = new ArrayList<>();
  for (Element source : XML.getChildren(searcherSpec, "source")) {
    sources.add(readSource(source));
  }
  return sources;
}

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

private List<RestApiContext.BundleInfo> getBundles(Element spec) {
  List<RestApiContext.BundleInfo> bundles = new ArrayList<>();
  for (Element bundleElement : XML.getChildren(spec, "components")) {
    bundles.add(getBundle(bundleElement));
  }
  return bundles;
}

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

private void readChains(DeployState deployState, AbstractConfigProducer ancestor, List<Element> chainsElems,
            Map<String, ComponentsBuilder.ComponentType> outerSearcherTypeByComponentName) {
  for (Map.Entry<String, Class<? extends DomChainBuilderBase<? extends COMPONENT, ? extends CHAIN>>>
      chainType : chainType2BuilderClass.entrySet()) {
    for (Element elemContainingChainElems : chainsElems) {
      for (Element chainElem : XML.getChildren(elemContainingChainElems, chainType.getKey())) {
        readChain(deployState, ancestor, chainElem, chainType.getValue(), outerSearcherTypeByComponentName);
      }
    }
  }
}

代码示例来源: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 void createLoadTypes(Element element, Clients clients) {
  for (Element e : XML.getChildren(element, "type")) {
    String priority = e.getAttribute("default-priority");
    clients.getLoadTypes().addType(e.getAttribute("name"), priority.length() > 0 ? priority : null);
  }
}

代码示例来源: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 List<Node> readNodes(Element providerElement) {
  Element nodesSpec = XML.getChild(providerElement, "nodes");
  if (nodesSpec == null) {
    return null;
  }
  List<Node> nodes = new ArrayList<>();
  for (Element nodeSpec : XML.getChildren(nodesSpec, "node")) {
    nodes.add(readNode(nodeSpec));
  }
  return nodes;
}

代码示例来源: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 void handleFlushStrategy(Element spec, Tuning.SearchNode sn) {
  for (Element e : XML.getChildren(spec)) {
    if (equals("native", e)) {
      handleNativeStrategy(e, sn);
    }
  }
}

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

private void addConfiguredComponents(DeployState deployState, ContainerCluster cluster, Element spec) {
  for (Element components : XML.getChildren(spec, "components")) {
    addIncludes(components);
    addConfiguredComponents(deployState, cluster, components, "component");
  }
  addConfiguredComponents(deployState, cluster, spec, "component");
}

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

private void handleInitialize(Element spec, Tuning.SearchNode sn) {
  sn.initialize = new Tuning.SearchNode.Initialize();
  for (Element e : XML.getChildren(spec)) {
    if (equals("threads", e)) {
      sn.initialize.threads = asInt(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 Tuning doBuild(DeployState deployState, AbstractConfigProducer parent, Element spec) {
  Tuning tuning = new Tuning(parent);
  for (Element e : XML.getChildren(spec)) {
    if (equals("dispatch", e)) {
      handleDispatch(e, tuning);
    } else if (equals("searchnode", e)) {
      handleSearchNode(e, tuning);
    }
  }
  return tuning;
}

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

private void handleSummaryStoreCompression(Element spec, Tuning.SearchNode.Summary.Store.Compression c) {
  for (Element e : XML.getChildren(spec)) {
    if (equals("type", e)) {
      c.type = Tuning.SearchNode.Summary.Store.Compression.Type.fromString(asString(e));
    } else if (equals("level", e)) {
      c.level = asInt(e);
    }
  }
}

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

private void handleSummaryStore(Element spec, Tuning.SearchNode.Summary s) {
  s.store = new Tuning.SearchNode.Summary.Store();
  for (Element e : XML.getChildren(spec)) {
    if (equals("cache", e)) {
      s.store.cache = new Tuning.SearchNode.Summary.Store.Component();
      handleSummaryStoreComponent(e, s.store.cache);
    } else if (equals("logstore", e)) {
      handleSummaryLogStore(e, s.store);
    }
  }
}

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

@Override
  protected JettyHttpServer doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element http) {
    JettyHttpServer jettyHttpServer = new JettyHttpServer(new ComponentId("jdisc-jetty"));
    for (Element serverSpec: XML.getChildren(http, "server")) {
      ConnectorFactory connectorFactory = new JettyConnectorBuilder().build(deployState, ancestor, serverSpec);
      jettyHttpServer.addConnector(connectorFactory);
    }

    return jettyHttpServer;
  }
}

相关文章

微信公众号

最新文章

更多