本文整理了Java中org.eclipse.californium.core.coap.OptionSet.getETags()
方法的一些代码示例,展示了OptionSet.getETags()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OptionSet.getETags()
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.OptionSet
类名称:OptionSet
方法名:getETags
[英]Returns the list of ETags. In a response, there MUST only be one ETag that defines the payload or the resource given through the Location-* options. In a request, there can be multiple ETags for validation. The OptionSet uses lazy initialization for this list.
[中]返回ETag的列表。在响应中,必须只有一个ETag定义有效负载或通过Location-*选项提供的资源。在一个请求中,可以有多个ETag进行验证。OptionSet对该列表使用延迟初始化。
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Returns the number of ETag options.
* @return the count
*/
public int getETagCount() {
return getETags().size();
}
代码示例来源:origin: eclipse/californium
/**
* Removes a specific ETag from the ETag options.
* Returns the current OptionSet object for a fluent API.
* @param etag the ETag to remove
* @return this OptionSet
*/
public OptionSet removeETag(byte[] etag) {
getETags().remove(etag);
return this;
}
代码示例来源:origin: eclipse/californium
/**
* Removes all ETag options.
* Returns the current OptionSet object for a fluent API.
* @return this OptionSet
*/
public OptionSet clearETags() {
getETags().clear();
return this;
}
代码示例来源:origin: eclipse/californium
/**
* Returns the number of ETag options.
* @return the count
*/
public int getETagCount() {
return getETags().size();
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Removes a specific ETag from the ETag options.
* Returns the current OptionSet object for a fluent API.
* @param etag the ETag to remove
* @return this OptionSet
*/
public OptionSet removeETag(byte[] etag) {
getETags().remove(etag);
return this;
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Removes all ETag options.
* Returns the current OptionSet object for a fluent API.
* @return this OptionSet
*/
public OptionSet clearETags() {
getETags().clear();
return this;
}
代码示例来源:origin: eclipse/californium
/**
* Adds an ETag to the ETag options.
* Returns the current OptionSet object for a fluent API.
* @param etag the ETag to add
* @return this OptionSet
*/
public OptionSet addETag(byte[] etag) {
if (etag==null)
throw new IllegalArgumentException("ETag option must not be null");
// TODO: ProxyHttp uses ETags that are larger than 8 bytes (20).
// if (opaque.length < 1 || 8 < opaque.length)
// throw new IllegalArgumentException("ETag option's length must be between 1 and 8 inclusive but was "+opaque.length);
getETags().add(etag);
return this;
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Adds an ETag to the ETag options.
* Returns the current OptionSet object for a fluent API.
* @param etag the ETag to add
* @return this OptionSet
*/
public OptionSet addETag(byte[] etag) {
if (etag==null)
throw new IllegalArgumentException("ETag option must not be null");
// TODO: ProxyHttp uses ETags that are larger than 8 bytes (20).
// if (opaque.length < 1 || 8 < opaque.length)
// throw new IllegalArgumentException("ETag option's length must be between 1 and 8 inclusive but was "+opaque.length);
getETags().add(etag);
return this;
}
代码示例来源: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);
storage.put(var, response.getOptions().getETags().get(0));
}
});
代码示例来源: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 Message message) {
assertThat(message.getOptions().getETags(), hasItem(etag));
}
代码示例来源:origin: eclipse/californium
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(response.getResponseText());
etag = response.getOptions().getETags().get(0);
System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]");
System.out.println(response.getResponseText());
etag = response.getOptions().getETags().get(0);
System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]");
System.out.println(response.getResponseText());
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(response.getResponseText());
etag = response.getOptions().getETags().get(0);
System.out.println(response.getCode() + " - ETag [" + Utils.toHexString(etag) + "]");
System.out.println(response.getResponseText());
代码示例来源:origin: eclipse/californium
success &= hasEtag(response);
success &= hasNonEmptyPalyoad(response);
etagStep3 = response.getOptions().getETags().get(0);
success &= hasEtag(response);
success &= checkOption(etagStep3, response.getOptions()
.getETags().get(0), "ETag");
success &= hasEtag(response);
success &= checkDifferentOption(etagStep3, response
.getOptions().getETags().get(0), "ETag");
代码示例来源:origin: eclipse/californium
etag1 = response.getOptions().getETags().get(0);
etag2 = response.getOptions().getETags().get(0);
内容来源于网络,如有侵权,请联系作者删除!