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


Java StringUtil.in方法代碼示例

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


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

示例1: head

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
@Override
public void head(Node node, int depth) {
	String name = node.nodeName();
	if (node instanceof TextNode) {
		append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM.
	} else if (name.equals("ul")) {
		listNesting++;
	} else if (name.equals("li")) {
		append("\n ");
		for (int i = 1; i < listNesting; i++) {
			append("  ");
		}
		if (listNesting == 1) {
			append("* ");
		} else {
			append("- ");
		}
	} else if (name.equals("dt")) {
		append("  ");
	} else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) {
		append("\n");
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:24,代碼來源:HtmlToPlainText.java

示例2: inSelectScope

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
boolean inSelectScope(String targetName) {
    for (int pos = stack.size() -1; pos >= 0; pos--) {
        Element el = stack.get(pos);
        String elName = el.nodeName();
        if (elName.equals(targetName))
            return true;
        if (!StringUtil.in(elName, TagSearchSelectScope)) // all elements except
            return false;
    }
    Validate.fail("Should not be reachable");
    return false;
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:13,代碼來源:HtmlTreeBuilder.java

示例3: head

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
public void head(Node node, int depth) {
    String name = node.nodeName();
    if (node instanceof TextNode)
        append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM.
    else if (name.equals("li"))
        append("\n * ");
    else if (name.equals("dt"))
        append("  ");
    else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr"))
        append("\n");
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:12,代碼來源:HtmlToPlainText.java

示例4: tail

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
public void tail(Node node, int depth) {
    String name = node.nodeName();
    if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5"))
        append("\n");
    else if (name.equals("a"))
        append(String.format(" <%s>", node.absUrl("href")));
}
 
開發者ID:rogerxaic,項目名稱:gestock,代碼行數:8,代碼來源:HtmlToPlainText.java

示例5: append

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
private void append(String text) {
    if (text.startsWith("\n"))
        width = 0; // reset counter if starts with a newline. only from formats above, not in natural text
    if (text.equals(" ") &&
            (accum.length() == 0 || StringUtil.in(accum.substring(accum.length() - 1), " ", "\n")))
        return; // don't accumulate long runs of empty spaces

    if (text.length() + width > maxWidth) { // won't fit, needs to wrap
        String words[] = text.split("\\s+");
        for (int i = 0; i < words.length; i++) {
            String word = words[i];
            boolean last = i == words.length - 1;
            if (!last) // insert a space if not the last word
                word = word + " ";
            if (word.length() + width > maxWidth) { // wrap and reset counter
                accum.append("\n").append(word);
                width = word.length();
            } else {
                accum.append(word);
                width += word.length();
            }
        }
    } else { // fits as is, without need to wrap text
        accum.append(text);
        width += text.length();
    }
}
 
開發者ID:rogerxaic,項目名稱:gestock,代碼行數:28,代碼來源:HtmlToPlainText.java

示例6: trimQuotes

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
public static String trimQuotes(String str) {
    Validate.isTrue(str != null && str.length() > 0);
    String quote = str.substring(0, 1);
    if (StringUtil.in(quote, "\"", "'")) {
        Validate.isTrue(str.endsWith(quote), "Quote" + " for " + str + " is incomplete!");
        str = str.substring(1, str.length() - 1);
    }
    return str;
}
 
開發者ID:zongtui,項目名稱:zongtui-webcrawler,代碼行數:10,代碼來源:XTokenQueue.java

示例7: popStackToClose

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
void popStackToClose(String... elNames) {
    Iterator<Element> it = stack.descendingIterator();
    while (it.hasNext()) {
        Element next = it.next();
        if (StringUtil.in(next.nodeName(), elNames)) {
            it.remove();
            break;
        } else {
            it.remove();
        }
    }
}
 
開發者ID:shannah,項目名稱:CN1ML-NetbeansModule,代碼行數:13,代碼來源:HtmlTreeBuilder.java

示例8: popStackToClose

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
void popStackToClose(String... elNames) {
    for (int pos = stack.size() -1; pos >= 0; pos--) {
        Element next = stack.get(pos);
        stack.remove(pos);
        if (StringUtil.in(next.nodeName(), elNames))
            break;
    }
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:9,代碼來源:HtmlTreeBuilder.java

示例9: clearStackToContext

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
private void clearStackToContext(String... nodeNames) {
    Iterator<Element> it = stack.descendingIterator();
    while (it.hasNext()) {
        Element next = it.next();
        if (StringUtil.in(next.nodeName(), nodeNames) || next.nodeName().equals("html"))
            break;
        else
            it.remove();
    }
}
 
開發者ID:gumulka,項目名稱:JabRefAutocomplete,代碼行數:11,代碼來源:TreeBuilder.java

示例10: tail

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
public void tail(Node node, int depth) {
    String name = node.nodeName();
    if (name.equals("br"))
        append("\n");
    else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5"))
        append("\n\n");
    else if (name.equals("a"))
        append(String.format(" <%s>", node.absUrl("href")));
}
 
開發者ID:shannah,項目名稱:CN1ML-NetbeansModule,代碼行數:10,代碼來源:HtmlToPlainText.java

示例11: insert

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
void insert(Token.Character characterToken) {
    Node node;
    // characters in script and style go in as datanodes, not text nodes
    if (StringUtil.in(currentElement().tagName(), TagsScriptStyle))
        node = new DataNode(characterToken.getData(), baseUri);
    else
        node = new TextNode(characterToken.getData(), baseUri);
    currentElement().appendChild(node); // doesn't use insertNode, because we don't foster these; and will always have a stack.
}
 
開發者ID:Nader-Sl,項目名稱:BoL-API-Parser,代碼行數:10,代碼來源:HtmlTreeBuilder.java

示例12: clearStackToContext

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
private void clearStackToContext(String... nodeNames) {
    for (int pos = stack.size() -1; pos >= 0; pos--) {
        Element next = stack.get(pos);
        if (StringUtil.in(next.nodeName(), nodeNames) || next.nodeName().equals("html"))
            break;
        else
            stack.remove(pos);
    }
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:10,代碼來源:HtmlTreeBuilder.java

示例13: isSpecial

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
boolean isSpecial(Element el) {
    // todo: mathml's mi, mo, mn
    // todo: svg's foreigObject, desc, title
    String name = el.nodeName();
    return StringUtil.in(name, "address", "applet", "area", "article", "aside", "base", "basefont", "bgsound",
            "blockquote", "body", "br", "button", "caption", "center", "col", "colgroup", "command", "dd",
            "details", "dir", "div", "dl", "dt", "embed", "fieldset", "figcaption", "figure", "footer", "form",
            "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html",
            "iframe", "img", "input", "isindex", "li", "link", "listing", "marquee", "menu", "meta", "nav",
            "noembed", "noframes", "noscript", "object", "ol", "p", "param", "plaintext", "pre", "script",
            "section", "select", "style", "summary", "table", "tbody", "td", "textarea", "tfoot", "th", "thead",
            "title", "tr", "ul", "wbr", "xmp");
}
 
開發者ID:gumulka,項目名稱:JabRefAutocomplete,代碼行數:14,代碼來源:TreeBuilder.java

示例14: inSpecificScope

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
private boolean inSpecificScope(String[] targetNames, String[] baseTypes, String[] extraTypes) {
    for (int pos = stack.size() -1; pos >= 0; pos--) {
        Element el = stack.get(pos);
        String elName = el.nodeName();
        if (StringUtil.in(elName, targetNames))
            return true;
        if (StringUtil.in(elName, baseTypes))
            return false;
        if (extraTypes != null && StringUtil.in(elName, extraTypes))
            return false;
    }
    Validate.fail("Should not be reachable");
    return false;
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:15,代碼來源:HtmlTreeBuilder.java

示例15: append

import org.jsoup.helper.StringUtil; //導入方法依賴的package包/類
private void append(String text) {
    if (text.startsWith("\n"))
        width = 0; // reset counter if starts with a newline. only from formats above, not in natural text
    if (text.equals(" ") &&
        (accum.length() == 0 || StringUtil.in(accum.substring(accum.length() - 1), " ", "\n")))
        return; // don't accumulate long runs of empty spaces

    if (text.length() + width > maxWidth) { // won't fit, needs to wrap
        String words[] = text.split("\\s+");
        for (int i = 0; i < words.length; i++) {
            String word = words[i];
            boolean last = i == words.length - 1;
            if (!last) // insert a space if not the last word
                word = word + " ";
            if (word.length() + width > maxWidth) { // wrap and reset counter
                accum.append("\n").append(word);
                width = word.length();
            } else {
                accum.append(word);
                width += word.length();
            }
        }
    } else { // fits as is, without need to wrap text
        accum.append(text);
        width += text.length();
    }
}
 
開發者ID:3wks,項目名稱:generator-thundr-gae-react,代碼行數:28,代碼來源:HtmlFormattingUtil.java


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