当前位置: 首页>>代码示例>>Java>>正文


Java Args.notNull方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:LocalRestRequest.java

示例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();
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:27,代码来源:PoolEntryFuture.java

示例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();
        }
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:BasicClientConnectionManager.java

示例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");
        }
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:BasicAuthCache.java

示例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<>();
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:36,代码来源:DatarouterHttpRequest.java

示例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;
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:UsernamePasswordCredentials.java

示例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();
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:SSLConnectionSocketFactory.java

示例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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:RFC2965Spec.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:RFC2109Spec.java

示例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);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:9,代码来源:ManagedHttpCacheStorage.java

示例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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:12,代码来源:RFC2109DomainHandler.java

示例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();
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:43,代码来源:URIUtilsHC4.java

示例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();
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:12,代码来源:MinimalHttpClient.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:FormBodyPart.java

示例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);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:7,代码来源:ParallelFilteredProcessorRunner.java


注:本文中的org.apache.http.util.Args.notNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。