org.apache.hc.core5.util.Args类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.apache.hc.core5.util.Args类的一些代码示例,展示了Args类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Args类的具体详情如下:
包路径:org.apache.hc.core5.util.Args
类名称:Args

Args介绍

暂无

代码示例

代码示例来源:origin: apache/httpcomponents-client

@Override
public Cancellable putEntry(final String key, final HttpCacheEntry entry, final FutureCallback<Boolean> callback) {
  Args.notEmpty(key, "Key");
  Args.notNull(entry, "Cache ehtry");
  Args.notNull(callback, "Callback");
  try {
    cacheStorage.putEntry(key, entry);
    callback.completed(Boolean.TRUE);
  } catch (final Exception ex) {
    callback.failed(ex);
  }
  return Operations.nonCancellable();
}

代码示例来源:origin: apache/httpcomponents-client

final Map<String,String> variantMap) {
super();
Args.notNull(requestDate, "Request date");
Args.notNull(responseDate, "Response date");
Args.check(status >= HttpStatus.SC_SUCCESS, "Status code");
Args.notNull(responseHeaders, "Response headers");
this.requestDate = requestDate;
this.responseDate = responseDate;

代码示例来源:origin: apache/httpcomponents-client

public ExponentialBackOffSchedulingStrategy(
    final long backOffRate,
    final TimeValue initialExpiry,
    final TimeValue maxExpiry) {
  this.backOffRate = Args.notNegative(backOffRate, "BackOff rate");
  this.initialExpiry = Args.notNull(initialExpiry, "Initial expiry");
  this.maxExpiry = Args.notNull(maxExpiry, "Max expiry");
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

/**
 * Adds the filter before the filter with the given name.
 */
public final AsyncServerBootstrap addFilterBefore(final String existing, final String name, final AsyncFilterHandler filterHandler) {
  Args.notBlank(existing, "Existing");
  Args.notBlank(name, "Name");
  Args.notNull(filterHandler, "Filter handler");
  filters.add(new FilterEntry<>(FilterEntry.Postion.BEFORE, name, filterHandler, existing));
  return this;
}

代码示例来源:origin: apache/httpcomponents-client

public AuthenticatingAsyncDecorator(final AsyncServerExchangeHandler exchangeHandler, final Authenticator authenticator) {
  this.exchangeHandler = Args.notNull(exchangeHandler, "Request handler");
  this.authenticator = Args.notNull(authenticator, "Authenticator");
  this.responseProducerRef = new AtomicReference<>(null);
  this.authTokenExtractor = new BasicAuthTokenExtractor();
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

private HttpRoute(final HttpHost targetHost, final InetAddress local, final List<HttpHost> proxies,
         final boolean secure, final TunnelType tunnelled, final LayerType layered) {
  Args.notNull(targetHost, "Target host");
  Args.notNegative(targetHost.getPort(), "Target port");
  this.targetHost = targetHost;
  this.localAddress = local;
  if (proxies != null && !proxies.isEmpty()) {
    this.proxyChain = new ArrayList<>(proxies);
  } else {
    this.proxyChain = null;
  }
  if (tunnelled == TunnelType.TUNNELLED) {
    Args.check(this.proxyChain != null, "Proxy required if tunnelled");
  }
  this.secure       = secure;
  this.tunnelled    = tunnelled != null ? tunnelled : TunnelType.PLAIN;
  this.layered      = layered != null ? layered : LayerType.PLAIN;
}

代码示例来源:origin: apache/httpcomponents-core

public FrameOutputBuffer(final BasicH2TransportMetrics metrics, final int maxFramePayloadSize) {
  super();
  Args.notNull(metrics, "HTTP2 transport metrcis");
  Args.positive(maxFramePayloadSize, "Maximum payload size");
  this.metrics = metrics;
  this.maxFramePayloadSize = maxFramePayloadSize;
  this.buffer = new byte[FrameConsts.HEAD_LEN + maxFramePayloadSize + FrameConsts.MAX_PADDING + 1];
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

/**
 * Creates a new instance of {@link ContentType}.
 *
 * @param mimeType MIME type. It may not be {@code null} or empty. It may not contain
 *        characters {@code <">, <;>, <,>} reserved by the HTTP specification.
 * @param charset charset.
 * @return content type
 */
public static ContentType create(final String mimeType, final Charset charset) {
  final String normalizedMimeType = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.ROOT);
  Args.check(valid(normalizedMimeType), "MIME type may not contain reserved characters");
  return new ContentType(normalizedMimeType, charset);
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

@Override
public final HttpHost getHopTarget(final int hop) {
  Args.notNegative(hop, "Hop index");
  final int hopcount = getHopCount();
  Args.check(hop < hopcount, "Hop index exceeds tracked route length");
  HttpHost result = null;
  if (hop < hopcount-1) {
    result = this.proxyChain[hop];
  } else {
    result = this.targetHost;
  }
  return result;
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

/**
 * Sets the amount of time, in milliseconds, to wait between
 * adjustments in pool sizes for a given host, to allow
 * enough time for the adjustments to take effect. Defaults
 * to 5000L (5 seconds).
 * @param l must be positive
 */
public void setCooldownMillis(final long l) {
  Args.positive(coolDown, "Cool down");
  coolDown = l;
}

代码示例来源:origin: apache/httpcomponents-core

public RawFrame createWindowUpdate(final int streamId, final int increment) {
  Args.notNegative(streamId, "Stream id");
  Args.positive(increment, "Increment");
  final ByteBuffer payload = ByteBuffer.allocate(4);
  payload.putInt(increment);
  payload.flip();
  return new RawFrame(FrameType.WINDOW_UPDATE.getValue(), 0, streamId, payload);
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

public LengthDelimitedDecoder(
    final ReadableByteChannel channel,
    final SessionInputBuffer buffer,
    final BasicHttpTransportMetrics metrics,
    final long contentLength) {
  super(channel, buffer, metrics);
  Args.notNegative(contentLength, "Content length");
  this.contentLength = contentLength;
}

代码示例来源:origin: apache/httpcomponents-core

public Builder setMaxFrameSize(final int maxFrameSize) {
  this.maxFrameSize = Args.checkRange(maxFrameSize, FrameConsts.MIN_FRAME_SIZE, FrameConsts.MAX_FRAME_SIZE,
      "Invalid max frame size");
  return this;
}

代码示例来源:origin: apache/httpcomponents-client

/**
 * Update the entry with the new information from the response.  Should only be used for
 * 304 responses.
 */
public HttpCacheEntry updateCacheEntry(
    final String requestId,
    final HttpCacheEntry entry,
    final Date requestDate,
    final Date responseDate,
    final HttpResponse response) throws ResourceIOException {
  Args.check(response.getCode() == HttpStatus.SC_NOT_MODIFIED,
      "Response must have 304 status code");
  final Header[] mergedHeaders = mergeHeaders(entry, response);
  Resource resource = null;
  if (entry.getResource() != null) {
    resource = resourceFactory.copy(requestId, entry.getResource());
  }
  return new HttpCacheEntry(
      requestDate,
      responseDate,
      entry.getStatus(),
      mergedHeaders,
      resource);
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

/**
 * Updates the auth state with a queue of auth options.
 *
 * @param authOptions a queue of auth options. May not be null or empty.
 */
public void setOptions(final Queue<AuthScheme> authOptions) {
  Args.notEmpty(authOptions, "Queue of auth options");
  this.authOptions = authOptions;
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5

/**
 * @since 4.4
 */
public MultipartEntityBuilder setMimeSubtype(final String subType) {
  Args.notBlank(subType, "MIME subtype");
  this.contentType = ContentType.create("multipart/" + subType);
  return this;
}

代码示例来源:origin: org.apache.httpcomponents.core5/httpcore5

/**
 * Adds the filter before the filter with the given name.
 */
public final ServerBootstrap addFilterBefore(final String existing, final String name, final HttpFilterHandler filterHandler) {
  Args.notBlank(existing, "Existing");
  Args.notBlank(name, "Name");
  Args.notNull(filterHandler, "Filter handler");
  filters.add(new FilterEntry<>(FilterEntry.Postion.BEFORE, name, filterHandler, existing));
  return this;
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Resource generate(final String requestId, final byte[] content) throws ResourceIOException {
  Args.notNull(content, "Content");
  return generate(requestId, content, 0, content.length);
}

代码示例来源:origin: apache/httpcomponents-core

FrameInputBuffer(final BasicH2TransportMetrics metrics, final int bufferLen, final int maxFramePayloadSize) {
  Args.notNull(metrics, "HTTP2 transport metrcis");
  Args.positive(maxFramePayloadSize, "Maximum payload size");
  this.metrics = metrics;
  this.maxFramePayloadSize = maxFramePayloadSize;
  this.buffer = new byte[bufferLen];
  this.dataLen = 0;
}

代码示例来源:origin: apache/httpcomponents-core

/**
 * Creates a new instance of {@link ContentType}.
 *
 * @param mimeType MIME type. It may not be {@code null} or empty. It may not contain
 *        characters {@code <">, <;>, <,>} reserved by the HTTP specification.
 * @param charset charset.
 * @return content type
 */
public static ContentType create(final String mimeType, final Charset charset) {
  final String normalizedMimeType = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.ROOT);
  Args.check(valid(normalizedMimeType), "MIME type may not contain reserved characters");
  return new ContentType(normalizedMimeType, charset);
}

相关文章