当前位置: 首页>>代码示例>>Java>>正文


Java TagNode.getAllChildren方法代码示例

本文整理汇总了Java中org.htmlcleaner.TagNode.getAllChildren方法的典型用法代码示例。如果您正苦于以下问题:Java TagNode.getAllChildren方法的具体用法?Java TagNode.getAllChildren怎么用?Java TagNode.getAllChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.htmlcleaner.TagNode的用法示例。


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

示例1: getPlainText

import org.htmlcleaner.TagNode; //导入方法依赖的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

示例2: applySpan

import org.htmlcleaner.TagNode; //导入方法依赖的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

示例3: satisfy

import org.htmlcleaner.TagNode; //导入方法依赖的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

示例4: satisfy

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public boolean satisfy(TagNode tagNode) {
	if (!isBrNode(tagNode)) {
		return false;
	}
	TagNode parent = tagNode.getParent();
	List children = parent.getAllChildren();
	int brIndex = children.indexOf(tagNode);		
	return checkSublist(0, brIndex, children) || checkSublist (brIndex, children.size(), children);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:10,代码来源:TagNodeInsignificantBrCondition.java

示例5: satisfy

import org.htmlcleaner.TagNode; //导入方法依赖的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

示例6: satisfy

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public boolean satisfy(TagNode tagNode) {
    if (!isBrNode(tagNode)) {
        return false;
    }
    TagNode parent = tagNode.getParent();
    List children = parent.getAllChildren();
    int brIndex = children.indexOf(tagNode);
    return checkSublist(0, brIndex, children) || checkSublist(brIndex, children.size(), children);
}
 
开发者ID:fivesmallq,项目名称:web-data-extractor,代码行数:10,代码来源:TagNodeInsignificantBrCondition.java


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