本文整理了Java中net.htmlparser.jericho.Element.getEnd()
方法的一些代码示例,展示了Element.getEnd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getEnd()
方法的具体详情如下:
包路径:net.htmlparser.jericho.Element
类名称:Element
方法名:getEnd
[英]Returns the end tag of the element.
If the element has no end tag this method returns null
.
[中]返回元素的结束标记。
如果元素没有结束标记,则此方法返回null
。
代码示例来源:origin: cflint/CFLint
/**
* Determine the line numbers of the <!--- @CFLintIgnore CFQUERYPARAM_REQ ---> tags
* Both the current and the next line are included.
*
* @param element the element object
* @return the line numbers of any @@CFLintIgnore annotations.
*/
private List<Integer> determineIgnoreLines(final Element element) {
final List<Integer> ignoreLines = new ArrayList<>();
for (Element comment : element.getChildElements()) {
if ("!---".equals(comment.getName()) && comment.toString().contains("@CFLintIgnore") && comment.toString().contains("CFQUERYPARAM_REQ")) {
int ignoreLine = comment.getSource().getRow(comment.getEnd());
ignoreLines.add(ignoreLine);
ignoreLines.add(ignoreLine + 1);
ignoreLines.add(comment.getSource().getRow(comment.getBegin()));
} else {
ignoreLines.addAll(determineIgnoreLines(comment));
}
}
return ignoreLines;
}
代码示例来源: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: pl.edu.icm.synat/synat-portal-core
private String processFirstTagOutOfBounds(String source, Tag tag, int maxLength, int tagSpace) {
String cutHtml = null;
if (tag.getTagType() == StartTagType.NORMAL) {
int whitespacePos = maxLength + tagSpace - 1;
while (whitespacePos < source.length() &&
!Character.isWhitespace(source.charAt(whitespacePos)) &&
!PUNCTUATION_SIGNS.contains(source.charAt(whitespacePos))) {
++whitespacePos;
}
cutHtml = (whitespacePos < tag.getBegin()) ? source.substring(0, whitespacePos) : source.substring(0, tag.getBegin());
return cutHtml + getClosingTagsBehindElement(tag.getElement()) + SHORTED_FORM_END;
} else {
cutHtml = source.substring(0, tag.getEnd());
boolean appendShorteningSign = true;
if (tag.getElement() == null) {
logger.error("DATA ERROR: No element in tag {}", source);
return cutHtml + SHORTED_FORM_END;
} else if (tag.getElement().getEnd() == source.length()) {
appendShorteningSign = false;
}
return cutHtml + getClosingTagsBehindElement(tag.getElement()) + ((appendShorteningSign) ? SHORTED_FORM_END : "");
}
}
代码示例来源: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: cflint/CFLint
/**
* Determine the line numbers of the <!--- @CFLintIgnore CFQUERYPARAM_REQ ---> tags
* Both the current and the next line are included.
*
* @param element the element object
* @return the line numbers of any @@CFLintIgnore annotations.
*/
private List<Integer> determineIgnoreLines(final Element element) {
final List<Integer> ignoreLines = new ArrayList<>();
for (Element comment : element.getChildElements()) {
if ("!---".equals(comment.getName()) && comment.toString().contains("@CFLintIgnore") && comment.toString().contains("CFQUERYPARAM_REQ")) {
int ignoreLine = comment.getSource().getRow(comment.getEnd());
ignoreLines.add(ignoreLine);
ignoreLines.add(ignoreLine + 1);
ignoreLines.add(comment.getSource().getRow(comment.getBegin()));
} else {
ignoreLines.addAll(determineIgnoreLines(comment));
}
}
return ignoreLines;
}
代码示例来源: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: konsoletyper/teavm-flavour
private TemplateNode parseComponent(Element elem) {
int prefixLength = elem.getName().indexOf(':');
String prefix = elem.getName().substring(0, prefixLength);
String name = elem.getName().substring(prefixLength + 1);
String fullName = prefix + ":" + name;
ElementComponentMetadata componentMeta = resolveComponent(prefix, name);
if (componentMeta == null) {
error(elem.getStartTag().getNameSegment(), "Undefined component " + fullName);
return null;
}
List<PostponedComponentParse> postponedList = new ArrayList<>();
TemplateNode node = parseComponent(componentMeta, prefix, name, elem, postponedList,
new MapSubstitutions(new HashMap<>()));
completeComponentParsing(postponedList, componentMeta, elem);
position = elem.getEnd();
return node;
}
代码示例来源:origin: org.teavm.flavour/teavm-flavour-templates
private TemplateNode parseComponent(Element elem) {
int prefixLength = elem.getName().indexOf(':');
String prefix = elem.getName().substring(0, prefixLength);
String name = elem.getName().substring(prefixLength + 1);
String fullName = prefix + ":" + name;
ElementComponentMetadata componentMeta = resolveComponent(prefix, name);
if (componentMeta == null) {
error(elem.getStartTag().getNameSegment(), "Undefined component " + fullName);
return null;
}
List<PostponedComponentParse> postponedList = new ArrayList<>();
TemplateNode node = parseComponent(componentMeta, prefix, name, elem, postponedList,
new MapSubstitutions(new HashMap<>()));
completeComponentParsing(postponedList, componentMeta, elem);
position = elem.getEnd();
return node;
}
代码示例来源:origin: org.teavm.flavour/teavm-flavour-templates
private void parseTag(Tag tag, List<TemplateNode> result, Predicate<Element> filter) {
if (tag instanceof StartTag) {
StartTag startTag = (StartTag) tag;
if (startTag.getStartTagType() == StartTagType.XML_PROCESSING_INSTRUCTION) {
parseProcessingInstruction(startTag);
} else if (startTag.getStartTagType() == StartTagType.NORMAL) {
if (filter.test(tag.getElement())) {
TemplateNode node = parseElement(tag.getElement());
if (node != null) {
result.add(node);
}
} else {
position = tag.getElement().getEnd();
}
}
}
}
代码示例来源:origin: konsoletyper/teavm-flavour
private void parseTag(Tag tag, List<TemplateNode> result, Predicate<Element> filter) {
if (tag instanceof StartTag) {
StartTag startTag = (StartTag) tag;
if (startTag.getStartTagType() == StartTagType.XML_PROCESSING_INSTRUCTION) {
parseProcessingInstruction(startTag);
} else if (startTag.getStartTagType() == StartTagType.NORMAL) {
if (filter.test(tag.getElement())) {
TemplateNode node = parseElement(tag.getElement());
if (node != null) {
result.add(node);
}
} else {
position = tag.getElement().getEnd();
}
}
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
if (!elementContainsMarkup) {
final Element element=tag.getElement();
if (element!=null && element.getEnd()>tag.getEnd()) nodeIterator.skipToPos(element.getEnd());
final StartTag startTag=(StartTag)tag;
if (tag.name==HTMLElementName.SCRIPT || tag.name==HTMLElementName.STYLE || excludeElement(startTag) || (excludeNonHTMLElements && !HTMLElements.getElementNames().contains(tag.name))) {
nodeIterator.skipToPos(startTag.getElement().getEnd());
continue;
代码示例来源:origin: httl/httl
document.insert(element.getEnd(), buf.toString()); // 插入结束指令
代码示例来源:origin: com.github.httl/httl
document.insert(element.getEnd(), buf.toString()); // 插入结束指令
代码示例来源:origin: com.github.cfparser/cfml.parsing
int endPosition = element.getEnd();
String name = element.getName();
String itemData = element.getTextExtractor().toString();
代码示例来源:origin: konsoletyper/teavm-flavour
private ComponentBinding parseComponent(ElementComponentMetadata componentMeta, String prefix, String name,
Element elem, List<PostponedComponentParse> postponed, MapSubstitutions typeVars) {
ComponentBinding component = new ComponentBinding(componentMeta.cls.getName(), name);
component.setLocation(new Location(elem.getBegin(), elem.getEnd()));
if (componentMeta.nameSetter != null) {
component.setElementNameMethodName(componentMeta.nameSetter.getName());
postponed.add(componentParse);
parseSegment(elem.getEnd(), new ArrayList<>(), child -> {
int nestedPrefixLength = child.getName().indexOf(':');
if (nestedPrefixLength > 0) {
代码示例来源:origin: org.teavm.flavour/teavm-flavour-templates
private ComponentBinding parseComponent(ElementComponentMetadata componentMeta, String prefix, String name,
Element elem, List<PostponedComponentParse> postponed, MapSubstitutions typeVars) {
ComponentBinding component = new ComponentBinding(componentMeta.cls.getName(), name);
component.setLocation(new Location(elem.getBegin(), elem.getEnd()));
if (componentMeta.nameSetter != null) {
component.setElementNameMethodName(componentMeta.nameSetter.getName());
postponed.add(componentParse);
parseSegment(elem.getEnd(), new ArrayList<>(), child -> {
int nestedPrefixLength = child.getName().indexOf(':');
if (nestedPrefixLength > 0) {
代码示例来源:origin: konsoletyper/teavm-flavour
private TemplateNode parseDomElement(Element elem) {
DOMElement templateElem = new DOMElement(elem.getName());
templateElem.setLocation(new Location(elem.getBegin(), elem.getEnd()));
for (int i = 0; i < elem.getAttributes().size(); ++i) {
Attribute attr = elem.getAttributes().get(i);
if (attr.getName().indexOf(':') > 0) {
AttributeComponentBinding component = parseAttributeComponent(attr);
if (component != null) {
templateElem.getAttributeComponents().add(component);
}
} else {
templateElem.setAttribute(attr.getName(), attr.getValue(),
new Location(attr.getBegin(), attr.getEnd()));
}
}
Set<String> vars = new HashSet<>();
for (AttributeComponentBinding attrComponent : templateElem.getAttributeComponents()) {
for (ComponentVariableBinding var : attrComponent.getVariables()) {
vars.add(var.getName());
pushVar(var.getName(), var.getValueType());
}
}
parseSegment(elem.getEnd(), templateElem.getChildNodes(), child -> true);
for (String var : vars) {
popVar(var);
}
return templateElem;
}
代码示例来源:origin: org.teavm.flavour/teavm-flavour-templates
private TemplateNode parseDomElement(Element elem) {
DOMElement templateElem = new DOMElement(elem.getName());
templateElem.setLocation(new Location(elem.getBegin(), elem.getEnd()));
for (int i = 0; i < elem.getAttributes().size(); ++i) {
Attribute attr = elem.getAttributes().get(i);
if (attr.getName().indexOf(':') > 0) {
AttributeComponentBinding component = parseAttributeComponent(attr);
if (component != null) {
templateElem.getAttributeComponents().add(component);
}
} else {
templateElem.setAttribute(attr.getName(), attr.getValue(),
new Location(attr.getBegin(), attr.getEnd()));
}
}
Set<String> vars = new HashSet<>();
for (AttributeComponentBinding attrComponent : templateElem.getAttributeComponents()) {
for (ComponentVariableBinding var : attrComponent.getVariables()) {
vars.add(var.getName());
pushVar(var.getName(), var.getValueType());
}
}
parseSegment(elem.getEnd(), templateElem.getChildNodes(), child -> true);
for (String var : vars) {
popVar(var);
}
return templateElem;
}
代码示例来源:origin: org.teavm.flavour/teavm-flavour-templates
for (PostponedComponentParse parse : postponed) {
position = parse.position;
parseSegment(parse.elem.getEnd(), parse.component.getContentNodes(),
child -> !elementsToSkip.contains(child));
代码示例来源:origin: konsoletyper/teavm-flavour
for (PostponedComponentParse parse : postponed) {
position = parse.position;
parseSegment(parse.elem.getEnd(), parse.component.getContentNodes(),
child -> !elementsToSkip.contains(child));
内容来源于网络,如有侵权,请联系作者删除!