本文整理了Java中com.yahoo.text.XML.getChild()
方法的一些代码示例,展示了XML.getChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XML.getChild()
方法的具体详情如下:
包路径:com.yahoo.text.XML
类名称:XML
方法名:getChild
[英]Returns the first child with the given name, or null if none
[中]返回具有给定名称的第一个子项,如果没有,则返回null
代码示例来源: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 String getCleanValue(Element spec, String name) {
Element elem = XML.getChild(spec, name);
if (elem == null) {
return null;
}
String value = elem.getFirstChild().getNodeValue();
if (value == null) {
return null;
}
value = value.trim();
return value.isEmpty() ? null : value;
}
代码示例来源: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
public static Optional<String> getOptionalChildValue(Element parent, String childName) {
Element child = XML.getChild(parent, childName);
if (child == null) return Optional.empty();
if (child.getFirstChild() == null) return Optional.empty();
return Optional.ofNullable(child.getFirstChild().getNodeValue());
}
}
代码示例来源:origin: com.yahoo.vespa/config-model
private void addSecretStore(ContainerCluster cluster, Element spec) {
Element secretStoreElement = XML.getChild(spec, "secret-store");
if (secretStoreElement != null) {
SecretStore secretStore = new SecretStore();
for (Element group : XML.getChildren(secretStoreElement, "group")) {
secretStore.addGroup(group.getAttribute("name"), group.getAttribute("environment"));
}
cluster.setSecretStore(secretStore);
}
}
代码示例来源:origin: com.yahoo.vespa/config-model
/**
* If not found, return null.
*/
public ModelElement getChild(String name) {
Element e = XML.getChild(xml, name);
if (e != null) {
return new ModelElement(e);
}
return null;
}
代码示例来源:origin: com.yahoo.vespa/config-model-api
private DeploymentSpec.UpgradePolicy readUpgradePolicy(Element root) {
Element upgradeElement = XML.getChild(root, "upgrade");
if (upgradeElement == null) return DeploymentSpec.UpgradePolicy.defaultPolicy;
String policy = upgradeElement.getAttribute("policy");
switch (policy) {
case "canary" : return DeploymentSpec.UpgradePolicy.canary;
case "default" : return DeploymentSpec.UpgradePolicy.defaultPolicy;
case "conservative" : return DeploymentSpec.UpgradePolicy.conservative;
default : throw new IllegalArgumentException("Illegal upgrade policy '" + policy + "': " +
"Must be one of " + Arrays.toString(DeploymentSpec.UpgradePolicy.values()));
}
}
代码示例来源: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/config-model
private Set<ComponentSpecification> read(Element spec, String attributeName, String elementName) {
Set<ComponentSpecification> componentSpecifications = new LinkedHashSet<>();
componentSpecifications.addAll(spaceSeparatedComponentSpecificationsFromAttribute(spec, attributeName));
// TODO: the 'inherits' element is undocumented, and can be removed in an upcoming version of Vespa
componentSpecifications.addAll(idRefFromElements(XML.getChild(spec, "inherits"), elementName));
return componentSpecifications;
}
代码示例来源:origin: com.yahoo.vespa/config-model
private Optional<Component> buildTargetSelector(DeployState deployState, AbstractConfigProducer ancestor, Element searcherElement, ComponentId namespace) {
Element targetSelectorElement = XML.getChild(searcherElement, "target-selector");
if (targetSelectorElement == null)
return Optional.empty();
return Optional.of(new DomComponentBuilder(namespace).build(deployState, ancestor, targetSelectorElement));
}
}
代码示例来源:origin: com.yahoo.vespa/config-model
private static void addFilterConfig(Element filterElement, Filter filter) {
Element filterConfigElement = XML.getChild(filterElement, "filter-config");
if (filterConfigElement == null)
return;
FilterConfigProvider filterConfigProvider = filter.addAndInjectConfigProvider();
putFilterConfig(filterConfigElement, filterConfigProvider);
}
代码示例来源:origin: com.yahoo.vespa/config-model
private void addHttp(DeployState deployState, Element spec, ContainerCluster cluster) {
Element httpElement = XML.getChild(spec, "http");
if (httpElement != null) {
cluster.setHttp(buildHttp(deployState, cluster, httpElement));
}
}
代码示例来源:origin: com.yahoo.vespa/config-model
private ContainerDocumentApi buildDocumentApi(ContainerCluster cluster, Element spec) {
Element documentApiElement = XML.getChild(spec, "document-api");
if (documentApiElement == null) return null;
ContainerDocumentApi.Options documentApiOptions = DocumentApiOptionsBuilder.build(documentApiElement);
return new ContainerDocumentApi(cluster, documentApiOptions);
}
代码示例来源:origin: com.yahoo.vespa/config-model
protected static FederationOptions readFederationOptions(Element sourceElement) {
Element optionsElement = XML.getChild(sourceElement, FederationOptionsBuilder.federationOptionsElement);
if (optionsElement == null) {
return new FederationOptions();
} else {
return new FederationOptionsBuilder(optionsElement).build();
}
}
}
代码示例来源:origin: com.yahoo.vespa/config-model
private Node readCertificateProxy(Element providerElement) {
Element certificateProxySpec = XML.getChild(providerElement, "yca-proxy");
if (certificateProxySpec == null) {
return null; // no proxy
}
if(getAttributeOrNull(certificateProxySpec, "host") == null) {
return new Node(null, 0); // default proxy
}
return readNode(certificateProxySpec);
}
代码示例来源:origin: com.yahoo.vespa/config-model
@Override
protected Admin doBuild(DeployState deployState, AbstractConfigProducer parent, Element adminElement) {
Monitoring monitoring = getMonitoring(XML.getChild(adminElement,"monitoring"));
Metrics metrics = new MetricsBuilder(applicationType, predefinedMetricSets)
.buildMetrics(XML.getChild(adminElement, "metrics"));
FileDistributionConfigProducer fileDistributionConfigProducer = getFileDistributionConfigProducer(parent);
Admin admin = new Admin(parent, monitoring, metrics, multitenant, fileDistributionConfigProducer, deployState.isHosted());
admin.setApplicationType(applicationType);
doBuildAdmin(deployState, admin, adminElement);
new ModelConfigProvider(admin);
return admin;
}
代码示例来源:origin: com.yahoo.vespa/config-model
private void addModelEvaluation(Element spec, ContainerCluster cluster, ConfigModelContext context) {
Element modelEvaluationElement = XML.getChild(spec, "model-evaluation");
if (modelEvaluationElement == null) return;
RankProfileList profiles =
context.vespaModel() != null ? context.vespaModel().rankProfileList() : RankProfileList.empty;
cluster.setModelEvaluation(new ContainerModelEvaluation(cluster, profiles));
}
代码示例来源:origin: com.yahoo.vespa/config-model
private void addProcessing(DeployState deployState, Element spec, ContainerCluster cluster) {
Element processingElement = XML.getChild(spec, "processing");
if (processingElement == null) return;
addIncludes(processingElement);
cluster.setProcessingChains(new DomProcessingBuilder(null).build(deployState, cluster, processingElement),
serverBindings(processingElement, ProcessingChains.defaultBindings));
validateAndAddConfiguredComponents(deployState, cluster, processingElement, "renderer", ContainerModelBuilder::validateRendererElement);
}
代码示例来源:origin: com.yahoo.vespa/config-model
private void addSearch(DeployState deployState, Element spec, ContainerCluster cluster) {
Element searchElement = XML.getChild(spec, "search");
if (searchElement == null) return;
addIncludes(searchElement);
cluster.setSearch(buildSearch(deployState, cluster, searchElement));
addSearchHandler(cluster, searchElement);
addGUIHandler(cluster);
validateAndAddConfiguredComponents(deployState, cluster, searchElement, "renderer", ContainerModelBuilder::validateRendererElement);
}
代码示例来源:origin: com.yahoo.vespa/config-model
@Override
protected void doBuildAdmin(DeployState deployState, Admin admin, Element adminE) {
List<Configserver> configservers = parseConfigservers(deployState, admin, adminE);
admin.setLogserver(parseLogserver(deployState, admin, adminE));
admin.addConfigservers(configservers);
admin.addSlobroks(getSlobroks(deployState, admin, XML.getChild(adminE, "slobroks")));
if ( ! admin.multitenant())
admin.setClusterControllers(addConfiguredClusterControllers(deployState, admin, adminE));
ModelElement adminElement = new ModelElement(adminE);
addLogForwarders(adminElement.getChild("logforwarding"), admin);
}
内容来源于网络,如有侵权,请联系作者删除!