本文整理了Java中org.jsoup.helper.Validate.notEmpty()
方法的一些代码示例,展示了Validate.notEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.notEmpty()
方法的具体详情如下:
包路径:org.jsoup.helper.Validate
类名称:Validate
方法名:notEmpty
[英]Validates that the string is not empty
[中]验证字符串是否为空
代码示例来源:origin: org.jsoup/jsoup
@Override
public Connection.KeyVal contentType(String contentType) {
Validate.notEmpty(contentType);
this.contentType = contentType;
return this;
}
代码示例来源:origin: org.jsoup/jsoup
public KeyVal key(String key) {
Validate.notEmpty(key, "Data key must not be empty");
this.key = key;
return this;
}
代码示例来源:origin: org.jsoup/jsoup
public T removeCookie(String name) {
Validate.notEmpty(name, "Cookie name must not be empty");
cookies.remove(name);
return (T) this;
}
代码示例来源:origin: org.jsoup/jsoup
public boolean hasHeader(String name) {
Validate.notEmpty(name, "Header name must not be empty");
return getHeadersCaseInsensitive(name).size() != 0;
}
代码示例来源:origin: org.jsoup/jsoup
public AttributeStarting(String keyPrefix) {
Validate.notEmpty(keyPrefix);
this.keyPrefix = lowerCase(keyPrefix);
}
代码示例来源:origin: org.jsoup/jsoup
@Override
public List<String> headers(String name) {
Validate.notEmpty(name);
return getHeadersCaseInsensitive(name);
}
代码示例来源:origin: org.jsoup/jsoup
public T removeHeader(String name) {
Validate.notEmpty(name, "Header name must not be empty");
Map.Entry<String, List<String>> entry = scanHeaders(name); // remove is case insensitive too
if (entry != null)
headers.remove(entry.getKey()); // ensures correct case
return (T) this;
}
代码示例来源:origin: org.jsoup/jsoup
public T cookie(String name, String value) {
Validate.notEmpty(name, "Cookie name must not be empty");
Validate.notNull(value, "Cookie value must not be null");
cookies.put(name, value);
return (T) this;
}
代码示例来源:origin: org.jsoup/jsoup
public AttributeKeyPair(String key, String value) {
Validate.notEmpty(key);
Validate.notEmpty(value);
this.key = normalize(key);
if (value.startsWith("\"") && value.endsWith("\"")
|| value.startsWith("'") && value.endsWith("'")) {
value = value.substring(1, value.length()-1);
}
this.value = normalize(value);
}
}
代码示例来源:origin: org.jsoup/jsoup
private void byClass() {
String className = tq.consumeCssIdentifier();
Validate.notEmpty(className);
evals.add(new Evaluator.Class(className.trim()));
}
代码示例来源:origin: org.jsoup/jsoup
/**
* Find elements that have an attribute name starting with the supplied prefix. Use {@code data-} to find elements
* that have HTML5 datasets.
* @param keyPrefix name prefix of the attribute e.g. {@code data-}
* @return elements that have attribute names that start with with the prefix, empty if none.
*/
public Elements getElementsByAttributeStarting(String keyPrefix) {
Validate.notEmpty(keyPrefix);
keyPrefix = keyPrefix.trim();
return Collector.collect(new Evaluator.AttributeStarting(keyPrefix), this);
}
代码示例来源:origin: org.jsoup/jsoup
/**
* Find the first element that matches the query.
* @param cssQuery CSS selector
* @param root root element to descend into
* @return the matching element, or <b>null</b> if none.
*/
public static Element selectFirst(String cssQuery, Element root) {
Validate.notEmpty(cssQuery);
return Collector.findFirst(QueryParser.parse(cssQuery), root);
}
代码示例来源:origin: org.jsoup/jsoup
private void matches(boolean own) {
tq.consume(own ? ":matchesOwn" : ":matches");
String regex = tq.chompBalanced('(', ')'); // don't unescape, as regex bits will be escaped
Validate.notEmpty(regex, ":matches(regex) query must not be empty");
if (own)
evals.add(new Evaluator.MatchesOwn(Pattern.compile(regex)));
else
evals.add(new Evaluator.Matches(Pattern.compile(regex)));
}
代码示例来源:origin: org.jsoup/jsoup
public Connection.KeyVal data(String key) {
Validate.notEmpty(key, "Data key must not be empty");
for (Connection.KeyVal keyVal : request().data()) {
if (keyVal.key().equals(key))
return keyVal;
}
return null;
}
代码示例来源:origin: org.jsoup/jsoup
private void not() {
tq.consume(":not");
String subQuery = tq.chompBalanced('(', ')');
Validate.notEmpty(subQuery, ":not(selector) subselect must not be empty");
evals.add(new StructuralEvaluator.Not(parse(subQuery)));
}
}
代码示例来源:origin: org.jsoup/jsoup
/**
* Finds elements, including and recursively under this element, with the specified tag name.
* @param tagName The tag name to search for (case insensitively).
* @return a matching unmodifiable list of elements. Will be empty if this element and none of its children match.
*/
public Elements getElementsByTag(String tagName) {
Validate.notEmpty(tagName);
tagName = normalize(tagName);
return Collector.collect(new Evaluator.Tag(tagName), this);
}
代码示例来源:origin: org.jsoup/jsoup
private void has() {
tq.consume(":has");
String subQuery = tq.chompBalanced('(', ')');
Validate.notEmpty(subQuery, ":has(el) subselect must not be empty");
evals.add(new StructuralEvaluator.Has(parse(subQuery)));
}
代码示例来源:origin: org.jsoup/jsoup
private void contains(boolean own) {
tq.consume(own ? ":containsOwn" : ":contains");
String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
Validate.notEmpty(searchText, ":contains(text) query must not be empty");
if (own)
evals.add(new Evaluator.ContainsOwnText(searchText));
else
evals.add(new Evaluator.ContainsText(searchText));
}
代码示例来源:origin: org.jsoup/jsoup
private void containsData() {
tq.consume(":containsData");
String searchText = TokenQueue.unescape(tq.chompBalanced('(', ')'));
Validate.notEmpty(searchText, ":containsData(text) query must not be empty");
evals.add(new Evaluator.ContainsData(searchText));
}
代码示例来源:origin: org.jsoup/jsoup
public Connection data(String... keyvals) {
Validate.notNull(keyvals, "Data key value pairs must not be null");
Validate.isTrue(keyvals.length %2 == 0, "Must supply an even number of key value pairs");
for (int i = 0; i < keyvals.length; i += 2) {
String key = keyvals[i];
String value = keyvals[i+1];
Validate.notEmpty(key, "Data key must not be empty");
Validate.notNull(value, "Data value must not be null");
req.data(KeyVal.create(key, value));
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!