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

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

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

OptionSet.getLocationPath介绍

[英]Returns the list of Location-Path segment strings. The OptionSet uses lazy initialization for this list.
[中]返回位置路径段字符串的列表。OptionSet对该列表使用延迟初始化。

代码示例

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

/**
 * Returns the number of Location-Path options (i.e., path segments).
 * @return the count
 */
public int getLocationPathCount() {
  return getLocationPath().size();
}

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

/**
 * Removes all Location-Path options.
 * Returns the current OptionSet object for a fluent API.
 * @return this OptionSet
 */
public OptionSet clearLocationPath() {
  getLocationPath().clear();
  return this;
}

代码示例来源:origin: org.eclipse.californium/californium-core

/**
 * Removes all Location-Path options.
 * Returns the current OptionSet object for a fluent API.
 * @return this OptionSet
 */
public OptionSet clearLocationPath() {
  getLocationPath().clear();
  return this;
}

代码示例来源:origin: org.eclipse.californium/californium-core

/**
 * Returns the number of Location-Path options (i.e., path segments).
 * @return the count
 */
public int getLocationPathCount() {
  return getLocationPath().size();
}

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

/**
 * Returns the Location-Path options as relative URI string.
 * @return the Location-Path as string
 */
public String getLocationPathString() {
  StringBuilder builder = new StringBuilder();
  for (String segment:getLocationPath())
    builder.append(segment).append("/");
  if (builder.length() > 0)
    builder.delete(builder.length() - 1, builder.length());
  return builder.toString();
}

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

/**
 * Adds a path segment to the Location-Path options.
 * Returns the current OptionSet object for a fluent API.
 * @param segment the path segment to add
 * @return this OptionSet
 */
public OptionSet addLocationPath(String segment) {
  if (segment == null)
    throw new IllegalArgumentException("Location-Path option must not be null");
  if (segment.getBytes(CoAP.UTF8_CHARSET).length > 255)
    throw new IllegalArgumentException("Location-Path option must be smaller or euqal to 255 bytes (UTF-8 encoded): " + segment);
  getLocationPath().add(segment);
  return this;
}

代码示例来源:origin: org.eclipse.californium/californium-core

/**
 * Adds a path segment to the Location-Path options.
 * Returns the current OptionSet object for a fluent API.
 * @param segment the path segment to add
 * @return this OptionSet
 */
public OptionSet addLocationPath(String segment) {
  if (segment == null)
    throw new IllegalArgumentException("Location-Path option must not be null");
  if (segment.getBytes(CoAP.UTF8_CHARSET).length > 255)
    throw new IllegalArgumentException("Location-Path option must be smaller or euqal to 255 bytes (UTF-8 encoded): " + segment);
  getLocationPath().add(segment);
  return this;
}

代码示例来源:origin: org.eclipse.californium/californium-core

/**
 * Returns the Location-Path options as relative URI string.
 * @return the Location-Path as string
 */
public String getLocationPathString() {
  StringBuilder builder = new StringBuilder();
  for (String segment:getLocationPath())
    builder.append(segment).append("/");
  if (builder.length() > 0)
    builder.delete(builder.length() - 1, builder.length());
  return builder.toString();
}

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

protected boolean checkResponse(Request request, Response response) {
    boolean success = true;

    success &= checkType(Type.ACK, response.getType());
    success &= checkInt(EXPECTED_RESPONSE_CODE.value,
        response.getCode().value, "code");
    success &= hasLocation(response);

    if (success) {

      List<String> path = response.getOptions().getLocationPath();
      List<String> expc = Arrays.asList("location1", "location2",
          "location3");
      success &= checkOption(expc, path, "Location path");
    }
    return success;
  }
}

相关文章

微信公众号

最新文章

更多