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


Java Args类代码示例

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


Args类属于org.apache.http.util包,在下文中一共展示了Args类的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: updateSecureConnection

import org.apache.http.util.Args; //导入依赖的package包/类
@Override
public void updateSecureConnection(
        final OperatedClientConnection conn,
        final HttpHost target,
        final HttpContext context,
        final HttpParams params) throws IOException {
    Args.notNull(conn, "Connection");
    Args.notNull(target, "Target host");
    Args.notNull(params, "Parameters");
    Asserts.check(conn.isOpen(), "Connection must be open");

    final SchemeRegistry registry = getSchemeRegistry(context);
    final Scheme schm = registry.getScheme(target.getSchemeName());
    Asserts.check(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory,
        "Socket factory must implement SchemeLayeredSocketFactory");
    final SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
    final Socket sock = lsf.createLayeredSocket(
            conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), params);
    prepareSocket(sock, context, params);
    conn.update(sock, target, lsf.isSecure(sock), params);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:22,代码来源:DefaultClientConnectionOperator.java

示例3: getKeepAliveDuration

import org.apache.http.util.Args; //导入依赖的package包/类
@Override
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
   Args.notNull(response, "HTTP response");
   final HeaderElementIterator it = new BasicHeaderElementIterator(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
   while (it.hasNext()) {
      final HeaderElement he = it.nextElement();
      final String param = he.getName();
      final String value = he.getValue();
      if (value != null && param.equalsIgnoreCase("timeout")) {
         try {
            return Long.parseLong(value) * 1000;
         } catch (final NumberFormatException ignore) {
            LOGGER.warn("keep alive timeout could not be parsed: param=" + param + " value:" + value, ignore);
         }
      }
   }
   return DEFAULT_KEEP_ALIVE;
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:19,代码来源:DefaultConnectionKeepAliveStrategy.java

示例4: nextStep

import org.apache.http.util.Args; //导入依赖的package包/类
/**
 * Provides the next step.
 *
 * @param plan      the planned route
 * @param fact      the currently established route, or
 *                  {@code null} if nothing is established
 *
 * @return  one of the constants defined in this class, indicating
 *          either the next step to perform, or success, or failure.
 *          0 is for success, a negative value for failure.
 */
@Override
public int nextStep(final RouteInfo plan, final RouteInfo fact) {
    Args.notNull(plan, "Planned route");

    int step = UNREACHABLE;

    if ((fact == null) || (fact.getHopCount() < 1)) {
        step = firstStep(plan);
    } else if (plan.getHopCount() > 1) {
        step = proxiedStep(plan, fact);
    } else {
        step = directStep(plan, fact);
    }

    return step;

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

示例5: Scheme

import org.apache.http.util.Args; //导入依赖的package包/类
/**
 * Creates a new scheme.
 * Whether the created scheme allows for layered connections
 * depends on the class of {@code factory}.
 *
 * @param name      the scheme name, for example "http".
 *                  The name will be converted to lowercase.
 * @param factory   the factory for creating sockets for communication
 *                  with this scheme
 * @param port      the default port for this scheme
 *
 * @deprecated (4.1)  Use {@link #Scheme(String, int, SchemeSocketFactory)}
 */
@Deprecated
public Scheme(final String name,
              final SocketFactory factory,
              final int port) {

    Args.notNull(name, "Scheme name");
    Args.notNull(factory, "Socket factory");
    Args.check(port > 0 && port <= 0xffff, "Port is invalid");

    this.name = name.toLowerCase(Locale.ENGLISH);
    if (factory instanceof LayeredSocketFactory) {
        this.socketFactory = new SchemeLayeredSocketFactoryAdaptor(
                (LayeredSocketFactory) factory);
        this.layered = true;
    } else {
        this.socketFactory = new SchemeSocketFactoryAdaptor(factory);
        this.layered = false;
    }
    this.defaultPort = port;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:34,代码来源:Scheme.java

示例6: getKeepAliveDuration

import org.apache.http.util.Args; //导入依赖的package包/类
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
    Args.notNull(response, "HTTP response");
    final HeaderElementIterator it = new BasicHeaderElementIterator(
            response.headerIterator(HTTP.CONN_KEEP_ALIVE));
    while (it.hasNext()) {
        final HeaderElement he = it.nextElement();
        final String param = he.getName();
        final String value = he.getValue();
        if (value != null && param.equalsIgnoreCase("timeout")) {
            try {
                return Long.parseLong(value) * 1000;
            } catch(final NumberFormatException ignore) {
            }
        }
    }
    return -1;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:18,代码来源:DefaultConnectionKeepAliveStrategyHC4.java

示例7: copy

import org.apache.http.util.Args; //导入依赖的package包/类
public static Builder copy(final CacheConfig config) {
    Args.notNull(config, "Cache config");
    return new Builder()
        .setMaxObjectSize(config.getMaxObjectSize())
        .setMaxCacheEntries(config.getMaxCacheEntries())
        .setMaxUpdateRetries(config.getMaxUpdateRetries())
        .setHeuristicCachingEnabled(config.isHeuristicCachingEnabled())
        .setHeuristicCoefficient(config.getHeuristicCoefficient())
        .setHeuristicDefaultLifetime(config.getHeuristicDefaultLifetime())
        .setSharedCache(config.isSharedCache())
        .setAsynchronousWorkersMax(config.getAsynchronousWorkersMax())
        .setAsynchronousWorkersCore(config.getAsynchronousWorkersCore())
        .setAsynchronousWorkerIdleLifetimeSecs(config.getAsynchronousWorkerIdleLifetimeSecs())
        .setRevalidationQueueSize(config.getRevalidationQueueSize())
        .setNeverCacheHTTP10ResponsesWithQueryString(config.isNeverCacheHTTP10ResponsesWithQuery());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:CacheConfig.java

示例8: match

import org.apache.http.util.Args; //导入依赖的package包/类
/**
 * Match cookie domain attribute.
 */
public boolean match(final Cookie cookie, final CookieOrigin origin) {
    Args.notNull(cookie, "Cookie");
    Args.notNull(origin, "Cookie origin");
    final String host = origin.getHost().toLowerCase(Locale.ENGLISH);
    final String cookieDomain = cookie.getDomain();

    // The effective host name MUST domain-match the Domain
    // attribute of the cookie.
    if (!domainMatch(host, cookieDomain)) {
        return false;
    }
    // effective host name minus domain must not contain any dots
    final String effectiveHostWithoutDomain = host.substring(
            0, host.length() - cookieDomain.length());
    return effectiveHostWithoutDomain.indexOf('.') == -1;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:20,代码来源:RFC2965DomainAttributeHandlerHC4.java

示例9: closeIdle

import org.apache.http.util.Args; //导入依赖的package包/类
/**
 * Closes connections that have been idle longer than the given period
 * of time and evicts them from the pool.
 *
 * @param idletime maximum idle time.
 * @param tunit time unit.
 */
public void closeIdle(final long idletime, final TimeUnit tunit) {
    Args.notNull(tunit, "Time unit");
    long time = tunit.toMillis(idletime);
    if (time < 0) {
        time = 0;
    }
    final long deadline = System.currentTimeMillis() - time;
    enumAvailable(new PoolEntryCallback<T, C>() {

        public void process(final PoolEntry<T, C> entry) {
            if (entry.getUpdated() <= deadline) {
                entry.close();
            }
        }

    });
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:25,代码来源:AbstractConnPool.java

示例10: authSucceeded

import org.apache.http.util.Args; //导入依赖的package包/类
@Override
public void authSucceeded(
        final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
    Args.notNull(authhost, "Host");
    Args.notNull(authScheme, "Auth scheme");
    Args.notNull(context, "HTTP context");

    final HttpClientContext clientContext = HttpClientContext.adapt(context);

    if (isCachable(authScheme)) {
        AuthCache authCache = clientContext.getAuthCache();
        if (authCache == null) {
            authCache = new BasicAuthCache();
            clientContext.setAuthCache(authCache);
        }
        if (this.log.isDebugEnabled()) {
            this.log.debug("Caching '" + authScheme.getSchemeName() +
                    "' auth scheme for " + authhost);
        }
        authCache.put(authhost, authScheme);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:AuthenticationStrategyImpl.java

示例11: layerProtocol

import org.apache.http.util.Args; //导入依赖的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

示例12: closeIdleConnections

import org.apache.http.util.Args; //导入依赖的package包/类
public synchronized void closeIdleConnections(final long idletime, final TimeUnit tunit) {
    Args.notNull(tunit, "Time unit");
    if (this.isShutdown.get()) {
        return;
    }
    if (!this.leased) {
        long time = tunit.toMillis(idletime);
        if (time < 0) {
            time = 0;
        }
        final long deadline = System.currentTimeMillis() - time;
        if (this.updated <= deadline) {
            closeConnection();
        }
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:17,代码来源:BasicHttpClientConnectionManager.java

示例13: PublicSuffixMatcher

import org.apache.http.util.Args; //导入依赖的package包/类
/**
 * @since 4.5
 */
public PublicSuffixMatcher(final Collection<PublicSuffixList> lists) {
    Args.notNull(lists,  "Domain suffix lists");
    this.rules = new ConcurrentHashMap<String, DomainType>();
    this.exceptions = new ConcurrentHashMap<String, DomainType>();
    for (final PublicSuffixList list: lists) {
        final DomainType domainType = list.getType();
        final List<String> rules = list.getRules();
        for (final String rule: rules) {
            this.rules.put(rule, domainType);
        }
        final List<String> exceptions = list.getExceptions();
        if (exceptions != null) {
            for (final String exception: exceptions) {
                this.exceptions.put(exception, domainType);
            }
        }
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:22,代码来源:PublicSuffixMatcher.java

示例14: setTaskData

import org.apache.http.util.Args; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @throws IllegalArgumentException {@inheritDoc}
 */
@Override
public RestRootEntity<ServiceData> setTaskData(@Nonnull String tkiid, @Nonnull Map<String, Object> parameters) {
    tkiid = Args.notNull(tkiid, "Task id (tkiid)");
    parameters = Args.notNull(parameters, "Variables (parameters)");
    Args.notEmpty(parameters.keySet(), "Parameters names");
    Args.notEmpty(parameters.values(), "Parameters values");

    Gson gson = new GsonBuilder().setDateFormat(DATE_TIME_FORMAT).create();
    String params = gson.toJson(parameters);

    URI uri = new SafeUriBuilder(rootUri).addPath(tkiid).addParameter(ACTION, ACTION_SET_DATA)
            .addParameter(PARAMS, params).build();

    return makePost(httpClient, httpContext, uri, new TypeToken<RestRootEntity<ServiceData>>() {});
}
 
开发者ID:egetman,项目名称:ibm-bpm-rest-client,代码行数:21,代码来源:TaskClientImpl.java

示例15: parse

import org.apache.http.util.Args; //导入依赖的package包/类
/**
 * Parse cookie domain attribute.
 */
@Override
public void parse(
        final SetCookie cookie, final String domain) throws MalformedCookieException {
    Args.notNull(cookie, "Cookie");
    if (domain == null) {
        throw new MalformedCookieException(
                "Missing value for domain attribute");
    }
    if (domain.trim().isEmpty()) {
        throw new MalformedCookieException(
                "Blank value for domain attribute");
    }
    String s = domain;
    s = s.toLowerCase(Locale.ROOT);
    if (!domain.startsWith(".")) {
        // Per RFC 2965 section 3.2.2
        // "... If an explicitly specified value does not start with
        // a dot, the user agent supplies a leading dot ..."
        // That effectively implies that the domain attribute
        // MAY NOT be an IP address of a host name
        s = '.' + s;
    }
    cookie.setDomain(s);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:28,代码来源:RFC2965DomainAttributeHandler.java


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