本文整理匯總了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++;
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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();
}