本文整理匯總了Java中com.google.gwt.dom.client.Node.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.equals方法的具體用法?Java Node.equals怎麽用?Java Node.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.dom.client.Node
的用法示例。
在下文中一共展示了Node.equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSameNode
import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public boolean isSameNode(Node node, Node other) {
// TODO(danilatos): Use .equals or isSameNode for nodelets in nodemanager,
// typing extractor, etc.
return node == other || (node != null && node.equals(other));
}
示例2: print
import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
/**
* @param n Node to pretty print
* @param selection Selection to mark in pretty print
* @param indent Indentation level to print with.
* @param multiLine True if output should be multi-line
* @return A pretty-print HTML string (with '<' and '>' already escaped)
*/
private static String print(Node n, PointRange<Node> selection, int indent, boolean multiLine) {
// Inspect selection's relevance to this element
boolean collapsed = selection != null && selection.isCollapsed();
boolean printStartMarker =
selection != null && selection.getFirst().getContainer().equals(n);
boolean printEndMarker =
selection != null && !collapsed && selection.getSecond().getContainer().equals(n);
String startMarker =
printStartMarker ? (collapsed ? "|" : "[") : "";
String endMarker = printEndMarker ? "]" : "";
if (DomHelper.isTextNode(n)) {
// Print text node as 'value'
String value = displayWhitespace(n.getNodeValue());
int startOffset = printStartMarker ? selection.getFirst().getTextOffset() : 0;
int endOffset = printEndMarker ? selection.getSecond().getTextOffset() : value.length();
String ret = "'" + value.substring(0, startOffset)
+ startMarker
+ value.substring(startOffset, endOffset)
+ endMarker
+ value.substring(endOffset, value.length())
+ "'" ;
return multiLine ? StringUtil.xmlEscape(ret) : ret;
} else {
Element e = n.cast();
if (e.getChildCount() == 0) {
// Print child-less element as self-closing tag
return startTag(e, true, multiLine);
} else {
boolean singleLineHtml = multiLine &&
(e.getChildCount() == 1 &&
e.getFirstChild()
.getChildCount() == 0);
// Print element w/ children. One line each for start tag, child, end tag
String pretty = startTag(e, false, multiLine);
Node child = e.getFirstChild();
Node startNodeAfter = selection.getFirst().getNodeAfter();
Node endNodeAfter = selection.getSecond().getNodeAfter();
while (child != null) {
pretty += (multiLine && !singleLineHtml ? newLine(indent + 1) : "")
+ (printStartMarker && child.equals(startNodeAfter) ? startMarker : "")
+ (printEndMarker && child.equals(endNodeAfter) ? endMarker : "")
+ print(child, selection, indent + 1, multiLine);
child = child.getNextSibling();
}
if (printEndMarker && endNodeAfter == null) {
pretty += endMarker;
}
return pretty + (multiLine && !singleLineHtml ? newLine(indent) : "")
+ endTag(e, multiLine);
}
}
}