當前位置: 首頁>>代碼示例>>Java>>正文


Java TextNode.getWholeText方法代碼示例

本文整理匯總了Java中org.jsoup.nodes.TextNode.getWholeText方法的典型用法代碼示例。如果您正苦於以下問題:Java TextNode.getWholeText方法的具體用法?Java TextNode.getWholeText怎麽用?Java TextNode.getWholeText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jsoup.nodes.TextNode的用法示例。


在下文中一共展示了TextNode.getWholeText方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: head

import org.jsoup.nodes.TextNode; //導入方法依賴的package包/類
public void head(Node source, int depth) {
    if (source instanceof Element) {
        Element sourceEl = (Element) source;

        if (whitelist.isSafeTag(sourceEl.tagName())) { // safe, clone and copy safe attrs
            ElementMeta meta = createSafeElement(sourceEl);
            Element destChild = meta.el;
            destination.appendChild(destChild);

            numDiscarded += meta.numAttribsDiscarded;
            destination = destChild;
        } else if (source != root) { // not a safe tag, so don't add. don't count root against discarded.
            numDiscarded++;
        }
    } else if (source instanceof TextNode) {
        TextNode sourceText = (TextNode) source;
        TextNode destText = new TextNode(sourceText.getWholeText());
        destination.appendChild(destText);
    } else if (source instanceof DataNode && whitelist.isSafeTag(source.parent().nodeName())) {
      DataNode sourceData = (DataNode) source;
      DataNode destData = new DataNode(sourceData.getWholeData());
      destination.appendChild(destData);
    } else { // else, we don't care about comments, xml proc instructions, etc
        numDiscarded++;
    }
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:27,代碼來源:Cleaner.java

示例2: head

import org.jsoup.nodes.TextNode; //導入方法依賴的package包/類
public void head(Node source, int depth) {
    if (skipChildren) {
        return;
    }

    if (source instanceof Element) {
        Element sourceElement = (Element) source;

        if (isSafeTag(sourceElement)) {
            String sourceTag = sourceElement.tagName();
            Attributes destinationAttributes = sourceElement.attributes().clone();
            Element destinationChild = new Element(Tag.valueOf(sourceTag), sourceElement.baseUri(), destinationAttributes);

            destination.appendChild(destinationChild);
            destination = destinationChild;
        } else if (source != root) {
            skipChildren = true;
        }
    } else if (source instanceof TextNode) {
        TextNode sourceText = (TextNode) source;
        TextNode destinationText = new TextNode(sourceText.getWholeText(), source.baseUri());
        destination.appendChild(destinationText);
    } else if (source instanceof DataNode && isSafeTag(source.parent())) {
        DataNode sourceData = (DataNode) source;
        DataNode destinationData = new DataNode(sourceData.getWholeData(), source.baseUri());
        destination.appendChild(destinationData);
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:29,代碼來源:HeadCleaner.java

示例3: mapToText

import org.jsoup.nodes.TextNode; //導入方法依賴的package包/類
/**
 * Map a node to text.
 *
 * @param node the node
 * @return the string
 */
private String mapToText(final Node node) {
	if (node instanceof TextNode) {
		final TextNode t = (TextNode) node;
		return t.getWholeText();
	} else {
		return null;
	}
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:15,代碼來源:DocumentToJCasConverter.java

示例4: appendNormalisedText

import org.jsoup.nodes.TextNode; //導入方法依賴的package包/類
private static void appendNormalisedText(StringBuilder accum, TextNode textNode) {
    String text = textNode.getWholeText();

    if (!preserveWhitespace(textNode.parent())) {
        text = normaliseWhitespace(text);
        if (lastCharIsWhitespace(accum))
            text = stripLeadingWhitespace(text);
    }
    accum.append(text);
}
 
開發者ID:eugenkiss,項目名稱:chanobol,代碼行數:11,代碼來源:CommentParser.java

示例5: toHtml

import org.jsoup.nodes.TextNode; //導入方法依賴的package包/類
public String toHtml(String s2) {
	RTFEditorKit rtfeditorkit = new RTFEditorKit();
	DefaultStyledDocument defaultstyleddocument = new DefaultStyledDocument();
	readString(s2, defaultstyleddocument, rtfeditorkit);
	scanDocument(defaultstyleddocument);

	// Parse all rtf elements
	for (RtfElementParser r : parserItems) {
		r.parseDocElements(entries.entrySet().iterator());
	}

	// Parse all textnodes
	for (Map.Entry<TextNode, Element> entry : entries.entrySet()) {
		TextNode txtNode = entry.getKey();
		// Replace \n an element node
		while (txtNode.getWholeText().contains("\n")){
			int pos = txtNode.getWholeText().indexOf("\n");
			String txt = txtNode.getWholeText();
			txtNode.before(new TextNode(txt.substring(0, pos), ""));
			txtNode.before(new org.jsoup.nodes.Element(Tag.valueOf("br"), ""));
			txtNode.text(txt.substring(pos + 1));
		}
		
	}

	return removeEmptyNodes(body).toString();
}
 
開發者ID:frickler,項目名稱:Html2Rtf,代碼行數:28,代碼來源:Rtf2Html.java


注:本文中的org.jsoup.nodes.TextNode.getWholeText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。