下面列出了org.springframework.util.xml.DomUtils#nodeNameEquals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* {@inheritDoc}
*/
public short accept(Element element) {
if (DomUtils.nodeNameEquals(element, elementName) &&
isEqualByNamespace(element, elementNamespace) &&
isEqualByBeanAttributes(element, attributes)) {
beanDefinitions.add(element);
}
return NodeFilter.FILTER_ACCEPT;
}
/**
* {@inheritDoc}
*/
public short accept(Element element) {
if (DomUtils.nodeNameEquals(element, elementName) &&
isEqualByNamespace(element, elementNamespace) &&
(isEqualById(element, id) || isEqualByBeanName(element, id))) {
beanDefinition = element;
}
return NodeFilter.FILTER_ACCEPT;
}
/**
* {@inheritDoc}
*/
public short accept(Element element) {
if (DomUtils.nodeNameEquals(element, "beans")) {
element.appendChild(element.getOwnerDocument().createTextNode("\n ")); //TODO make indentation configurable
element.appendChild(element.getOwnerDocument().importNode(beanDefinition, true));
}
return NodeFilter.FILTER_ACCEPT;
}
@Override
public short startElement(Element element) {
if (DomUtils.nodeNameEquals(element, "import")) {
String resourceLocation = element.getAttribute("resource");
if (StringUtils.hasText(resourceLocation)) {
if (resourceLocation.startsWith("classpath:")) {
resourceLocation = resourceLocation.substring("classpath:".length());
} else if (resourceLocation.startsWith("file:")) {
resourceLocation = resourceLocation.substring("file:".length());
}
try {
File importedFile = new FileSystemResource(parentConfigFile.getParentFile().getCanonicalPath() +
File.separator + resourceLocation).getFile();
if (importedFile.exists()) {
importedFiles.add(importedFile);
}
} catch (IOException e) {
log.warn("Unable to resolve imported file resource location", e);
}
}
}
return NodeFilter.FILTER_ACCEPT;
}