本文整理匯總了Java中org.w3c.dom.Node.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.equals方法的具體用法?Java Node.equals怎麽用?Java Node.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.Node
的用法示例。
在下文中一共展示了Node.equals方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: canGenerateSelectionXpath
import org.w3c.dom.Node; //導入方法依賴的package包/類
private boolean canGenerateSelectionXpath(boolean overwrite, Node node) {
boolean bSelectionMenu = (currentAnchor == null);
if (bSelectionMenu && !overwrite) {
Node curNode = node instanceof Attr ? ((Attr) node).getOwnerElement() : node;
Node root = node.getOwnerDocument().getFirstChild();
if (curNode.equals(root)) {
bSelectionMenu = false;
} else {
NodeList nodeList = root.getChildNodes();
for (int i = 0; i < nodeList.getLength() && bSelectionMenu; i++) {
bSelectionMenu = !nodeList.item(i).equals(curNode);
}
}
}
return bSelectionMenu;
}
示例2: contains
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Tell if the table contains the given node.
*
* @param s Node to look for
*
* @return True if the given node was found.
*/
public boolean contains(Node s)
{
runTo(-1);
if (null == m_map)
return false;
for (int i = 0; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(s))
return true;
}
return false;
}
示例3: indexOf
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Searches for the first occurence of the given argument,
* beginning the search at index, and testing for equality
* using the equals method.
*
* @param elem Node to look for
* @param index Index of where to start the search
* @return the index of the first occurrence of the object
* argument in this vector at position index or later in the
* vector; returns -1 if the object is not found.
*/
public int indexOf(Node elem, int index)
{
runTo(-1);
if (null == m_map)
return -1;
for (int i = index; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(elem))
return i;
}
return -1;
}
示例4: indexOf
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Searches for the first occurence of the given argument,
* beginning the search at index, and testing for equality
* using the equals method.
*
* @param elem Node to look for
* @return the index of the first occurrence of the object
* argument in this vector at position index or later in the
* vector; returns -1 if the object is not found.
*/
public int indexOf(Node elem)
{
runTo(-1);
if (null == m_map)
return -1;
for (int i = 0; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(elem))
return i;
}
return -1;
}
示例5: removeElement
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Removes the first occurrence of the argument from this vector.
* If the object is found in this vector, each component in the vector
* with an index greater or equal to the object's index is shifted
* downward to have an index one smaller than the value it had
* previously.
*
* @param s Node to remove from the list
*
* @return True if the node was successfully removed
*/
public boolean removeElement(Node s)
{
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if (null == m_map)
return false;
for (int i = 0; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(s))
{
if (i < m_firstFree - 1)
System.arraycopy(m_map, i + 1, m_map, i, m_firstFree - i - 1);
m_firstFree--;
m_map[m_firstFree] = null;
return true;
}
}
return false;
}
示例6: traverseFragment
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Perform a pre-order traversal non-recursive style.
*
* In contrast to the traverse() method this method will not issue
* startDocument() and endDocument() events to the SAX listener.
*
* @param pos Node in the tree where to start traversal
*
* @throws TransformerException
*/
public void traverseFragment(Node pos) throws org.xml.sax.SAXException
{
Node top = pos;
while (null != pos)
{
startNode(pos);
Node nextNode = pos.getFirstChild();
while (null == nextNode)
{
endNode(pos);
if (top.equals(pos))
break;
nextNode = pos.getNextSibling();
if (null == nextNode)
{
pos = pos.getParentNode();
if ((null == pos) || (top.equals(pos)))
{
if (null != pos)
endNode(pos);
nextNode = null;
break;
}
}
}
pos = nextNode;
}
}
示例7: traverse
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Perform a pre-order traversal non-recursive style.
* Note that TreeWalker assumes that the subtree is intended to represent
* a complete (though not necessarily well-formed) document and, during a
* traversal, startDocument and endDocument will always be issued to the
* SAX listener.
*
* @param pos Node in the tree where to start traversal
* @param top Node in the tree where to end traversal
*
* @throws TransformerException
*/
public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
{
this.m_contentHandler.startDocument();
while (null != pos)
{
startNode(pos);
Node nextNode = pos.getFirstChild();
while (null == nextNode)
{
endNode(pos);
if ((null != top) && top.equals(pos))
break;
nextNode = pos.getNextSibling();
if (null == nextNode)
{
pos = pos.getParentNode();
if ((null == pos) || ((null != top) && top.equals(pos)))
{
nextNode = null;
break;
}
}
}
pos = nextNode;
}
this.m_contentHandler.endDocument();
}
示例8: areSameNodes
import org.w3c.dom.Node; //導入方法依賴的package包/類
@Override
public boolean areSameNodes(Node n1, Node n2) {
return n1.equals(n2);
}
示例9: calcXpath
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Compute the xpath of a node relative to an anchor.
*
* @param node
* node to find the xpath from.
* @param anchor
* the relative point to fid from.
* @return the computed xpath.
*/
public static String calcXpath(Node node, Node anchor) {
String xpath = "";
Node current = null;
if (node == null || node.equals(anchor))
return "";
// add attribute to xpath
if (node instanceof Attr) {
Attr attr = (Attr) node;
node = attr.getOwnerElement();
xpath = '@' + attr.getName() + '/';
}
while ((current = node.getParentNode()) != anchor) {
Engine.logEngine.trace("Calc Xpath : current node : " + current.getNodeName());
NodeList childs = current.getChildNodes();
int index = 0;
for (int i = 0; i < childs.getLength(); i++) {
if (childs.item(i).getNodeType() != Node.ELEMENT_NODE
&& !childs.item(i).getNodeName().equalsIgnoreCase("#text"))
continue;
Engine.logEngine.trace("Calc Xpath : ==== > Child node : " + childs.item(i).getNodeName());
// Bump the index if we have the same tag names..
if (childs.item(i).getNodeName().equalsIgnoreCase(node.getNodeName())) {
// tag names are equal ==> bump the index.
index++;
// is our node the one that is listed ?
if (childs.item(i).equals(node))
// We found our node in the parent node list
break;
}
}
// count the number of elements having the same tag
int nbElements = 0;
for (int i = 0; i < childs.getLength(); i++) {
if (childs.item(i).getNodeName().equalsIgnoreCase(node.getNodeName())) {
nbElements++;
}
}
String name = node.getNodeName();
if (name.equalsIgnoreCase("#text"))
name = "text()";
name = xpathEscapeColon(name);
if (nbElements > 1) {
xpath = name + "[" + index + "]/" + xpath;
} else {
// only one element had the same tag ==> do not compute the [xx]
// syntax..
xpath = name + "/" + xpath;
}
node = current;
}
if (xpath.length() > 0)
// remove the trailing '/'
xpath = xpath.substring(0, xpath.length() - 1);
return xpath;
}
示例10: undeferChildren
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Traverses the DOM Tree and expands deferred nodes and their
* children.
*
*/
protected void undeferChildren(Node node) {
Node top = node;
while (null != node) {
if (((NodeImpl)node).needsSyncData()) {
((NodeImpl)node).synchronizeData();
}
NamedNodeMap attributes = node.getAttributes();
if (attributes != null) {
int length = attributes.getLength();
for (int i = 0; i < length; ++i) {
undeferChildren(attributes.item(i));
}
}
Node nextNode = null;
nextNode = node.getFirstChild();
while (null == nextNode) {
if (top.equals(node))
break;
nextNode = node.getNextSibling();
if (null == nextNode) {
node = node.getParentNode();
if ((null == node) || (top.equals(node))) {
nextNode = null;
break;
}
}
}
node = nextNode;
}
}
示例11: traverse
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Perform a pre-order traversal non-recursive style.
*
* Note that TreeWalker assumes that the subtree is intended to represent
* a complete (though not necessarily well-formed) document and, during a
* traversal, startDocument and endDocument will always be issued to the
* SAX listener.
*
* @param pos Node in the tree where to start traversal
*
* @throws TransformerException
*/
public void traverse(Node pos) throws org.xml.sax.SAXException {
this.fSerializer.startDocument();
// Determine if the Node is a DOM Level 3 Core Node.
if (pos.getNodeType() != Node.DOCUMENT_NODE) {
Document ownerDoc = pos.getOwnerDocument();
if (ownerDoc != null
&& ownerDoc.getImplementation().hasFeature("Core", "3.0")) {
fIsLevel3DOM = true;
}
} else {
if (((Document) pos)
.getImplementation()
.hasFeature("Core", "3.0")) {
fIsLevel3DOM = true;
}
}
if (fSerializer instanceof LexicalHandler) {
fLexicalHandler = ((LexicalHandler) this.fSerializer);
}
if (fFilter != null)
fWhatToShowFilter = fFilter.getWhatToShow();
Node top = pos;
while (null != pos) {
startNode(pos);
Node nextNode = null;
nextNode = pos.getFirstChild();
while (null == nextNode) {
endNode(pos);
if (top.equals(pos))
break;
nextNode = pos.getNextSibling();
if (null == nextNode) {
pos = pos.getParentNode();
if ((null == pos) || (top.equals(pos))) {
if (null != pos)
endNode(pos);
nextNode = null;
break;
}
}
}
pos = nextNode;
}
this.fSerializer.endDocument();
}