org.eclipse.californium.core.coap.OptionSet.getETagCount()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(65)

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

OptionSet.getETagCount介绍

[英]Returns the number of ETag options.
[中]返回ETag选项的数量。

代码示例

代码示例来源:origin: eclipse/californium

/**
 * Checks for ETag option.
 * 
 * @param response
 *            the response
 * @return true, if successful
 */
protected boolean hasEtag(Response response) {
  // boolean success = response.hasOption(OptionNumberRegistry.ETAG);
  boolean success = response.getOptions().getETagCount() > 0;
  if (!success) {
    System.out.println("FAIL: Response without Etag");
  } else {
    System.out.printf(
        "PASS: Etag (%s)\n",
        Utils.toHexString(response.getOptions().getETags()
            .get(0)));
  }
  return success;
}

代码示例来源:origin: eclipse/californium

protected final void appendEtags(final OptionSet options) {
  if (options != null && options.getETagCount() > 0) {
    buffer.append(", ETags(");
    int i = 0;
    for (byte[] tag : options.getETags()) {
      buffer.append(Utils.toHexString(tag));
      if (++i < options.getETagCount()) {
        buffer.append(", ");
      }
    }
    buffer.append(")");
  }
}
protected final void appendRequestDetails(final Request request) {

代码示例来源:origin: eclipse/californium

@Override
  public void check(final Response response) {
    assertTrue("Response has no ETag", response.getOptions().getETagCount() > 0);
    Object obj = storage.get(var);
    assertThat("Object stored under " + var + " is not an ETag", obj, is(instanceOf(byte[].class)));
    assertThat("Response contains wrong ETag", (byte[]) obj,
        is(response.getOptions().getETags().get(0)));
  }
});

代码示例来源:origin: eclipse/californium

@Override
  public void check(final Response response) {
    assertTrue("Response has no ETag", response.getOptions().getETagCount() > 0);
    storage.put(var, response.getOptions().getETags().get(0));
  }
});

代码示例来源:origin: eclipse/californium

System.out.println("---------------\nGET /validate\n---------------");
response = client.get();
if (response.getOptions().getETagCount()==1) {
  etag = response.getOptions().getETags().get(0);
  System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]");
System.out.println("---------------\nGET /validate with If-Match\n---------------");
response = client.get();
if (response.getOptions().getETagCount()==1) {
  etag = response.getOptions().getETags().get(0);
  System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]");

相关文章

微信公众号

最新文章

更多