本文整理了Java中net.htmlparser.jericho.Element.getContent()
方法的一些代码示例,展示了Element.getContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getContent()
方法的具体详情如下:
包路径:net.htmlparser.jericho.Element
类名称:Element
方法名:getContent
[英]Returns the segment representing the content of the element.
This segment spans between the end of the start tag and the start of the end tag. If the end tag is not present, the content reaches to the end of the element.
A zero-length segment is returned if the element is #isEmpty(),
[中]返回表示元素content的段。
此段跨越开始标记的端点和结束标记的起点。如果结束标记不存在,则内容将到达元素的结尾。
如果元素为#isEmpty(),则返回长度为零的段,
代码示例来源:origin: wala/WALA
@Override
public Position getContentPosition() {
return getPosition(innerElement.getContent());
}
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.cast.js
@Override
public Position getContentPosition() {
return getPosition(innerElement.getContent());
}
}
代码示例来源:origin: aria42/nlp-utils
public static Span getContentSpan(Element e) {
return getSpan(e.getContent());
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
final String tagName = element.getName();
if (tagName.equals(CF.CFQUERY)) {
String queryGuts = element.getContent().toString().replaceAll("\\s+", "");
queryGuts = queryGuts.toLowerCase();
if (queryGuts.contains(selectStar)) {
context.addMessage("SQL_SELECT_STAR", null);
}
}
}
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
final String tagName = element.getName();
if (tagName.equals(CF.CFQUERY)) {
String queryGuts = element.getContent().toString().replaceAll("\\s+", "");
queryGuts = queryGuts.toLowerCase();
if (queryGuts.contains(selectStar)) {
context.addMessage("SQL_SELECT_STAR", null);
}
}
}
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
final String elementName = element.getName();
if (elementName.equals(CF.CFCOMPONENT)) {
// this includes whitespace-change it
final int total = element.getContent().toString().split("\\n").length;
checkSize(LENGTH_THRESHOLD, "EXCESSIVE_COMPONENT_LENGTH", context, 1, 0, total, bugs);
}
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
private static String getOptionLabel(final Element optionElement) {
final String labelAttributeValue=optionElement.getAttributeValue("label");
if (labelAttributeValue!=null) return labelAttributeValue;
return CharacterReference.decodeCollapseWhiteSpace(optionElement.getContent());
}
private final class OptionElementIterator implements Iterator<Element> {
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
final String elementName = element.getName();
if (elementName.equals(CF.CFCOMPONENT)) {
// this includes whitespace-change it
final int total = element.getContent().toString().split("\\n").length;
checkSize(LENGTH_THRESHOLD, "EXCESSIVE_COMPONENT_LENGTH", context, 1, 0, total, bugs);
}
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
private String getValue() {
return (value==UNCHANGED) ? CharacterReference.decode(getElement().getContent()) : value;
}
}
代码示例来源:origin: VueGWT/vue-gwt
private String processScopedCss(Source doc) {
final String[] scopedCss = new String[1];
doc.getAllElements().stream()
.filter(TemplateParser::isScopedStyleElement)
.peek(styleScoped -> {
String css = styleScoped.getContent().toString().trim();
if (!css.isEmpty()) {
String lang = styleScoped.getAttributeValue("lang");
if ("scss".equalsIgnoreCase(lang)) { // lang="scss"
css = scssToCss(css);
}
TemplateScopedCssParser scopedCssParser = new TemplateScopedCssParser(messager);
Optional<ScopedCssResult> scopedCssResult = scopedCssParser.parse(
context.getComponentTypeElement(), css);
if (scopedCssResult.isPresent()) {
context.getMandatoryAttributes().putAll(scopedCssResult.get().mandatoryAttributes);
scopedCss[0] = scopedCssResult.get().scopedCss;
}
}
})
.forEach(outputDocument::remove);
return scopedCss[0];
}
代码示例来源:origin: mozilla/zest
private String getReturnValue(Element element) throws ZestAssignFailException {
if (returnElement) {
return element.getContent().toString();
} else if (returnAttribute) {
return element.getAttributeValue(returnedAttributeName);
} else {
throw new ZestAssignFailException(this, "A selection method must be configured");
}
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (
element.getName().equalsIgnoreCase(CF.CFQUERY) && !CF.QUERY.equalsIgnoreCase(element.getAttributeValue(CF.DBTYPE))) {
String content = element.getContent().toString();
//Todo : cfparser/Jericho does not support parsing out the cfqueryparam very well.
// the following code will not work when there is a > sign in the expression
content = content.replaceAll("<[cC][fF][qQ][uU][eE][rR][yY][pP][aA][rR][aA][mM][^>]*>", "");
if (content.indexOf('#') >= 0) {
final List<Integer> ignoreLines = determineIgnoreLines(element);
final Matcher matcher = Pattern.compile("#(?:##)?([^#]+)(?:##)?#($|[^#])",Pattern.DOTALL).matcher(content);
while (matcher.find()) {
if (matcher.groupCount() >= 1) {
int currentline = context.startLine() + countNewLinesUpTo(content, matcher.start());
int currentOffset = element.getStartTag().getEnd() + 1 + matcher.start();
final String variableName = matcher.group(1);
if (!ignoreLines.contains(currentline)) {
context.addMessage("CFQUERYPARAM_REQ", variableName, currentline, currentOffset);
}
}
}
}
}
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (
element.getName().equalsIgnoreCase(CF.CFQUERY) && !CF.QUERY.equalsIgnoreCase(element.getAttributeValue(CF.DBTYPE))) {
String content = element.getContent().toString();
//Todo : cfparser/Jericho does not support parsing out the cfqueryparam very well.
// the following code will not work when there is a > sign in the expression
content = content.replaceAll("<[cC][fF][qQ][uU][eE][rR][yY][pP][aA][rR][aA][mM][^>]*>", "");
if (content.indexOf('#') >= 0) {
final List<Integer> ignoreLines = determineIgnoreLines(element);
final Matcher matcher = Pattern.compile("#(?:##)?([^#]+)(?:##)?#($|[^#])",Pattern.DOTALL).matcher(content);
while (matcher.find()) {
if (matcher.groupCount() >= 1) {
int currentline = context.startLine() + countNewLinesUpTo(content, matcher.start());
int currentOffset = element.getStartTag().getEnd() + 1 + matcher.start();
final String variableName = matcher.group(1);
if (!ignoreLines.contains(currentline)) {
context.addMessage("CFQUERYPARAM_REQ", variableName, currentline, currentOffset);
}
}
}
}
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public void process(Processor x, Element element) throws IOException {
if (!x.includeHyperlinkURLs) {
x.appendElementContent(element);
return;
}
String renderedHyperlinkURL=x.renderer.renderHyperlinkURL(element.getStartTag());
if (renderedHyperlinkURL==null) {
x.appendElementContent(element);
return;
}
String href=element.getAttributeValue("href");
final boolean displayContent=href==null || !getInformalURL(href).equals(getInformalURL(element.getContent().toString())); // only display the content if it is not the same as the URL
int linkLength=renderedHyperlinkURL.length();
if (displayContent) {
x.appendElementContent(element);
linkLength++; // allow for space after content
}
if (x.maxLineLength>0 && x.col+linkLength>=x.maxLineLength) {
x.startNewLine(0);
} else if (displayContent) {
x.append(' ');
}
x.append(renderedHyperlinkURL);
x.lastCharWhiteSpace=true;
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public SelectFormControl(final Element element) {
super(element,element.getAttributes().get(Attribute.MULTIPLE)!=null ? FormControlType.SELECT_MULTIPLE : FormControlType.SELECT_SINGLE,false);
final List<Element> optionElements=element.getAllElements(HTMLElementName.OPTION);
optionElementContainers=new ElementContainer[optionElements.size()];
int x=0;
for (Element optionElement : optionElements) {
final ElementContainer optionElementContainer=new ElementContainer(optionElement,true);
if (optionElementContainer.predefinedValue==null)
// use the content of the element if it has no value attribute
optionElementContainer.predefinedValue=CharacterReference.decodeCollapseWhiteSpace(optionElementContainer.element.getContent());
optionElementContainers[x++]=optionElementContainer;
}
}
public String getPredefinedValue() {
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
continue;
for (StartTag texTag : tag.getElement().getContent().getAllStartTags(TEX_TAG_NAME)) {
Element texElement = texTag.getElement();
if (texElement.getEndTag() == null) {
String content = texElement.getContent().toString().trim();
Pair<Integer, Integer> bounds = getBounds(content);
if(bounds.getRight() == 0){
logger.info("Empty source in Tex tag");
outputDocument.replace(texElement.getContent(), StringUtils.EMPTY);
} else {
String strippedContent = content.substring(bounds.getLeft(), bounds.getRight());
String unescapedContent = StringEscapeUtils.unescapeHtml4(strippedContent);
outputDocument.replace(texElement.getContent(), unescapedContent);
代码示例来源:origin: wala/WALA
public Pair<Integer, String> getBodyText() {
Segment content = innerElement.getContent();
Integer lineNum = innerElement.getSource().getRow(content.getBegin());
String nl = content.getSource().getNewLine();
String body = nl==null? content.toString(): content.toString().replace(nl, "\n");
return Pair.make(lineNum, body);
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.cast.js
public Pair<Integer, String> getBodyText() {
Segment content = innerElement.getContent();
Integer lineNum = innerElement.getSource().getRow(content.getBegin());
String nl = content.getSource().getNewLine();
String body = nl==null? content.toString(): content.toString().replace(nl, "\n");
return Pair.make(lineNum, body);
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public static List<Segment> getStyleURISegments(final Segment segment) {
if (segment==null || segment.length()==0) return Collections.emptyList();
if (segment.getFirstStartTag()==null) {
// no start tags in this segment, assume the segment is a style attribute value
int urlDelimiterStartPos=segment.getSource().getParseText().indexOf("url(",segment.getBegin(),segment.getEnd());
if (urlDelimiterStartPos==-1) return Collections.emptyList();
return addURLSegmentsFromCSS(new ArrayList<Segment>(),new Segment(segment.getSource(),urlDelimiterStartPos,segment.getEnd()));
}
List<Segment> uriSegments=new ArrayList<Segment>();
for (StartTag startTag : segment.getAllStartTags("style",null)) {
addURLSegmentsFromCSS(uriSegments,startTag.getAttributes().get("style").getValueSegment());
}
for (Element element : segment.getAllElements(HTMLElementName.STYLE)) {
addURLSegmentsFromCSS(uriSegments,element.getContent());
}
Collections.sort(uriSegments);
return uriSegments;
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
void replaceInOutputDocument(final OutputDocument outputDocument) {
if (outputStyle==FormControlOutputStyle.REMOVE) {
outputDocument.remove(getElement());
} else if (outputStyle==FormControlOutputStyle.DISPLAY_VALUE) {
outputDocument.replace(getElement(),getDisplayValueHTML(getValue(),true));
} else {
replaceAttributesInOutputDocumentIfModified(outputDocument);
if (value!=UNCHANGED)
outputDocument.replace(getElement().getContent(),CharacterReference.encode(value,false));
}
}
private String getValue() {
内容来源于网络,如有侵权,请联系作者删除!