本文整理了Java中org.jdom2.Element.isAncestor()
方法的一些代码示例,展示了Element.isAncestor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.isAncestor()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:isAncestor
[英]Determines if this element is the ancestor of another element.
[中]确定此元素是否是另一个元素的祖先。
代码示例来源:origin: org.jdom/jdom
private final void checkPreConditions(final Content child, final int index,
final boolean replace) {
if (child == null) {
throw new NullPointerException("Cannot add null object");
}
checkIndex(index, replace);
if (child.getParent() != null) {
// the content to be added already has a parent.
final Parent p = child.getParent();
if (p instanceof Document) {
throw new IllegalAddException((Element) child,
"The Content already has an existing parent document");
}
throw new IllegalAddException(
"The Content already has an existing parent \"" +
((Element) p).getQualifiedName() + "\"");
}
if (child == parent) {
throw new IllegalAddException(
"The Element cannot be added to itself");
}
// Detect if we have <a><b><c/></b></a> and c.add(a)
if ((parent instanceof Element && child instanceof Element) &&
((Element) child).isAncestor((Element) parent)) {
throw new IllegalAddException(
"The Element cannot be added as a descendent of itself");
}
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#isAncestor(org.jdom2.Element)
* @param element {@link Element}.
* @return true/false.
*/
public boolean isAncestor( Element element )
{
return element.isAncestor( element );
}
内容来源于网络,如有侵权,请联系作者删除!