本文整理了Java中net.htmlparser.jericho.Element.getParentElement()
方法的一些代码示例,展示了Element.getParentElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getParentElement()
方法的具体详情如下:
包路径:net.htmlparser.jericho.Element
类名称:Element
方法名:getParentElement
[英]Returns the parent of this element in the document element hierarchy.
The Source#fullSequentialParse() method must be called (either explicitly or implicitly) immediately after construction of the Source
object if this method is to be used. An IllegalStateException
is thrown if a full sequential parse has not been performed or if it was performed after this element was found.
This method returns null
for a top-level element, as well as any element formed from a TagType#isServerTag(), regardless of whether it is nested inside a normal element.
See the Source#getChildElements() method for more details.
[中]返回文档元素层次结构中此元素的父级。
如果要使用Source#fullSequentialParse()方法,则必须在构造Source
对象后立即(显式或隐式)调用该方法。如果未执行完整的顺序分析,或者在找到此元素后执行,则会抛出IllegalStateException
。
此方法返回{$0$}的null
,以及由TagType#isServerTag()形成的任何元素,而不管它是否嵌套在普通元素中。
有关详细信息,请参阅源代码#getChildElements()方法。
代码示例来源:origin: net.htmlparser.jericho/jericho-html
/**
* Returns the nesting depth of this element in the document element hierarchy.
* <p>
* The {@link Source#fullSequentialParse()} method must be called (either explicitly or implicitly) after construction of the <code>Source</code> object if this method is to be used.
* An <code>IllegalStateException</code> is thrown if a full sequential parse has not been performed or if it was performed after this element was found.
* <p>
* A <a href="Source.html#TopLevelElement">top-level element</a> has a nesting depth of <code>0</code>.
* <p>
* An element formed from a {@linkplain TagType#isServerTag() server tag} always have a nesting depth of <code>0</code>,
* regardless of whether it is nested inside a normal element.
* <p>
* See the {@link Source#getChildElements()} method for more details.
*
* @return the nesting depth of this element in the document element hierarchy.
* @throws IllegalStateException if a {@linkplain Source#fullSequentialParse() full sequential parse} has not been performed or if it was performed after this element was found.
* @see #getParentElement()
*/
public int getDepth() {
if (depth==-1) {
getParentElement();
if (depth==-1) depth=0;
}
return depth;
}
代码示例来源:origin: cflint/CFLint
public static Element getNamedParent(final Element elem, final String tagName) {
Element parentElem = elem.getParentElement();
while (parentElem != null && !parentElem.getName().equals(tagName)) {
parentElem = parentElem.getParentElement();
}
return parentElem;
}
代码示例来源:origin: cflint/CFLint
public static Element getNamedParent(final Element elem, final String tagName) {
Element parentElem = elem.getParentElement();
while (parentElem != null && !parentElem.getName().equals(tagName)) {
parentElem = parentElem.getParentElement();
}
return parentElem;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
private String getClosingTagsBehindElement(Element element) {
StringBuilder closingTags = new StringBuilder();
Element parent = element.getParentElement();
while (parent != null) {
closingTags.append( (parent.getEndTag() == null) ? "" : ("</" + parent.getEndTag().getName() + ">") );
parent = parent.getParentElement();
}
return closingTags.toString();
}
代码示例来源:origin: cflint/CFLint
/**
* Returns the previous sibling of a given element
*
* @param element
* The Jericho HTML element object
* @return the previous sibling of the given element.
*/
public static Element getPreviousSibling(final Element element) {
if (element.getParentElement() != null) {
final List<Element> parentElements = element.getParentElement().getChildElements();
final int idx = parentElements.indexOf(element);
if (idx > 0) {
return parentElements.get(idx - 1);
}
} else if (element.getSource() != null) {
final List<Element> parentElements = element.getSource().getChildElements();
final int idx = parentElements.indexOf(element);
if (idx > 0) {
return parentElements.get(idx - 1);
}
}
return null;
}
代码示例来源:origin: cflint/CFLint
/**
* Returns the previous sibling of a given element
*
* @param element
* The Jericho HTML element object
* @return the previous sibling of the given element.
*/
public static Element getPreviousSibling(final Element element) {
if (element.getParentElement() != null) {
final List<Element> parentElements = element.getParentElement().getChildElements();
final int idx = parentElements.indexOf(element);
if (idx > 0) {
return parentElements.get(idx - 1);
}
} else if (element.getSource() != null) {
final List<Element> parentElements = element.getSource().getChildElements();
final int idx = parentElements.indexOf(element);
if (idx > 0) {
return parentElements.get(idx - 1);
}
}
return null;
}
代码示例来源:origin: cflint/CFLint
elem = elem.getParentElement();
代码示例来源:origin: cflint/CFLint
elem = elem.getParentElement();
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final String name = element.getAttributeValue(CF.NAME) != null
? element.getAttributeValue(CF.NAME) : "";
ArgInfo argInfo = new ArgInfo();
argInfo.casedName=name;
argInfo.argumentLineNo=context.startLine();
argInfo.argumentOffset=element.getAttributeValue(CF.NAME) != null
? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : element.getBegin();
argInfo.type=element.getAttributeValue(CF.TYPE);
currentArgs.put(name.toLowerCase(), argInfo);
final String code = element.getParentElement().toString();
if (isUsed(code, name.toLowerCase())) {
argInfo.used=true;
}
}
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final String name = element.getAttributeValue(CF.NAME) != null
? element.getAttributeValue(CF.NAME) : "";
ArgInfo argInfo = new ArgInfo();
argInfo.casedName=name;
argInfo.argumentLineNo=context.startLine();
argInfo.argumentOffset=element.getAttributeValue(CF.NAME) != null
? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : element.getBegin();
argInfo.type=element.getAttributeValue(CF.TYPE);
currentArgs.put(name.toLowerCase(), argInfo);
final String code = element.getParentElement().toString();
if (isUsed(code, name.toLowerCase())) {
argInfo.used=true;
}
}
}
代码示例来源:origin: org.zaproxy/zap
while ((element = element.getParentElement()) != null) {
context.addParentTag(element.getName());
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final String name = element.getAttributeValue(CF.NAME);
final boolean required = CFTool.toBoolean(element.getAttributeValue(CF.REQUIRED));
final String defaultExpr = element.getAttributeValue(CF.DEFAULT);
final String code = element.getParentElement().toString();
final boolean checked = isCheck(code, name);
if (!required && defaultExpr == null && !checked) {
element.getSource().getRow(element.getBegin());
element.getSource().getColumn(element.getBegin());
context.addMessage("ARG_DEFAULT_MISSING", name);
}
}
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final String name = element.getAttributeValue(CF.NAME);
final boolean required = CFTool.toBoolean(element.getAttributeValue(CF.REQUIRED));
final String defaultExpr = element.getAttributeValue(CF.DEFAULT);
final String code = element.getParentElement().toString();
final boolean checked = isCheck(code, name);
if (!required && defaultExpr == null && !checked) {
element.getSource().getRow(element.getBegin());
element.getSource().getColumn(element.getBegin());
context.addMessage("ARG_DEFAULT_MISSING", name);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!