当前位置: 首页>>代码示例>>Java>>正文


Java Element.hasChildNodes方法代码示例

本文整理汇总了Java中org.w3c.dom.Element.hasChildNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Element.hasChildNodes方法的具体用法?Java Element.hasChildNodes怎么用?Java Element.hasChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Element的用法示例。


在下文中一共展示了Element.hasChildNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseChildElements

import org.w3c.dom.Element; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:27,代码来源:RedissonDefinitionParser.java

示例2: doParse

import org.w3c.dom.Element; //导入方法依赖的package包/类
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	BundleActionCallback callback = new BundleActionCallback();

	ParserUtils.parseCustomAttributes(element, builder, new AttributeCallback[] { callback });

	// parse nested definition (in case there is any)

	if (element.hasChildNodes()) {
		NodeList nodes = element.getChildNodes();
		boolean foundElement = false;
		for (int i = 0; i < nodes.getLength() && !foundElement; i++) {
			Node nd = nodes.item(i);
			if (nd instanceof Element) {
				foundElement = true;
				Object obj =
						parserContext.getDelegate().parsePropertySubElement((Element) nd,
								builder.getBeanDefinition());
				builder.addPropertyValue(BUNDLE_PROP, obj);
			}
		}
	}
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:24,代码来源:BundleBeanDefinitionParser.java

示例3: getDefsElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * 
 */
protected Element getDefsElement()
{
	if (defs == null)
	{
		defs = document.createElement("defs");

		Element svgNode = document.getDocumentElement();

		if (svgNode.hasChildNodes())
		{
			svgNode.insertBefore(defs, svgNode.getFirstChild());
		}
		else
		{
			svgNode.appendChild(defs);
		}
	}

	return defs;
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:24,代码来源:mxSvgCanvas.java

示例4: getDefsElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * 
 */
protected Element getDefsElement() {
  if (defs == null) {
    defs = document.createElement("defs");

    Element svgNode = document.getDocumentElement();

    if (svgNode.hasChildNodes()) {
      svgNode.insertBefore(defs, svgNode.getFirstChild());
    } else {
      svgNode.appendChild(defs);
    }
  }

  return defs;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:19,代码来源:mxSvgCanvas.java

示例5: elementToHTMLTag

import org.w3c.dom.Element; //导入方法依赖的package包/类
private String elementToHTMLTag(Element elt) {
	String sTags = "";
	if (elt != null) {
		if (elt.hasChildNodes()) {
			NodeList children = elt.getChildNodes();
			int len = children.getLength();
			if (len > 0) {
				for (int i=0; i<len; i++) {
					Node child = children.item(i);
					int type = child.getNodeType();
					switch (type) {
						case Node.ELEMENT_NODE:
							String sOcc = ((Element)child).getAttribute("occurence");
							sOcc = ((sOcc == null) ? "":sOcc);
							boolean bHeader = !sOcc.equalsIgnoreCase("");
							sTags += "<TR>";
							if (child.hasChildNodes()) {
								if (child.getFirstChild().getNodeType() == Node.TEXT_NODE)
									sTags += "<TD>" + addInput(((Element)child).getTagName(),((Element)child).getAttribute("bytes"),child.getFirstChild().getNodeValue()) + "</TD>";
								else {
									sTags += "<TD colspan='2'><TABLE border='1'>";
									sTags += (bHeader ? "<TR><TH colspan='2'>"+ ((Element)child).getTagName() + ": " + sOcc +"</TH></TR>":"");
									sTags += elementToHTMLTag((Element)child);
									sTags += "</TABLE></TD>";
								}
							}
							else {
								sTags += "<TD>" + addInput(((Element)child).getTagName(),((Element)child).getAttribute("bytes"),"") + "</TD>";
							}
							sTags += "</TR>";
							break;
						default:
							break;
					}
				}
			}
		}
	}
	return sTags; 
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:41,代码来源:CicsTransaction.java

示例6: extendBeanDefinition

import org.w3c.dom.Element; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:AspectJAutoProxyBeanDefinitionParser.java

示例7: getFirstChildByTagNameText

import org.w3c.dom.Element; //导入方法依赖的package包/类
private String getFirstChildByTagNameText(Element parent, String name) {
	Element element = getFirstChildByTagName(parent, name);
	if (element != null && element.hasChildNodes()) {
		return element.getFirstChild().getNodeValue();
	}
	return null;
}
 
开发者ID:geops,项目名称:geoserver-documentor,代码行数:8,代码来源:ExplainAnalyzer.java

示例8: funcList

import org.w3c.dom.Element; //导入方法依赖的package包/类
private Element funcList() {
    Element funcListElement = doc.createElement("Functions");
    Element funcDefElement = funcDef();
    while (funcDefElement != null) {
        funcListElement.appendChild(funcDefElement);

        funcDefElement = funcDef();
    }
    if (funcListElement.hasChildNodes()) {
        return funcListElement;
    } else {
        return null;
    }
}
 
开发者ID:hologerry,项目名称:Compiler,代码行数:15,代码来源:GSyntaxAnalyzer.java

示例9: codeBlock

import org.w3c.dom.Element; //导入方法依赖的package包/类
private Element codeBlock() {
    Element codeBlockElement = doc.createElement("CodeBlock");
    Element leftBigPaElement;
    Element stmtListElement;
    Element rightBigPaElement;
    Element stmtElement;
    currentWord = getNextWord();
    if (currentWord != null && currentWord.type == SEPARATOR_TYPE && currentWord.value.equals("{")) {
        leftBigPaElement = doc.createElement("separator");
        leftBigPaElement.appendChild(doc.createTextNode(currentWord.value));
        codeBlockElement.appendChild(leftBigPaElement);

        stmtListElement = stmtList();
        if (stmtListElement != null) {
            codeBlockElement.appendChild(stmtListElement);
        }

        currentWord = getNextWord();
        if (currentWord != null && currentWord.type == SEPARATOR_TYPE && currentWord.value.equals("}")) {
            rightBigPaElement = doc.createElement("separator");
            rightBigPaElement.appendChild(doc.createTextNode(currentWord.value));
            codeBlockElement.appendChild(rightBigPaElement);
        }

    } else {
        currentWordLabIndex--;
        stmtElement = statement();
        if (stmtElement != null) {
            codeBlockElement.appendChild(stmtElement);
        }
    }

    if (codeBlockElement.hasChildNodes()) {
        return codeBlockElement;
    }

    return null;
}
 
开发者ID:hologerry,项目名称:Compiler,代码行数:39,代码来源:GSyntaxAnalyzer.java

示例10: expr2

import org.w3c.dom.Element; //导入方法依赖的package包/类
private Element expr2() {
    Element expr2Element = doc.createElement("Expr2");
    Element rExpr2Element; // recursive element;
    Element plusMinusElement;
    Element termElement;
    currentWord = getNextWord();
    if (currentWord != null && currentWord.type == OPERATOR_TYPE) {
        if (currentWord.value.equals("+") || currentWord.value.equals("-")) {
            plusMinusElement = doc.createElement("operator");
            plusMinusElement.appendChild(doc.createTextNode(currentWord.value));
            expr2Element.appendChild(plusMinusElement);
        }

        termElement = term();
        if (termElement != null) {
            expr2Element.appendChild(termElement);
        }

        rExpr2Element = expr2();
        while (rExpr2Element != null ) {
            expr2Element.appendChild(rExpr2Element);
            rExpr2Element = expr2();
        }

    } else {
        currentWordLabIndex--;
        return null;
    }

    if (expr2Element.hasChildNodes()) {
        return expr2Element;
    } else {
        return null;
    }

}
 
开发者ID:hologerry,项目名称:Compiler,代码行数:37,代码来源:GSyntaxAnalyzer.java

示例11: term2

import org.w3c.dom.Element; //导入方法依赖的package包/类
private Element term2() {
    Element term2Element = doc.createElement("Term2");
    Element rTerm2Element;
    Element mltDivElement;
    Element factorElement;
    currentWord = getNextWord();
    if (currentWord != null && currentWord.type == OPERATOR_TYPE) {
        if (currentWord.value.equals("*") || currentWord.value.equals("/")) {
            mltDivElement = doc.createElement("operator");
            mltDivElement.appendChild(doc.createTextNode(currentWord.value));
            term2Element.appendChild(mltDivElement);
        }

        factorElement = factor();
        if (factorElement != null) {
            term2Element.appendChild(factorElement);
        }

        rTerm2Element = term2();
        while(rTerm2Element != null) {
            term2Element.appendChild(rTerm2Element);
            rTerm2Element = term2();
        }
    } else {
        currentWordLabIndex--;
        return null;
    }
    if (term2Element.hasChildNodes()) {
        return term2Element;
    } else {
        return null;
    }
}
 
开发者ID:hologerry,项目名称:Compiler,代码行数:34,代码来源:GSyntaxAnalyzer.java

示例12: CollectionEntity

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Create a collection entity from a chunk of XML and params
 * 
 * @param locationId the location for the collection
 * @param ownerId the ownerId (will override the value from the XML if set)
 * @param element the XML Dom element
 */
public CollectionEntity(String locationId, String ownerId, Element element) {
    if (log.isDebugEnabled()) log.debug("kaltura CE.construct(loc="+locationId+", owner="+ownerId+", element="+element+")");
    this.mc = new MediaCollection(null, locationId, ownerId, "", false, null); // id, location, owner, title
    // ignore the id for now
    if (ownerId == null || "".equals(ownerId)) {
        if (!"".equals(element.getAttribute("ownerId"))) {
            ownerId = element.getAttribute("ownerId");
            this.mc.setOwnerId(ownerId);
        }
    }
    if (!"".equals(element.getAttribute("title"))) {
        this.mc.setTitle(element.getAttribute("title"));
    }
    if (!"".equals(element.getAttribute("description"))) {
        this.mc.setDescription(element.getAttribute("description"));
    }
    if (!"".equals(element.getAttribute("hidden"))) {
        this.mc.setHidden(Boolean.parseBoolean(element.getAttribute("hidden")));
    }
    if (!"".equals(element.getAttribute("sharing"))) {
        this.mc.setSharing(element.getAttribute("sharing"));
    }
    // check for the children items
    if (element.hasChildNodes()) {
        NodeList nodes = element.getChildNodes();
        if (log.isDebugEnabled()) log.debug("kaltura CE.construct: found items="+nodes.getLength());
        List<MediaItem> mediaItems = new ArrayList<MediaItem>(nodes.getLength());
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (MediaItem.XML_ITEM_KEY.equals(node.getNodeName()) && Node.ELEMENT_NODE == node.getNodeType()) {
                MediaItem mi = new MediaItem(this.mc, ownerId, (Element) node);
                if (log.isDebugEnabled()) log.debug("kaltura CE.construct: made node into mediaItem="+mi);
                mediaItems.add(mi);
            } else {
                log.warn("kaltura CE.construct: skipped node="+node);
            }
        }
        this.mc.setItems(mediaItems);
        if (log.isDebugEnabled()) log.debug("kaltura CE.construct: mediaItems added to collection="+mediaItems.size());
    }
    if (log.isDebugEnabled()) log.debug("kaltura CE.construct: coll="+this.mc);
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:50,代码来源:CollectionEntity.java

示例13: parseDocument

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void parseDocument(Configuration conf, Document doc) throws IOException {
  try {
    Element root = doc.getDocumentElement();
    if (!"configuration".equals(root.getTagName())) {
      throw new IOException("bad conf file: top-level element not <configuration>");
    }
    NodeList props = root.getChildNodes();
    for (int i = 0; i < props.getLength(); i++) {
      Node propNode = props.item(i);
      if (!(propNode instanceof Element)) {
        continue;
      }
      Element prop = (Element) propNode;
      if (!"property".equals(prop.getTagName())) {
        throw new IOException("bad conf file: element not <property>");
      }
      NodeList fields = prop.getChildNodes();
      String attr = null;
      String value = null;
      for (int j = 0; j < fields.getLength(); j++) {
        Node fieldNode = fields.item(j);
        if (!(fieldNode instanceof Element)) {
          continue;
        }
        Element field = (Element) fieldNode;
        if ("name".equals(field.getTagName()) && field.hasChildNodes()) {
          attr = ((Text) field.getFirstChild()).getData().trim();
        }
        if ("value".equals(field.getTagName()) && field.hasChildNodes()) {
          value = ((Text) field.getFirstChild()).getData();
        }
      }

      if (attr != null && value != null) {
        conf.set(attr, value);
      }
    }

  } catch (DOMException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:43,代码来源:ConfigurationUtils.java

示例14: serializeElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Called to serialize a DOM element. Equivalent to calling {@link
 * #startElement}, {@link #endElement} and serializing everything
 * inbetween, but better optimized.
 */
protected void serializeElement( Element elem )
    throws IOException
{
    Node         child;
    ElementState state;
    boolean      preserveSpace;
    String       tagName;

    tagName = elem.getTagName();
    state = getElementState();
    if ( isDocumentState() ) {
        // If this is the root element handle it differently.
        // If the first root element in the document, serialize
        // the document's DOCTYPE. Space preserving defaults
        // to that of the output format.
        if ( ! _started )
            startDocument( tagName );
    }
    // For any other element, if first in parent, then
    // use the parnet's space preserving.
    preserveSpace = state.preserveSpace;

    // Do not change the current element state yet.
    // This only happens in endElement().

    // Ignore all other attributes of the element, only printing
    // its contents.

    // If element has children, then serialize them, otherwise
    // serialize en empty tag.
    if ( elem.hasChildNodes() ) {
        // Enter an element state, and serialize the children
        // one by one. Finally, end the element.
        state = enterElementState( null, null, tagName, preserveSpace );
        child = elem.getFirstChild();
        while ( child != null ) {
            serializeNode( child );
            child = child.getNextSibling();
        }
        endElementIO( tagName );
    } else {
        if ( ! isDocumentState() ) {
            // After element but parent element is no longer empty.
            state.afterElement = true;
            state.empty = false;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:TextSerializer.java

示例15: circumventBug2650internal

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * This is the work horse for {@link #circumventBug2650}.
 *
 * @param node
 * @see <A HREF="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2650">
 * Namespace axis resolution is not XPath compliant </A>
 */
@SuppressWarnings("fallthrough")
private static void circumventBug2650internal(Node node) {
    Node parent = null;
    Node sibling = null;
    final String namespaceNs = Constants.NamespaceSpecNS;
    do {
        switch (node.getNodeType()) {
        case Node.ELEMENT_NODE :
            Element element = (Element) node;
            if (!element.hasChildNodes()) {
                break;
            }
            if (element.hasAttributes()) {
                NamedNodeMap attributes = element.getAttributes();
                int attributesLength = attributes.getLength();

                for (Node child = element.getFirstChild(); child!=null;
                    child = child.getNextSibling()) {

                    if (child.getNodeType() != Node.ELEMENT_NODE) {
                        continue;
                    }
                    Element childElement = (Element) child;

                    for (int i = 0; i < attributesLength; i++) {
                        Attr currentAttr = (Attr) attributes.item(i);
                        if (!namespaceNs.equals(currentAttr.getNamespaceURI())) {
                            continue;
                        }
                        if (childElement.hasAttributeNS(namespaceNs,
                                                        currentAttr.getLocalName())) {
                            continue;
                        }
                        childElement.setAttributeNS(namespaceNs,
                                                    currentAttr.getName(),
                                                    currentAttr.getNodeValue());
                    }
                }
            }
        case Node.ENTITY_REFERENCE_NODE :
        case Node.DOCUMENT_NODE :
            parent = node;
            sibling = node.getFirstChild();
            break;
        }
        while ((sibling == null) && (parent != null)) {
            sibling = parent.getNextSibling();
            parent = parent.getParentNode();
        }
        if (sibling == null) {
            return;
        }

        node = sibling;
        sibling = node.getNextSibling();
    } while (true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:65,代码来源:XMLUtils.java


注:本文中的org.w3c.dom.Element.hasChildNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。