本文整理汇总了Java中org.apache.http.util.Args.notNull方法的典型用法代码示例。如果您正苦于以下问题:Java Args.notNull方法的具体用法?Java Args.notNull怎么用?Java Args.notNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.util.Args
的用法示例。
在下文中一共展示了Args.notNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setContent
import org.apache.http.util.Args; //导入方法依赖的package包/类
public void setContent(final String source, final ContentType contentType) throws UnsupportedCharsetException {
Args.notNull(source, "Source string");
Charset charset = contentType != null?contentType.getCharset():null;
if(charset == null) {
charset = HTTP.DEF_CONTENT_CHARSET;
}
try {
this.content = new BytesArray(source.getBytes(charset.name()));
} catch (UnsupportedEncodingException var) {
throw new UnsupportedCharsetException(charset.name());
}
if(contentType != null) {
addHeader("Content-Type", contentType.toString());
}
}
示例2: get
import org.apache.http.util.Args; //导入方法依赖的package包/类
public T get(
final long timeout,
final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
Args.notNull(unit, "Time unit");
this.lock.lock();
try {
if (this.completed) {
return this.result;
}
this.result = getPoolEntry(timeout, unit);
this.completed = true;
if (this.callback != null) {
this.callback.completed(this.result);
}
return result;
} catch (final IOException ex) {
this.completed = true;
this.result = null;
if (this.callback != null) {
this.callback.failed(ex);
}
throw new ExecutionException(ex);
} finally {
this.lock.unlock();
}
}
示例3: closeIdleConnections
import org.apache.http.util.Args; //导入方法依赖的package包/类
@Override
public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
Args.notNull(tunit, "Time unit");
synchronized (this) {
assertNotShutdown();
long time = tunit.toMillis(idletime);
if (time < 0) {
time = 0;
}
final long deadline = System.currentTimeMillis() - time;
if (this.poolEntry != null && this.poolEntry.getUpdated() <= deadline) {
this.poolEntry.close();
this.poolEntry.getTracker().reset();
}
}
}
示例4: put
import org.apache.http.util.Args; //导入方法依赖的package包/类
@Override
public void put(final HttpHost host, final AuthScheme authScheme) {
Args.notNull(host, "HTTP host");
if (authScheme == null) {
return;
}
if (authScheme instanceof Serializable) {
try {
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
final ObjectOutputStream out = new ObjectOutputStream(buf);
out.writeObject(authScheme);
out.close();
this.map.put(getKey(host), buf.toByteArray());
} catch (final IOException ex) {
if (log.isWarnEnabled()) {
log.warn("Unexpected I/O error while serializing auth scheme", ex);
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Auth scheme " + authScheme.getClass() + " is not serializable");
}
}
}
示例5: DatarouterHttpRequest
import org.apache.http.util.Args; //导入方法依赖的package包/类
/**
* Expects query string parameters to already be UTF-8 encoded. See AdvancedStringTool.makeUrlParameters().
* URL fragment is stripped from URL when sent to server.
*/
public DatarouterHttpRequest(HttpRequestMethod method, final String url, boolean retrySafe){
Args.notBlank(url, "request url");
Args.notNull(method, "http method");
String fragment;
int fragmentIndex = url.indexOf('#');
if(fragmentIndex > 0 && fragmentIndex < url.length() - 1){
fragment = url.substring(fragmentIndex + 1);
}else{
fragmentIndex = url.length();
fragment = "";
}
String path = url.substring(0, fragmentIndex);
Map<String,List<String>> queryParams;
int queryIndex = path.indexOf("?");
if(queryIndex > 0){
queryParams = extractQueryParams(path.substring(queryIndex + 1));
path = path.substring(0, queryIndex);
}else{
queryParams = new LinkedHashMap<>();
}
this.method = method;
this.path = path;
this.retrySafe = retrySafe;
this.fragment = fragment;
this.headers = new HashMap<>();
this.queryParams = queryParams;
this.postParams = new HashMap<>();
this.cookies = new ArrayList<>();
}
示例6: UsernamePasswordCredentials
import org.apache.http.util.Args; //导入方法依赖的package包/类
/**
* The constructor with the username and password combined string argument.
*
* @param usernamePassword the username:password formed string
* @see #toString
* @deprecated (4.5) will be replaced with {@code String}, {@code char[]} in 5.0
*/
@Deprecated
public UsernamePasswordCredentials(final String usernamePassword) {
super();
Args.notNull(usernamePassword, "Username:password string");
final int atColon = usernamePassword.indexOf(':');
if (atColon >= 0) {
this.principal = new BasicUserPrincipal(usernamePassword.substring(0, atColon));
this.password = usernamePassword.substring(atColon + 1);
} else {
this.principal = new BasicUserPrincipal(usernamePassword);
this.password = null;
}
}
示例7: SSLConnectionSocketFactory
import org.apache.http.util.Args; //导入方法依赖的package包/类
/**
* @since 4.4
*/
public SSLConnectionSocketFactory(
final javax.net.ssl.SSLSocketFactory socketfactory,
final String[] supportedProtocols,
final String[] supportedCipherSuites,
final HostnameVerifier hostnameVerifier) {
this.socketfactory = Args.notNull(socketfactory, "SSL socket factory");
this.supportedProtocols = supportedProtocols;
this.supportedCipherSuites = supportedCipherSuites;
this.hostnameVerifier = hostnameVerifier != null ? hostnameVerifier : getDefaultHostnameVerifier();
}
示例8: validate
import org.apache.http.util.Args; //导入方法依赖的package包/类
@Override
public void validate(
final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
super.validate(cookie, adjustEffectiveHost(origin));
}
示例9: validate
import org.apache.http.util.Args; //导入方法依赖的package包/类
@Override
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
Args.notNull(cookie, "Cookie");
final String name = cookie.getName();
if (name.indexOf(' ') != -1) {
throw new CookieRestrictionViolationException("Cookie name may not contain blanks");
}
if (name.startsWith("$")) {
throw new CookieRestrictionViolationException("Cookie name may not start with $");
}
super.validate(cookie, origin);
}
示例10: getEntry
import org.apache.http.util.Args; //导入方法依赖的package包/类
@Override
public HttpCacheEntry getEntry(final String url) throws IOException {
Args.notNull(url, "URL");
ensureValidState();
synchronized (this) {
return this.entries.get(url);
}
}
示例11: match
import org.apache.http.util.Args; //导入方法依赖的package包/类
@Override
public boolean match(final Cookie cookie, final CookieOrigin origin) {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
final String host = origin.getHost();
final String domain = cookie.getDomain();
if (domain == null) {
return false;
}
return host.equals(domain) || (domain.startsWith(".") && host.endsWith(domain));
}
示例12: rewriteURI
import org.apache.http.util.Args; //导入方法依赖的package包/类
/**
* A convenience method for creating a new {@link URI} whose scheme, host
* and port are taken from the target host, but whose path, query and
* fragment are taken from the existing URI. The fragment is only used if
* dropFragment is false. The path is set to "/" if not explicitly specified.
*
* @param uri
* Contains the path, query and fragment to use.
* @param target
* Contains the scheme, host and port to use.
* @param dropFragment
* True if the fragment should not be copied.
*
* @throws URISyntaxException
* If the resulting URI is invalid.
*/
public static URI rewriteURI(
final URI uri,
final HttpHost target,
final boolean dropFragment) throws URISyntaxException {
Args.notNull(uri, "URI");
if (uri.isOpaque()) {
return uri;
}
final URIBuilder uribuilder = new URIBuilder(uri);
if (target != null) {
uribuilder.setScheme(target.getSchemeName());
uribuilder.setHost(target.getHostName());
uribuilder.setPort(target.getPort());
} else {
uribuilder.setScheme(null);
uribuilder.setHost(null);
uribuilder.setPort(-1);
}
if (dropFragment) {
uribuilder.setFragment(null);
}
if (TextUtils.isEmpty(uribuilder.getPath())) {
uribuilder.setPath("/");
}
return uribuilder.build();
}
示例13: MinimalHttpClient
import org.apache.http.util.Args; //导入方法依赖的package包/类
public MinimalHttpClient(
final HttpClientConnectionManager connManager) {
super();
this.connManager = Args.notNull(connManager, "HTTP connection manager");
this.requestExecutor = new MinimalClientExec(
new HttpRequestExecutor(),
connManager,
DefaultConnectionReuseStrategyHC4.INSTANCE,
DefaultConnectionKeepAliveStrategyHC4.INSTANCE);
this.params = new BasicHttpParams();
}
示例14: FormBodyPart
import org.apache.http.util.Args; //导入方法依赖的package包/类
/**
* @deprecated (4.4) use {@link org.apache.http.entity.mime.FormBodyPartBuilder}.
*/
@Deprecated
public FormBodyPart(final String name, final ContentBody body) {
super();
Args.notNull(name, "Name");
Args.notNull(body, "Body");
this.name = name;
this.body = body;
this.header = new Header();
generateContentDisp(body);
generateContentType(body);
generateTransferEncoding(body);
}
示例15: run
import org.apache.http.util.Args; //导入方法依赖的package包/类
private Result<T> run(final WarcReader reader, final long storePosition) throws Exception {
Args.notNull(reader, "reader");
final T result = processor.process(reader.read(), storePosition);
if (result == null) return null;
return new Result<>(result, this.writer, storePosition, this.out);
}