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


Java Asserts.notNull方法代码示例

本文整理汇总了Java中org.apache.http.util.Asserts.notNull方法的典型用法代码示例。如果您正苦于以下问题:Java Asserts.notNull方法的具体用法?Java Asserts.notNull怎么用?Java Asserts.notNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.util.Asserts的用法示例。


在下文中一共展示了Asserts.notNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: layerProtocol

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
/**
 * Layers a protocol on top of an established tunnel.
 *
 * @param context   the context for layering
 * @param params    the parameters for layering
 *
 * @throws IOException  in case of a problem
 */
public void layerProtocol(final HttpContext context, final HttpParams params)
    throws IOException {

    //@@@ is context allowed to be null? depends on operator?
    Args.notNull(params, "HTTP parameters");
    Asserts.notNull(this.tracker, "Route tracker");
    Asserts.check(this.tracker.isConnected(), "Connection not open");
    Asserts.check(this.tracker.isTunnelled(), "Protocol layering without a tunnel not supported");
    Asserts.check(!this.tracker.isLayered(), "Multiple protocol layering not supported");
    // - collect the arguments
    // - call the operator
    // - update the tracking data
    // In this order, we can be sure that only a successful
    // layering on top of the connection will be tracked.

    final HttpHost target = tracker.getTargetHost();

    connOperator.updateSecureConnection(this.connection, target,
                                         context, params);

    this.tracker.layerProtocol(this.connection.isSecure());

}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:32,代码来源:AbstractPoolEntry.java

示例2: buildNotifyJson

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
private String buildNotifyJson( @Nonnull final AbstractBuild build,
                                @Nonnull final Map<String,?> env )
{
    Map<String,?> binding = new HashMap<String, Object>(){{
       put( "jenkins", notNull( Jenkins.getInstance(), "Jenkins instance" ));
       put( "build",   notNull( build, "Build instance" ));
       put( "env",     notNull( env, "Build environment" ));
    }};

    String json     = null;
    String template = "<%\n\n" + JSON_FUNCTION + "\n\n%>\n\n" +
                      notBlank( notifyTemplate, "Notify template" );

    try
    {
        json = notBlank( new SimpleTemplateEngine( getClass().getClassLoader()).
                         createTemplate( template ).
                         make( binding ).toString(), "Payload JSON" ).trim();

        Asserts.check(( json.startsWith( "{" ) && json.endsWith( "}" )) ||
                      ( json.startsWith( "[" ) && json.endsWith( "]" )),
                      "Illegal JSON content: should start and end with {} or []" );

        Asserts.notNull( new JsonSlurper().parseText( json ), "Parsed JSON" );
    }
    catch ( Exception e )
    {
        throwError(( json == null ?
            String.format( "Failed to parse Groovy template:%s%s%s",
                           LINE, template, LINE ) :
            String.format( "Failed to validate JSON payload (check with http://jsonlint.com/):%s%s%s",
                           LINE, json, LINE )), e );
    }

    return json;
}
 
开发者ID:evgeny-goldin,项目名称:jenkins-notify-plugin,代码行数:37,代码来源:NotifyRecorder.java

示例3: index

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
@Override
public void index(Document ... docs) {
    Asserts.notNull(docs,"Document to index should not be null.");
    Asserts.check(docs.length > 0, "Should be at least one document to index.");
    for(Document doc: docs) {
        indexSingleDocument(doc);
    }
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:9,代码来源:SolrSearchServer.java

示例4: getLocationURI

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
public URI getLocationURI(
        final HttpRequest request,
        final HttpResponse response,
        final HttpContext context) throws ProtocolException {
    Args.notNull(request, "HTTP request");
    Args.notNull(response, "HTTP response");
    Args.notNull(context, "HTTP context");

    final HttpClientContext clientContext = HttpClientContext.adapt(context);

    //get the location header to find out where to redirect to
    final Header locationHeader = response.getFirstHeader("location");
    if (locationHeader == null) {
        // got a redirect response, but no location header
        throw new ProtocolException(
                "Received redirect response " + response.getStatusLine()
                + " but no location header");
    }
    final String location = locationHeader.getValue();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Redirect requested to location '" + location + "'");
    }

    final RequestConfig config = clientContext.getRequestConfig();

    URI uri = createLocationURI(location);

    // rfc2616 demands the location value be a complete URI
    // Location       = "Location" ":" absoluteURI
    try {
        if (!uri.isAbsolute()) {
            if (!config.isRelativeRedirectsAllowed()) {
                throw new ProtocolException("Relative redirect location '"
                        + uri + "' not allowed");
            }
            // Adjust location URI
            final HttpHost target = clientContext.getTargetHost();
            Asserts.notNull(target, "Target host");
            final URI requestURI = new URI(request.getRequestLine().getUri());
            final URI absoluteRequestURI = URIUtilsHC4.rewriteURI(requestURI, target, false);
            uri = URIUtilsHC4.resolve(absoluteRequestURI, uri);
        }
    } catch (final URISyntaxException ex) {
        throw new ProtocolException(ex.getMessage(), ex);
    }

    RedirectLocationsHC4 redirectLocations = (RedirectLocationsHC4) clientContext.getAttribute(
            HttpClientContext.REDIRECT_LOCATIONS);
    if (redirectLocations == null) {
        redirectLocations = new RedirectLocationsHC4();
        context.setAttribute(HttpClientContext.REDIRECT_LOCATIONS, redirectLocations);
    }
    if (!config.isCircularRedirectsAllowed()) {
        if (redirectLocations.contains(uri)) {
            throw new CircularRedirectException("Circular redirect to '" + uri + "'");
        }
    }
    redirectLocations.add(uri);
    return uri;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:61,代码来源:DefaultRedirectStrategy.java

示例5: authenticate

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
private Header authenticate(
        final AuthScheme authScheme,
        final Credentials creds,
        final HttpRequest request,
        final HttpContext context) throws AuthenticationException {
    Asserts.notNull(authScheme, "Auth scheme");
    if (authScheme instanceof ContextAwareAuthScheme) {
        return ((ContextAwareAuthScheme) authScheme).authenticate(creds, request, context);
    } else {
        return authScheme.authenticate(creds, request);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:RequestAuthenticationBase.java

示例6: determineRoute

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
@Override
public HttpRoute determineRoute(final HttpHost target,
                                final HttpRequest request,
                                final HttpContext context)
    throws HttpException {

    Args.notNull(request, "HTTP request");

    // If we have a forced route, we can do without a target.
    HttpRoute route =
        ConnRouteParams.getForcedRoute(request.getParams());
    if (route != null) {
        return route;
    }

    // If we get here, there is no forced route.
    // So we need a target to compute a route.

    Asserts.notNull(target, "Target host");

    final InetAddress local =
        ConnRouteParams.getLocalAddress(request.getParams());
    final HttpHost proxy = determineProxy(target, request, context);

    final Scheme schm =
        this.schemeRegistry.getScheme(target.getSchemeName());
    // as it is typically used for TLS/SSL, we assume that
    // a layered scheme implies a secure connection
    final boolean secure = schm.isLayered();

    if (proxy == null) {
        route = new HttpRoute(target, local, secure);
    } else {
        route = new HttpRoute(target, local, proxy, secure);
    }
    return route;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:38,代码来源:ProxySelectorRoutePlanner.java

示例7: tunnelTarget

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
/**
 * Tracks tunnelling of the connection to the target.
 * The tunnel has to be established outside by sending a CONNECT
 * request to the (last) proxy.
 *
 * @param secure    {@code true} if the tunnel should be
 *                  considered secure, {@code false} otherwise
 * @param params    the parameters for tunnelling the connection
 *
 * @throws IOException  in case of a problem
 */
public void tunnelTarget(final boolean secure, final HttpParams params)
    throws IOException {

    Args.notNull(params, "HTTP parameters");
    Asserts.notNull(this.tracker, "Route tracker");
    Asserts.check(this.tracker.isConnected(), "Connection not open");
    Asserts.check(!this.tracker.isTunnelled(), "Connection is already tunnelled");

    this.connection.update(null, tracker.getTargetHost(),
                           secure, params);
    this.tracker.tunnelTarget(secure);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:AbstractPoolEntry.java

示例8: getLocationURI

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
public URI getLocationURI(
        final HttpRequest request,
        final HttpResponse response,
        final HttpContext context) throws ProtocolException {
    Args.notNull(request, "HTTP request");
    Args.notNull(response, "HTTP response");
    Args.notNull(context, "HTTP context");

    final HttpClientContext clientContext = HttpClientContext.adapt(context);

    //get the location header to find out where to redirect to
    final Header locationHeader = response.getFirstHeader("location");
    if (locationHeader == null) {
        // got a redirect response, but no location header
        throw new ProtocolException(
                "Received redirect response " + response.getStatusLine()
                + " but no location header");
    }
    final String location = locationHeader.getValue();
    if (this.log.isDebugEnabled()) {
        this.log.debug("Redirect requested to location '" + location + "'");
    }

    final RequestConfig config = clientContext.getRequestConfig();

    URI uri = createLocationURI(location);

    // rfc2616 demands the location value be a complete URI
    // Location       = "Location" ":" absoluteURI
    try {
        if (!uri.isAbsolute()) {
            if (!config.isRelativeRedirectsAllowed()) {
                throw new ProtocolException("Relative redirect location '"
                        + uri + "' not allowed");
            }
            // Adjust location URI
            final HttpHost target = clientContext.getTargetHost();
            Asserts.notNull(target, "Target host");
            final URI requestURI = new URI(request.getRequestLine().getUri());
            final URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, false);
            uri = URIUtils.resolve(absoluteRequestURI, uri);
        }
    } catch (final URISyntaxException ex) {
        throw new ProtocolException(ex.getMessage(), ex);
    }

    RedirectLocations redirectLocations = (RedirectLocations) clientContext.getAttribute(
            HttpClientContext.REDIRECT_LOCATIONS);
    if (redirectLocations == null) {
        redirectLocations = new RedirectLocations();
        context.setAttribute(HttpClientContext.REDIRECT_LOCATIONS, redirectLocations);
    }
    if (!config.isCircularRedirectsAllowed()) {
        if (redirectLocations.contains(uri)) {
            throw new CircularRedirectException("Circular redirect to '" + uri + "'");
        }
    }
    redirectLocations.add(uri);
    return uri;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:61,代码来源:DefaultRedirectStrategy.java

示例9: tunnelTarget

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
/**
 * Tracks tunnelling to the target.
 *
 * @param secure    {@code true} if the route is secure,
 *                  {@code false} otherwise
 */
public final void tunnelTarget(final boolean secure) {
    Asserts.check(this.connected, "No tunnel unless connected");
    Asserts.notNull(this.proxyChain, "No tunnel without proxy");
    this.tunnelled = TunnelType.TUNNELLED;
    this.secure    = secure;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:RouteTracker.java

示例10: tunnelProxy

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
/**
 * Tracks tunnelling to a proxy in a proxy chain.
 * This will extend the tracked proxy chain, but it does not mark
 * the route as tunnelled. Only end-to-end tunnels are considered there.
 *
 * @param proxy     the proxy tunnelled to
 * @param secure    {@code true} if the route is secure,
 *                  {@code false} otherwise
 */
public final void tunnelProxy(final HttpHost proxy, final boolean secure) {
    Args.notNull(proxy, "Proxy host");
    Asserts.check(this.connected, "No tunnel unless connected");
    Asserts.notNull(this.proxyChain, "No tunnel without proxy");
    // prepare an extended proxy chain
    final HttpHost[] proxies = new HttpHost[this.proxyChain.length+1];
    System.arraycopy(this.proxyChain, 0,
                     proxies, 0, this.proxyChain.length);
    proxies[proxies.length-1] = proxy;

    this.proxyChain = proxies;
    this.secure     = secure;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:RouteTracker.java

示例11: BloomFilterRepo

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
/**
 * @param expectedInsertions 预期插入数.
 * @param fpp                误报率 (0~1).
 */
public BloomFilterRepo(File file, int expectedInsertions, double fpp) {
	this.expectedInsertions = expectedInsertions;
	this.fpp = fpp;
	Asserts.notNull(file, "save file");
	this.file = file;
}
 
开发者ID:myshzzx,项目名称:mlib,代码行数:11,代码来源:BloomFilterRepo.java

示例12: getJkesProperties

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
public static JkesProperties getJkesProperties() {
    Asserts.notNull(jkesProperties, "JkesProperties config must be set into Config");
    return jkesProperties;
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:5,代码来源:Config.java

示例13: ensureAuthScheme

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
private void ensureAuthScheme(final AuthScheme authScheme) {
    Asserts.notNull(authScheme, "Auth scheme");
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:4,代码来源:HttpAuthenticator.java

示例14: streamWrite

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
private void streamWrite(final byte[] b, final int off, final int len) throws IOException {
    Asserts.notNull(outstream, "Output stream");
    this.outstream.write(b, off, len);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:5,代码来源:SessionOutputBufferImpl.java

示例15: streamRead

import org.apache.http.util.Asserts; //导入方法依赖的package包/类
private int streamRead(final byte[] b, final int off, final int len) throws IOException {
    Asserts.notNull(this.instream, "Input stream");
    return this.instream.read(b, off, len);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:5,代码来源:SessionInputBufferImpl.java


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