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


Java Node.getLastChild方法代码示例

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


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

示例1: getLastChildElementNS

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last child node with the given qualified name. */
public static Element getLastChildElementNS(Node parent,
        String[][] elemNames) {

    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            for (int i = 0; i < elemNames.length; i++) {
                String uri = child.getNamespaceURI();
                if (uri != null && uri.equals(elemNames[i][0]) &&
                        child.getLocalName().equals(elemNames[i][1])) {
                    return (Element)child;
                }
            }
        }
        child = child.getPreviousSibling();
    }

    // not found
    return null;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:DOMUtil.java

示例2: insertSourceMarkers

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static File insertSourceMarkers(@NonNull Node node, @Nullable File currentFile) {
    for (int i = 0; i < node.getChildNodes().getLength(); i++) {
        Node child = node.getChildNodes().item(i);
        short nodeType = child.getNodeType();
        if (nodeType == Node.ELEMENT_NODE
                || nodeType == Node.COMMENT_NODE
                || nodeType == Node.DOCUMENT_NODE
                || nodeType == Node.CDATA_SECTION_NODE) {
            File file = MergerXmlUtils.getFileFor(child);
            if (file != null && !file.equals(currentFile)) {
                i += insertSourceMarker(node, child, file, false);
                currentFile = file;
            }

            currentFile = insertSourceMarkers(child, currentFile);
        }
    }

    Node lastElement = node.getLastChild();
    while (lastElement != null && lastElement.getNodeType() == Node.TEXT_NODE) {
        lastElement = lastElement.getPreviousSibling();
    }
    if (lastElement != null && lastElement.getNodeType() == Node.ELEMENT_NODE) {
        File parentFile = MergerXmlUtils.getFileFor(node);
        File lastFile = MergerXmlUtils.getFileFor(lastElement);
        if (lastFile != null && parentFile != null && !parentFile.equals(lastFile)) {
            insertSourceMarker(node, lastElement, parentFile, true);
            currentFile = parentFile;
        }
    }

    return currentFile;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:34,代码来源:ManifestMerger.java

示例3: getLastChildElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last child node with the given name. */
public static Element getLastChildElement(Node parent, String elemName) {

    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            if (child.getNodeName().equals(elemName)) {
                return (Element)child;
            }
        }
        child = child.getPreviousSibling();
    }

    // not found
    return null;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:DOMUtil.java

示例4: getLastChildElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last child element node.
 *  Overload previous method for non-Xerces node impl.
 */
public static Element getLastChildElement(Node parent) {

    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            return (Element)child;
        }
        child = child.getPreviousSibling();
    }

    // not found
    return null;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:DOMUtil.java

示例5: getLastVisibleChildElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last visible child element node. */
public static Element getLastVisibleChildElement(Node parent) {

    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE &&
                !isHidden(child)) {
            return (Element)child;
        }
        child = child.getPreviousSibling();
    }

    // not found
    return null;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:DOMUtil.java

示例6: getLastElementChild

import org.w3c.dom.Node; //导入方法依赖的package包/类
private Element getLastElementChild(Node n) {
    final Node top = n;
    while (n != null) {
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            return (Element) n;
        }
        Node next = n.getLastChild();
        while (next == null) {
            if (top == n) {
                break;
            }
            next = n.getPreviousSibling();
            if (next == null) {
                n = n.getParentNode();
                if (n == null || top == n) {
                    return null;
                }
            }
        }
        n = next;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ElementImpl.java

示例7: getLastChildElementNS

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last child node with the given qualified name. */
public static Element getLastChildElementNS(Node parent,
        String uri, String localpart) {

    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String childURI = child.getNamespaceURI();
            if (childURI != null && childURI.equals(uri) &&
                    child.getLocalName().equals(localpart)) {
                return (Element)child;
            }
        }
        child = child.getPreviousSibling();
    }

    // not found
    return null;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DOMUtil.java

示例8: getLastVisibleChildElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last visible child element node.
 *  Overload previous method for non-Xerces node impl
 */
public static Element getLastVisibleChildElement(Node parent, Map<Node, String> hiddenNodes) {

    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE &&
                !isHidden(child, hiddenNodes)) {
            return (Element)child;
        }
        child = child.getPreviousSibling();
    }

    // not found
    return null;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:DOMUtil.java

示例9: getLastChild

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Internal function.
 *  Return the last child Node, from the input node
 *  after applying filter, whatToshow.
 *  The current node is not consulted or set.
 */
Node getLastChild(Node node) {

    if (node == null) return null;

    if ( !fEntityReferenceExpansion
         && node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
        return null;

    Node newNode = node.getLastChild();
    if (newNode == null)  return null;

    int accept = acceptNode(newNode);

    if (accept == NodeFilter.FILTER_ACCEPT)
        return newNode;
    else
    if (accept == NodeFilter.FILTER_SKIP
        && newNode.hasChildNodes())
    {
        Node lChild = getLastChild(newNode);
        if (lChild == null) {
            return getPreviousSibling(newNode, node);
        }
        return lChild;
    }
    else
    //if (accept == NodeFilter.REJECT_NODE)
    {
        return getPreviousSibling(newNode, node);
    }


}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:TreeWalkerImpl.java

示例10: previousNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** The method previousNode(Node) returns the previous node
 *  from the actual DOM tree.
 */
Node previousNode(Node node) {

    Node result;

    // if we're at the root, return null.
    if (node == fRoot) return null;

    // get sibling
    result = node.getPreviousSibling();
    if (result == null) {
        //if 1st sibling, return parent
        result = node.getParentNode();
        return result;
    }

    // if sibling has children, keep getting last child of child.
    if (result.hasChildNodes()
        && !(!fEntityReferenceExpansion
            && result != null
            && result.getNodeType() == Node.ENTITY_REFERENCE_NODE))

    {
        while (result.hasChildNodes()) {
            result = result.getLastChild();
        }
    }

    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:NodeIteratorImpl.java

示例11: convertToFinalForm

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static void convertToFinalForm(Node program) throws TransformerException
{
	Element functions = doc.createElement("functions");
	Element dataStructures = doc.createElement("structures");
	Element init = doc.createElement("init");

	removeFunctions(program, functions);
	removeDataStructures(program, dataStructures);
	Node initCode = program.getFirstChild();
	Node globalVariable = initCode.getLastChild();

	while (globalVariable.getNodeName().equals("uses"))
	{
		dataStructures.appendChild(globalVariable.cloneNode(true));
		globalVariable = globalVariable.getPreviousSibling();
		initCode.removeChild(globalVariable.getNextSibling());
	}

	init.appendChild(initCode.cloneNode(true));

	while (program.hasChildNodes())
		program.removeChild(program.getFirstChild());

	NodeList myFunctions = functions.getChildNodes();

	for (int i = 0; i < myFunctions.getLength();i++)
	{
		for (Node temp = myFunctions.item(i).getLastChild();temp != null;temp = temp.getPreviousSibling())
		{
			if (temp.getLastChild().getTextContent().equals(myFunctions.item(i).getFirstChild().getTextContent()))
			{
				myFunctions.item(i).removeChild(temp);
				break;
			}
		}
	}

	Element callMain = doc.createElement("op");
	callMain.setAttribute("name", "CALL");
	callMain.setAttribute("type", "void");

	Element mainName = doc.createElement("value");
	mainName.setTextContent("main");

	callMain.appendChild(mainName);

	Element mainParams = doc.createElement("op");
	mainParams.setAttribute("name", "NO_ARG");
	mainParams.setAttribute("type", "");

	callMain.appendChild(mainParams);

	init.appendChild(callMain);

	Element haltProgram = doc.createElement("op");
	haltProgram.setAttribute("name", "HALT");
	init.appendChild(haltProgram);

	program.appendChild(init);
	program.appendChild(functions);
	program.appendChild(dataStructures);
}
 
开发者ID:Christopher-Chianelli,项目名称:ccpa,代码行数:63,代码来源:TreeOptimizer.java

示例12: setStructIndices

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void setStructIndices(Node program)
{
	Node structures = program.getLastChild();
	for (Node n = structures.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if (n.getNodeName().equals("data"))
		{
			String kind = n.getAttributes().getNamedItem("kind").getTextContent();
			if (kind.equals("STRUCT"))
			{
				int totalSize = 0;
				for (Node child = n.getLastChild(); !child.getNodeName().equals("value"); child = child.getPreviousSibling())
				{
					TreeToAE2.setIndexOf("struct " + n.getFirstChild().getTextContent(), child.getLastChild().getTextContent(), totalSize);
					try
					{
					    totalSize += TreeToAE2.getSizeOf(child.getFirstChild().getTextContent());
					}
					catch(Exception e)
					{
					}
				}
			}
			else if (kind.equals("UNION"))
			{
				for (Node child = n.getLastChild(); !child.getNodeName().equals("value"); child = child.getPreviousSibling())
				{
					TreeToAE2.setIndexOf("union " + n.getFirstChild().getTextContent(), child.getLastChild().getTextContent(), 0);
				}
			}
			else if (kind.equals("ENUM"))
			{
				int i = 0;
				for (Node child = n.getLastChild(); !child.getNodeName().equals("value"); child = child.getPreviousSibling())
				{
					TreeToAE2.setIndexOf("union " + n.getFirstChild().getTextContent(), child.getLastChild().getTextContent(), i);
					i++;
				}
			}
		}
	}
}
 
开发者ID:Christopher-Chianelli,项目名称:ccpa,代码行数:43,代码来源:TreeTransformer.java

示例13: synchronizeData

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Synchronizes the node's data. */
protected void synchronizeData() {

    // no need to sync in the future
    needsSyncData(false);

    // fluff up enough nodes to fill identifiers hash
    if (fIdElement != null) {

        // REVISIT: There has to be a more efficient way of
        //          doing this. But keep in mind that the
        //          tree can have been altered and re-ordered
        //          before all of the element nodes with ID
        //          attributes have been registered. For now
        //          this is reasonable and safe. -Ac

        IntVector path = new IntVector();
        for (int i = 0; i < fIdCount; i++) {

            // ignore if it's already been registered
            int elementNodeIndex = fIdElement[i];
            String idName      = fIdName[i];
            if (idName == null) {
                continue;
            }

            // find path from this element to the root
            path.removeAllElements();
            int index = elementNodeIndex;
            do {
                path.addElement(index);
                int pchunk = index >> CHUNK_SHIFT;
                int pindex = index & CHUNK_MASK;
                index = getChunkIndex(fNodeParent, pchunk, pindex);
            } while (index != -1);

            // Traverse path (backwards), fluffing the elements
            // along the way. When this loop finishes, "place"
            // will contain the reference to the element node
            // we're interested in. -Ac
            Node place = this;
            for (int j = path.size() - 2; j >= 0; j--) {
                index = path.elementAt(j);
                Node child = place.getLastChild();
                while (child != null) {
                    if (child instanceof DeferredNode) {
                        int nodeIndex =
                            ((DeferredNode)child).getNodeIndex();
                        if (nodeIndex == index) {
                            place = child;
                            break;
                        }
                    }
                    child = child.getPreviousSibling();
                }
            }

            // register the element
            Element element = (Element)place;
            putIdentifier0(idName, element);
            fIdName[i] = null;

            // see if there are more IDs on this element
            while (i + 1 < fIdCount &&
                fIdElement[i + 1] == elementNodeIndex) {
                idName = fIdName[++i];
                if (idName == null) {
                    continue;
                }
                putIdentifier0(idName, element);
            }
        }

    } // if identifiers

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:77,代码来源:DeferredDocumentImpl.java

示例14: getLastChildElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Returns the last child element of the specified node, or null if there
 * is no such element.
 *
 * @param node the node
 * @return the last child element of the specified node, or null if there
 *    is no such element
 * @throws NullPointerException if <code>node == null</code>
 */
public static Element getLastChildElement(Node node) {
    Node child = node.getLastChild();
    while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
        child = child.getPreviousSibling();
    }
    return (Element)child;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:DOMUtils.java


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