本文整理汇总了Java中io.fabric8.utils.DomHelper.firstChild方法的典型用法代码示例。如果您正苦于以下问题:Java DomHelper.firstChild方法的具体用法?Java DomHelper.firstChild怎么用?Java DomHelper.firstChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.fabric8.utils.DomHelper
的用法示例。
在下文中一共展示了DomHelper.firstChild方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setGitHubOrgJobOwnerAndRepo
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
private void setGitHubOrgJobOwnerAndRepo(Document doc, String gitOwnerName, String gitRepoName) {
Element githubNavigator = getGitHubScmNavigatorElement(doc);
if (githubNavigator == null) {
throw new IllegalArgumentException("No element <" + GITHUB_SCM_NAVIGATOR_ELEMENT + "> found in the github organisation job!");
}
Element repoOwner = DomUtils.mandatoryFirstChild(githubNavigator, "repoOwner");
Element pattern = DomHelper.firstChild(githubNavigator, "pattern");
if (pattern == null) {
// lets check for the new plugin XML
Element traitsElement = DomHelper.firstChild(githubNavigator, "traits");
if (traitsElement != null) {
Element sourceFilterElement = DomHelper.firstChild(traitsElement, REGEX_SCM_SOURCE_FILTER_TRAIT_ELEMENT);
if (sourceFilterElement != null) {
pattern = DomHelper.firstChild(sourceFilterElement, "regex");
}
}
}
if (pattern == null) {
throw new IllegalArgumentException("No <pattern> or <traits><" + REGEX_SCM_SOURCE_FILTER_TRAIT_ELEMENT + "><regex> found in element <" + GITHUB_SCM_NAVIGATOR_ELEMENT + "> for the github organisation job!");
}
String newPattern = combineJobPattern(pattern.getTextContent(), gitRepoName);
DomUtils.setElementText(repoOwner, gitOwnerName);
DomUtils.setElementText(pattern, newPattern);
}
示例2: updateFirstChild
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
private static boolean updateFirstChild(Element parentElement, String elementName, String value) {
if (parentElement != null) {
Element element = DomHelper.firstChild(parentElement, elementName);
if (element != null) {
String textContent = element.getTextContent();
if (textContent == null || !value.equals(textContent)) {
element.setTextContent(value);
return true;
}
}
}
return false;
}
示例3: mandatoryFirstChild
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
/**
* Returns the first child of the given element with the name or throws an exception
*/
public static Element mandatoryFirstChild(Element element, String name) {
Element child = DomHelper.firstChild(element, name);
if (child == null) {
throw new IllegalArgumentException("The element <" + element.getTagName() + "> should have at least one child called <" + name + ">");
}
return child;
}
示例4: firstElementText
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
private static String firstElementText(Element element, String name) {
Element child = DomHelper.firstChild(element, name);
if (child != null) {
return child.getTextContent();
}
return null;
}
示例5: getOrCreateFirstChild
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
protected Element getOrCreateFirstChild(Element element, String elementName) {
Element answer = DomHelper.firstChild(element, elementName);
if (answer != null) {
return answer;
}
return DomHelper.addChildElement(element, elementName);
}
示例6: isFunktionProject
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
protected static boolean isFunktionProject(Document doc) {
Element parent = DomHelper.firstChild(doc.getDocumentElement(), "parent");
if (parent != null) {
Element groupId = DomHelper.firstChild(parent, "groupId");
if (groupId != null) {
String text = groupId.getTextContent();
return Objects.equals("io.fabric8.funktion.starter", text);
}
}
return false;
}
示例7: ensureMavenDependency
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
protected static boolean ensureMavenDependency(Document doc, String groupId, String artifactId, String scope) {
Element dependences = DomHelper.firstChild(doc.getDocumentElement(), "dependencies");
if (dependences == null) {
dependences = DomHelper.addChildElement(doc.getDocumentElement(), "dependencies");
}
NodeList childNodes = dependences.getChildNodes();
for (int i = 0, size = childNodes.getLength(); i < size; i++) {
Node item = childNodes.item(i);
if (item instanceof Element) {
Element child = (Element) item;
if (firstChildTextContent(child, "groupId", groupId) &&
firstChildTextContent(child, "artifactId", artifactId)) {
return false;
}
}
}
dependences.appendChild(doc.createTextNode("\n "));
Element dependency = DomHelper.addChildElement(dependences, "dependency");
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "groupId", groupId);
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "artifactId", artifactId);
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "scope", scope);
dependency.appendChild(doc.createTextNode("\n "));
dependences.appendChild(doc.createTextNode("\n "));
return true;
}
示例8: ensureMavenDependencyBOM
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
protected static boolean ensureMavenDependencyBOM(Document doc, String groupId, String artifactId, String version) {
Element dependencyManagement = DomHelper.firstChild(doc.getDocumentElement(), "dependencyManagement");
if (dependencyManagement == null) {
dependencyManagement = DomHelper.addChildElement(doc.getDocumentElement(), "dependencyManagement");
}
Element dependences = DomHelper.firstChild(dependencyManagement, "dependencies");
if (dependences == null) {
dependences = DomHelper.addChildElement(dependencyManagement, "dependencies");
}
NodeList childNodes = dependences.getChildNodes();
for (int i = 0, size = childNodes.getLength(); i < size; i++) {
Node item = childNodes.item(i);
if (item instanceof Element) {
Element child = (Element) item;
if (firstChildTextContent(child, "groupId", groupId) &&
firstChildTextContent(child, "artifactId", artifactId)) {
return false;
}
}
}
dependences.appendChild(doc.createTextNode("\n "));
Element dependency = DomHelper.addChildElement(dependences, "dependency");
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "groupId", groupId);
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "artifactId", artifactId);
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "version", version);
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "type", "pom");
dependency.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(dependency, "scope", "import");
dependency.appendChild(doc.createTextNode("\n "));
dependences.appendChild(doc.createTextNode("\n "));
return true;
}
示例9: firstChildTextContent
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
private static boolean firstChildTextContent(Element element, String name, String textContent) {
Element child = DomHelper.firstChild(element, name);
if (child != null) {
String actual = child.getTextContent();
if (textContent.equals(actual)) {
return true;
}
}
return false;
}
示例10: ensureFailsafePlugin
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
protected boolean ensureFailsafePlugin(Document doc) {
String artifactId = "maven-failsafe-plugin";
Element build = DomHelper.firstChild(doc.getDocumentElement(), "build");
if (build == null) {
build = DomHelper.addChildElement(doc.getDocumentElement(), "build");
}
Element plugins = DomHelper.firstChild(build, "plugins");
if (plugins == null) {
plugins = DomHelper.addChildElement(build, "plugins");
}
NodeList childNodes = plugins.getChildNodes();
for (int i = 0, size = childNodes.getLength(); i < size; i++) {
Node item = childNodes.item(i);
if (item instanceof Element) {
Element child = (Element) item;
if (firstChildTextContent(child, "artifactId", artifactId)) {
return false;
}
}
}
plugins.appendChild(doc.createTextNode("\n "));
Element plugin = DomHelper.addChildElement(plugins, "plugin");
plugin.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(plugin, "artifactId", artifactId);
plugin.appendChild(doc.createTextNode("\n "));
DomHelper.addChildElement(plugin, "version", failsafeVersion);
plugin.appendChild(doc.createTextNode("\n "));
Element configuration = DomHelper.addChildElement(plugin, "configuration");
configuration.appendChild(doc.createTextNode("\n "));
Element includes = DomHelper.addChildElement(configuration, "includes");
includes.appendChild(doc.createTextNode("\n "));
Element include = DomHelper.addChildElement(includes, "include", "**/*KT.*");
includes.appendChild(doc.createTextNode("\n "));
configuration.appendChild(doc.createTextNode("\n "));
plugin.appendChild(doc.createTextNode("\n "));
plugins.appendChild(doc.createTextNode("\n "));
return true;
}
示例11: validateVersion
import io.fabric8.utils.DomHelper; //导入方法依赖的package包/类
private void validateVersion(String kind, Element element, Element propertyElement) {
Element version = DomHelper.firstChild(element, "version");
if (version != null) {
String textContent = version.getTextContent();
if (textContent != null) {
textContent = textContent.trim();
if (Strings.isNotBlank(textContent)) {
String groupId = textContent(DomHelper.firstChild(element, "groupId"));
String artifactId = textContent(DomHelper.firstChild(element, "artifactId"));
String coords = groupId + ":" + artifactId;
if (Strings.isNullOrBlank(groupId)) {
coords = artifactId;
}
if (!textContent.startsWith("${") || !textContent.endsWith("}")) {
warn("" + kind + " " + coords + " does not use a maven property for version; has value: " + textContent);
} else {
String propertyName = textContent.substring(2, textContent.length() - 1);
String propertyValue = "????";
boolean unknownValue = true;
if (propertyElement != null) {
Element property = DomHelper.firstChild(propertyElement, propertyName);
if (property != null) {
propertyValue = property.getTextContent();
if (Strings.isNotBlank(propertyValue)) {
unknownValue = false;
}
}
}
if (!mavenDependenciesProperties.containsKey(propertyName)) {
if (!addMavenDependency.containsKey(propertyName) || !unknownValue) {
addMavenDependency.put(propertyName, propertyValue);
}
}
}
}
}
}
}