.", ele);
return null;
}
String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR +
ObjectUtils.getIdentityHexString(innerDefinition);
if (logger.isTraceEnabled()) {
logger.trace("Using generated bean name [" + id +
"] for nested custom element '" + ele.getNodeName() + "'");
}
return new BeanDefinitionHolder(innerDefinition, id);
}
/**
* Get the namespace URI for the supplied node.
* The default implementation uses {@link Node#getNamespaceURI}.
* Subclasses may override the default implementation to provide a
* different namespace identification mechanism.
* @param node the node
*/
@Nullable
public String getNamespaceURI(Node node) {
return node.getNamespaceURI();
}
/**
* Get the local name for the supplied {@link Node}.
*
The default implementation calls {@link Node#getLocalName}.
* Subclasses may override the default implementation to provide a
* different mechanism for getting the local name.
* @param node the {@code Node}
*/
public String getLocalName(Node node) {
return node.getLocalName();
}
/**
* Determine whether the name of the supplied node is equal to the supplied name.
*
The default implementation checks the supplied desired name against both
* {@link Node#getNodeName()} and {@link Node#getLocalName()}.
*
Subclasses may override the default implementation to provide a different
* mechanism for comparing node names.
* @param node the node to compare
* @param desiredName the name to check for
*/
public boolean nodeNameEquals(Node node, String desiredName) {
return desiredName.equals(node.getNodeName()) || desiredName.equals(getLocalName(node));
}
/**
* Determine whether the given URI indicates the default namespace.
*/
public boolean isDefaultNamespace(@Nullable String namespaceUri) {
return !StringUtils.hasLength(namespaceUri) || BEANS_NAMESPACE_URI.equals(namespaceUri);
}
/**
* Determine whether the given node indicates the default namespace.
* 确定给定节点是否指示默认命名空间。
*/
public boolean isDefaultNamespace(Node node) {
return isDefaultNamespace(getNamespaceURI(node));
}
private boolean isDefaultValue(String value) {
return !StringUtils.hasLength(value) || DEFAULT_VALUE.equals(value);
}
private boolean isCandidateElement(Node node) {
return (node instanceof Element && (isDefaultNamespace(node) || !isDefaultNamespace(node.getParentNode())));
}
}