本文整理了Java中net.htmlparser.jericho.Element.getEndTag()
方法的一些代码示例,展示了Element.getEndTag()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getEndTag()
方法的具体详情如下:
包路径:net.htmlparser.jericho.Element
类名称:Element
方法名:getEndTag
[英]Returns the end tag of the element.
If the element has no end tag this method returns null
.
[中]返回元素的结束标记。
如果元素没有结束标记,则此方法返回null
。
代码示例来源: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: pl.edu.icm.synat/synat-portal-core
private CharSequence getStartTagHTML(StartTag startTag) {
// tidies and filters out non-approved attributes
StringBuilder sb = new StringBuilder();
sb.append('<').append(startTag.getName());
for (Attribute attribute : startTag.getAttributes()) {
if (allowedAttributes.contains(attribute.getKey().toLowerCase())) {
sb.append(' ').append(attribute.getName());
if (attribute.getValue() != null) {
sb.append("=\"");
sb.append(CharacterReference.encode(attribute.getValue()));
sb.append('"');
}
}
}
if (startTag.getElement().getEndTag() == null &&
!HTMLElements.getEndTagOptionalElementNames().contains(startTag.getName())) {
sb.append(" /");
}
sb.append('>');
return sb;
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
/**
* Returns the {@linkplain Element element} that is ended by this end tag.
* <p>
* Returns <code>null</code> if this end tag is not properly matched to any {@linkplain StartTag start tag} in the source document.
* <p>
* This method is much less efficient than the {@link StartTag#getElement()} method.
* <p>
* IMPLEMENTATION NOTE: The explanation for why this method is relatively inefficient lies in the fact that more than one
* {@linkplain StartTagType start tag type} can have the same
* {@linkplain StartTagType#getCorrespondingEndTagType() corresponding end tag type}, so it is not possible to know for certain
* which type of start tag this end tag is matched to (see {@link EndTagType#getCorrespondingStartTagType()} for more explanation).
* Because of this uncertainty, the implementation of this method must check every start tag preceding this end tag, calling its
* {@link StartTag#getElement()} method to see whether it is terminated by this end tag.
*
* @return the {@linkplain Element element} that is ended by this end tag.
*/
public Element getElement() {
if (element!=Element.NOT_CACHED) return element;
int pos=begin;
while (pos!=0) {
StartTag startTag=source.getPreviousStartTag(pos-1);
if (startTag==null) break;
Element foundElement=startTag.getElement(); // this automatically sets foundElement.getEndTag().element cache
if (foundElement.getEndTag()==this) return foundElement; // no need to set element as it was already done in previous statement
pos=startTag.begin;
}
return element=null;
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
attributes.appendTidy(sb,getNextTag());
} catch (IOException ex) {throw new RuntimeException(ex);} // never happens
if (startTagType==StartTagType.NORMAL && getElement().getEndTag()==null && !HTMLElements.getEndTagOptionalElementNames().contains(name)) sb.append(" /");
sb.append(startTagType.getClosingDelimiter());
return sb.toString();
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
List<StartTag> tags = sourceHtml.getAllStartTags(FORMULA_TAG_NAME);
for (StartTag tag : tags) {
EndTag endTag = tag.getElement().getEndTag();
if (endTag == null) {
logger.warn("Formula element without end tag in " + source);
if (texElement.getEndTag() == null) {
logger.warn("Tex element without end tag in " + source);
continue;
outputDocument.replace(texElement.getContent(), unescapedContent);
outputDocument.replace(texElement.getEndTag(), TEX_SCRIPT_TAG_END);
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
private boolean processTag(Tag tag, OutputDocument outputDocument) {
String elementName = tag.getName().toLowerCase();
if (!allowedTags.contains(elementName)) {
return false;
}
if (tag.getTagType() == StartTagType.NORMAL) {
Element element = tag.getElement();
if (HTMLElements.getEndTagRequiredElementNames().contains(elementName)) {
if (element.getEndTag() == null) {
return false;
}
} else if (HTMLElements.getEndTagOptionalElementNames().contains(elementName) && element.getEndTag() == null) {
outputDocument.insert(element.getEnd(), getEndTagHTML(elementName));
}
outputDocument.replace(tag, getStartTagHTML(element.getStartTag()));
return true;
}
if (tag.getTagType() == EndTagType.NORMAL) {
if (tag.getElement() == null) {
return false;
}
outputDocument.replace(tag, getEndTagHTML(elementName));
return true;
}
return false;
}
代码示例来源:origin: Netbreeze-GmbH/boilerpipe
outputDocument.remove(element.getEndTag());
代码示例来源:origin: com.github.cfparser/cfml.parsing
if (nextPos > 0 && nextPos < elem.getEndTag().getBegin()) {
endPos = nextPos;
if (elem.getEndTag() != null) {
final String cfscript = elem.getContent().toString();
visitor.visitScript(parseScript(cfscript));
代码示例来源:origin: com.github.cfparser/cfml.parsing
public ParserTag(StartTag tag) {
setName(tag.getName());
setBegin(tag.getElement().getEnd());
setEnd(tag.getElement().getBegin());
setStartTagBegin(tag.getElement().getStartTag().getBegin());
setStartTagEnd(tag.getElement().getStartTag().getEnd());
if (tag.getElement().getEndTag() != null) {
setEndTagBegin(tag.getElement().getEndTag().getBegin());
setEndTagEnd(tag.getElement().getEndTag().getEnd());
} else {
setEndTagBegin(tag.getElement().getStartTag().getBegin());
setEndTagEnd(tag.getElement().getStartTag().getEnd());
}
setAttributes(tag.getAttributes());
}
代码示例来源:origin: com.github.cfparser/cfml.parsing
public ParserTag(net.htmlparser.jericho.Tag tag) {
setName(tag.getName());
setBegin(tag.getElement().getEnd());
setEnd(tag.getElement().getBegin());
setStartTagBegin(tag.getElement().getStartTag().getBegin());
setStartTagEnd(tag.getElement().getStartTag().getEnd());
if (tag.getElement().getEndTag() != null) {
setEndTagBegin(tag.getElement().getEndTag().getBegin());
setEndTagEnd(tag.getElement().getEndTag().getEnd());
} else {
setEndTagBegin(tag.getElement().getStartTag().getBegin());
setEndTagEnd(tag.getElement().getStartTag().getEnd());
}
setAttributes(tag.getElement().getAttributes());
}
代码示例来源:origin: aria42/nlp-utils
public static int[] getCharOffsets(String html) {
int[] res = new int[html.length()];
Source source = new Source(html);
List<Element> elems = source.getAllElements();
for (int i=0; i < res.length; ++i) {
res[i] = i;
}
for (Element elem : elems) {
StartTag startTag = elem.getStartTag();
Span startSpan = getSpan(startTag);
EndTag stopTag = elem.getEndTag();
Span stopSpan = getSpan(stopTag);
for (int i=startSpan.getStart(); i < startSpan.getStop(); ++i) {
res[i] -= (startSpan.getLength() - (startSpan.getStop()-i));
}
for (int i=startSpan.getStop(); i < stopSpan.getStart(); ++i) {
res[i] -= startSpan.getLength();
}
for (int i=stopSpan.getStart(); i < stopSpan.getStop(); ++i) {
res[i] -= (stopSpan.getLength() - (stopSpan.getStop()-i)) ;
}
for (int i=stopSpan.getStop(); i < html.length(); ++i) {
res[i] -= (startSpan.getLength() + stopSpan.getLength());
}
}
return res;
}
代码示例来源:origin: cflint/CFLint
scanElement(elem, context);
String cfscript = elem.getContent().toString();
if (elem.getEndTag() == null) {
代码示例来源:origin: net.htmlparser.jericho/jericho-html
assert index<end;
final StartTag startTag=element.getStartTag();
final EndTag endTag=element.getEndTag();
appendIndent(depth);
appendTag(startTag,depth,end);
代码示例来源:origin: cflint/CFLint
scanElement(elem, context);
String cfscript = elem.getContent().toString();
if (elem.getEndTag() == null) {
代码示例来源:origin: net.htmlparser.jericho/jericho-html
final EndTag endTag=element.getEndTag();
if (endTag==null) {
assert index<=end;
内容来源于网络,如有侵权,请联系作者删除!