• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ContentNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.htmlcleaner.ContentNode的典型用法代码示例。如果您正苦于以下问题:Java ContentNode类的具体用法?Java ContentNode怎么用?Java ContentNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContentNode类属于org.htmlcleaner包,在下文中一共展示了ContentNode类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleContent

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
private void handleContent(SpannableStringBuilder builder, Object node,
                           SpanStack stack, CancellationCallback cancellationCallback ) {

    checkForCancellation(cancellationCallback);

    ContentNode contentNode = (ContentNode) node;

    String text = TextUtil.replaceHtmlEntities(
            contentNode.getContent().toString(), false);

    if ( isStripExtraWhiteSpace() ) {
        //Replace unicode non-breaking space with normal space.
        text = text.replace( '\u00A0', ' ' );
    }

    if ( text.trim().length() > 0 ) {
        builder.append(text);
    }
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:20,代码来源:HtmlSpanner.java


示例2: getPlainText

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
private void getPlainText(StringBuffer buffer, Object node) {
	if (node instanceof ContentNode) {

		ContentNode contentNode = (ContentNode) node;
		String text = TextUtil.replaceHtmlEntities(contentNode.getContent()
				.toString(), true);

		buffer.append(text);

	} else if (node instanceof TagNode) {
		TagNode tagNode = (TagNode) node;
		for (Object child : tagNode.getAllChildren()) {
			getPlainText(buffer, child);
		}
	}
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:17,代码来源:PreHandler.java


示例3: handleTagNode

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end, SpanStack spanStack) {

    if ( getSpanner().isAllowStyling() ) {

        if ( node.getAllChildren().size() == 1 ) {
            Object childNode = node.getAllChildren().get(0);

            if ( childNode instanceof ContentNode ) {
                parseCSSFromText( ( (ContentNode) childNode ).getContent(),
                        spanStack );
            }
        }
    }

}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:17,代码来源:StyleNodeHandler.java


示例4: checkStyleCSS

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
final private void checkStyleCSS(TagNode node)
		throws ClientProtocolException, IllegalStateException, IOException, SearchLibException, URISyntaxException {
	if (!("style".equalsIgnoreCase(node.getName())))
		return;
	String attr = node.getAttributeByName("type");
	if (!StringUtils.isEmpty(attr) && !"text/css".equalsIgnoreCase(attr))
		return;
	attr = node.getAttributeByName("media");
	if (!StringUtils.isEmpty(attr) && !"screen".equalsIgnoreCase(attr) && !"all".equalsIgnoreCase(attr))
		return;
	StringBuilder builder = (StringBuilder) node.getText();
	if (builder == null)
		return;
	String content = builder.toString();
	String newContent = StringEscapeUtils.unescapeXml(content);
	StringBuffer sb = checkCSSContent(baseUrl, newContent);
	if (sb != null)
		newContent = sb.toString();
	if (newContent.equals(content))
		return;
	node.removeAllChildren();
	node.addChild(new ContentNode(newContent));
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:24,代码来源:HtmlArchiver.java


示例5: checkScriptContent

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
final private void checkScriptContent(TagNode node, Set<TagNode> disableScriptNodeSet) {
	if (!("script".equalsIgnoreCase(node.getName())))
		return;
	if (disableScriptNodeSet != null && hasAncestorXPath(disableScriptNodeSet, node)) {
		node.removeFromTree();
		return;
	}
	StringBuilder builder = (StringBuilder) node.getText();
	if (builder == null)
		return;
	String content = builder.toString();
	if (content == null)
		return;
	String newContent = StringEscapeUtils.unescapeXml(content);
	if (newContent.equals(content))
		return;
	node.removeAllChildren();
	node.addChild(new ContentNode(newContent));
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:20,代码来源:HtmlArchiver.java


示例6: getPlainText

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
private void getPlainText(StringBuffer buffer, Object node) {
    if (node instanceof ContentNode) {
        ContentNode contentNode = (ContentNode) node;
        String text = contentNode.getContent().toString();
        buffer.append(text);
    } else if (node instanceof TagNode) {
        TagNode tagNode = (TagNode) node;
        for (Object child : tagNode.getChildren()) {
            this.getPlainText(buffer, child);
        }
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:13,代码来源:PreTagHandler.java


示例7: applySpan

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
private void applySpan(SpannableStringBuilder builder, TagNode node, SpanStack stack,
                       CancellationCallback cancellationCallback) {

    checkForCancellation(cancellationCallback);

    TagNodeHandler handler = this.handlers.get(node.getName());

    if ( handler == null ) {
        handler = new StyledTextHandler();
        handler.setSpanner(this);
    }

    int lengthBefore = builder.length();

    handler.beforeChildren(node, builder, stack);

    if ( !handler.rendersContent() ) {

        for (Object childNode : node.getAllChildren()) {

            if ( childNode instanceof ContentNode ) {
                handleContent( builder, childNode, stack, cancellationCallback );
            } else if ( childNode instanceof TagNode ) {
                applySpan( builder, (TagNode) childNode, stack, cancellationCallback );
            }
        }
    }

    int lengthAfter = builder.length();
    handler.handleTagNode(node, builder, lengthBefore, lengthAfter, stack);
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:32,代码来源:HtmlSpanner.java


示例8: satisfy

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
private boolean satisfy(TagNode tagNode, boolean override) {
    String name = tagNode.getName();
    TagInfo tagInfo = tagInfoProvider.getTagInfo(name);
    //Only _block_ elements can match.
    if (tagInfo != null && !hasIdAttributeSet(tagNode) && none != tagInfo.getDisplay() && !tagInfo.isEmptyTag() && (override || !unsafeBlockElements.contains(name))) {
        CharSequence contentString = tagNode.getText();
        if(isEmptyString(contentString)) {
            // even though there may be no text need to make sure all children are empty or can be pruned
            if (tagNode.isEmpty()) {
                return true;
            } else {
                for(Object child: tagNode.getAllChildren()) {
                    // TODO : similar check as in tagNode.isEmpty() argues for a visitor pattern
                    // but allow empty td, ths to be pruned.
                    if ( child instanceof TagNode) {
                        if (!satisfy((TagNode)child, true)) {
                            return false;
                        }
                    } else if (child instanceof ContentNode ) {
                        if ( !((ContentNode)child).isBlank()) {
                            return false;
                        }
                    } else {
                        return false;
                    }
                }
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:33,代码来源:TagNodeEmptyContentCondition.java


示例9: satisfy

import org.htmlcleaner.ContentNode; //导入依赖的package包/类
private boolean satisfy(TagNode tagNode, boolean override) {
    String name = tagNode.getName();
    TagInfo tagInfo = tagInfoProvider.getTagInfo(name);
    //Only _block_ elements can match.
    if (tagInfo != null && !hasIdAttributeSet(tagNode) && none != tagInfo.getDisplay() && !tagInfo.isEmptyTag() && (override || !unsafeBlockElements.contains(name))) {
        CharSequence contentString = tagNode.getText();
        if (isEmptyString(contentString)) {
            // even though there may be no text need to make sure all children are empty or can be pruned
            if (tagNode.isEmpty()) {
                return true;
            } else {
                for (Object child : tagNode.getAllChildren()) {
                    // TODO : similar check as in tagNode.isEmpty() argues for a visitor pattern
                    // but allow empty td, ths to be pruned.
                    if (child instanceof TagNode) {
                        if (!satisfy((TagNode) child, true)) {
                            return false;
                        }
                    } else if (child instanceof ContentNode) {
                        if (!((ContentNode) child).isBlank()) {
                            return false;
                        }
                    } else {
                        return false;
                    }
                }
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:fivesmallq,项目名称:web-data-extractor,代码行数:33,代码来源:TagNodeEmptyContentCondition.java



注:本文中的org.htmlcleaner.ContentNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RDFList类代码示例发布时间:2022-05-22
下一篇:
Java Required类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap