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