本文整理了Java中org.w3c.dom.Element.hasChildNodes()
方法的一些代码示例,展示了Element.hasChildNodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.hasChildNodes()
方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:hasChildNodes
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
private static boolean isWordNode(Element node) {
return node.hasAttribute(ATTR_WORD) && !node.hasChildNodes();
}
代码示例来源:origin: spring-projects/spring-framework
private void extendBeanDefinition(Element element, ParserContext parserContext) {
BeanDefinition beanDef =
parserContext.getRegistry().getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
if (element.hasChildNodes()) {
addIncludePatterns(element, parserContext, beanDef);
}
}
代码示例来源:origin: ehcache/ehcache3
private static String val(Element element) {
return element.hasChildNodes() ? element.getFirstChild().getNodeValue() : null;
}
代码示例来源:origin: nutzam/nutz
protected List<IocValue> paserCollection(Element element) throws Throwable {
List<IocValue> list = new ArrayList<IocValue>();
if (element.hasChildNodes()) {
NodeList nodeList = element.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
list.add((IocValue) parseX((Element) node));
}
}
}
return list;
}
代码示例来源:origin: liyiorg/weixin-popular
/**
* 转换 未定义XML 字段为 Map
* @since 2.8.13
* @return MAP
*/
public Map<String, String> otherElementsToMap() {
Map<String, String> map = new LinkedHashMap<String, String>();
if (otherElements != null) {
for (org.w3c.dom.Element e : otherElements) {
if (e.hasChildNodes()) {
if (e.getChildNodes().getLength() == 1
&& e.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE) {
map.put(e.getTagName(), e.getTextContent());
}
}
}
}
return map;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
/**
* Common routine to remove all children nodes from the passed element container
* @param parentElement
* @param nodeName
* @throws XPathExpressionException
*/
protected void clearNode(Element parentElement, String nodeName) throws XPathExpressionException {
if (parentElement.hasChildNodes()) {
NodeList children = (NodeList) xPath.evaluate(nodeName, parentElement, XPathConstants.NODESET);
for (int j = 0; j < children.getLength(); j++) {
parentElement.removeChild(children.item(j));
}
children = parentElement.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
if (children.item(j).getNodeName().equalsIgnoreCase("#text")) {
parentElement.removeChild(children.item(j));
}
}
}
}
代码示例来源:origin: nutzam/nutz
protected Map<String, ?> paserMap(Element element) throws Throwable {
Map<String, Object> map = new HashMap<String, Object>();
if (element.hasChildNodes()) {
List<Element> elist = getChildNodesByTagName(element, ITEM_TAG);
for (Element elementItem : elist) {
String key = elementItem.getAttribute("key");
if (map.containsKey(key))
throw new IllegalArgumentException("key is not unique!");
NodeList list = elementItem.getChildNodes();
for (int j = 0; j < list.getLength(); j++) {
if (list.item(j) instanceof Element) {
map.put(key, parseX((Element) list.item(j)));
break;
}
}
if (!map.containsKey(key))
map.put(key, null);
}
}
return map;
}
代码示例来源:origin: groovy/groovy-core
/**
* Returns the list of any direct String nodes of this node.
*
* @return the list of String values from this node
* @since 2.3.0
*/
public static List<String> localText(Element self) {
List<String> result = new ArrayList<String>();
if (self.getNodeType() == Node.TEXT_NODE || self.getNodeType() == Node.CDATA_SECTION_NODE) {
result.add(self.getNodeValue());
} else if (self.hasChildNodes()) {
NodeList nodeList = self.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node item = nodeList.item(i);
if (item.getNodeType() == Node.TEXT_NODE || item.getNodeType() == Node.CDATA_SECTION_NODE) {
result.add(item.getNodeValue());
}
}
}
return result;
}
代码示例来源:origin: plutext/docx4j
case Node.ELEMENT_NODE :
Element element = (Element) node;
if (!element.hasChildNodes()) {
break;
代码示例来源:origin: apache/flink
continue;
Element field = (Element)fieldNode;
if ("name".equals(field.getTagName()) && field.hasChildNodes())
attr = StringInterner.weakIntern(
((Text)field.getFirstChild()).getData().trim());
if ("value".equals(field.getTagName()) && field.hasChildNodes())
value = StringInterner.weakIntern(
((Text)field.getFirstChild()).getData());
if ("final".equals(field.getTagName()) && field.hasChildNodes())
finalParameter = "true".equals(((Text)field.getFirstChild()).getData());
if ("source".equals(field.getTagName()) && field.hasChildNodes())
source.add(StringInterner.weakIntern(
((Text)field.getFirstChild()).getData()));
代码示例来源:origin: nutzam/nutz
protected void parseFields(Element beanElement, IocObject iocObject) throws Throwable {
List<Element> list = getChildNodesByTagName(beanElement, TAG_FIELD);
for (Element fieldElement : list) {
IocField iocField = new IocField();
iocField.setName(fieldElement.getAttribute("name"));
if ("true".equals(fieldElement.getAttribute("optional")))
iocField.setOptional(true);
if (fieldElement.hasChildNodes()) {
NodeList nodeList = fieldElement.getChildNodes();
for (int j = 0; j < nodeList.getLength(); j++) {
if (nodeList.item(j) instanceof Element) {
iocField.setValue(parseX((Element) nodeList.item(j)));
break;
}
}
}
iocObject.addField(iocField);
}
}
代码示例来源:origin: plutext/docx4j
if (!thisSpan.hasChildNodes()) continue;
代码示例来源:origin: apache/ignite
ttl = extractIntAttribute(root, TTL_ATTR);
if (!root.hasChildNodes()) {
throw new IllegalArgumentException("Incorrect Cassandra persistence settings specification, " +
"there are no key and value persistence settings specified");
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
if (!document.getDocumentElement().hasChildNodes()) {
代码示例来源:origin: androidquery/androidquery
if(e.hasChildNodes()){
代码示例来源:origin: redisson/redisson
private void parseChildElements(Element element, String parentId, String redissonRef, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
if (element.hasChildNodes()) {
CompositeComponentDefinition compositeDef
= new CompositeComponentDefinition(parentId,
parserContext.extractSource(element));
parserContext.pushContainingComponent(compositeDef);
List<Element> childElts = DomUtils.getChildElements(element);
for (Element elt : childElts) {
if(BeanDefinitionParserDelegate
.QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
continue;//parsed elsewhere
}
String localName = parserContext.getDelegate().getLocalName(elt);
localName = Conventions.attributeNameToPropertyName(localName);
if (ConfigType.contains(localName)) {
parseConfigTypes(elt, localName, redissonDef, parserContext);
} else if (AddressType.contains(localName)) {
parseAddressTypes(elt, localName, redissonDef, parserContext);
} else if (helper.isRedissonNS(elt)) {
elt.setAttribute(REDISSON_REF, redissonRef);
parserContext.getDelegate().parseCustomElement(elt);
}
}
parserContext.popContainingComponent();
}
}
代码示例来源:origin: redisson/redisson
private void parseChildElements(Element element, String parentId, String redissonRef, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
if (element.hasChildNodes()) {
CompositeComponentDefinition compositeDef
= new CompositeComponentDefinition(parentId,
parserContext.extractSource(element));
parserContext.pushContainingComponent(compositeDef);
List<Element> childElts = DomUtils.getChildElements(element);
for (Element elt : childElts) {
if(BeanDefinitionParserDelegate
.QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
continue;//parsed elsewhere
}
String localName = parserContext.getDelegate().getLocalName(elt);
localName = Conventions.attributeNameToPropertyName(localName);
if (ConfigType.contains(localName)) {
parseConfigTypes(elt, localName, redissonDef, parserContext);
} else if (AddressType.contains(localName)) {
parseAddressTypes(elt, localName, redissonDef, parserContext);
} else if (helper.isRedissonNS(elt)) {
elt.setAttribute(REDISSON_REF, redissonRef);
parserContext.getDelegate().parseCustomElement(elt);
}
}
parserContext.popContainingComponent();
}
}
代码示例来源:origin: plutext/docx4j
&& !xhtmlBlock.hasChildNodes() ) {
代码示例来源:origin: rhuss/jolokia
/** {@inheritDoc} */
public Object extract(Element element) { return element.hasChildNodes(); }
}
代码示例来源:origin: geotools/geotools
private boolean hasParameters(Element root) {
// check if any attribute is parametric
NamedNodeMap attributes = root.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attribute = attributes.item(i);
final String nv = attribute.getNodeValue();
if (nv != null && nv.contains("param(")) {
return true;
}
}
// recurse
if (root.hasChildNodes()) {
NodeList childNodes = root.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node n = childNodes.item(i);
if (n != null && n instanceof Element) {
if (hasParameters((Element) n)) {
return true;
}
}
}
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!