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

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

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

OptionSet.getLocationQueryString介绍

[英]Returns the Location-Query options as &-separated list string.
[中]以&-分隔的列表字符串形式返回位置查询选项。

代码示例

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

/**
 * Returns the Location-Path and Location-Query options as relative URI string.
 * @return the Location-* as string
 */
public String getLocationString() {
  StringBuilder builder = new StringBuilder();
  builder.append("/");
  builder.append(getLocationPathString());
  if (getLocationQueryCount()>0) {
    builder.append("?");
    builder.append(getLocationQueryString());
  }
  return builder.toString();
}

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

/**
 * Returns the Location-Path and Location-Query options as relative URI string.
 * @return the Location-* as string
 */
public String getLocationString() {
  StringBuilder builder = new StringBuilder();
  builder.append("/");
  builder.append(getLocationPathString());
  if (getLocationQueryCount()>0) {
    builder.append("?");
    builder.append(getLocationQueryString());
  }
  return builder.toString();
}

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

/**
 * Checks for Location-Query option.
 * 
 * @param response
 *            the response
 * @return true, if successful
 */
protected boolean hasLocationQuery(Response response) {
  // boolean success =
  // response.hasOption(OptionNumberRegistry.LOCATION_QUERY);
  boolean success = response.getOptions().getLocationQueryCount() > 0;
  if (!success) {
    System.out.println("FAIL: Response without Location-Query");
  } else {
    System.out.printf("PASS: Location-Query (%s)\n", response
        .getOptions().getLocationQueryString());
  }
  return success;
}

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

@Test public void testUTF8Encoding() {
    Response response = new Response(ResponseCode.CONTENT);
    response.setType(Type.NON);
    response.setMID(expectedMid);
    response.setToken(new byte[] {});
    response.getOptions().addLocationPath("ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ").addLocationPath("γλώσσα")
        .addLocationPath("пустынных").addLocationQuery("ვეპხის=யாமறிந்த").addLocationQuery("⠊⠀⠉⠁⠝=⠑⠁⠞⠀⠛⠇⠁⠎⠎");
    response.setPayload("⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑");

    RawData rawData = serializer.serializeResponse(response);

    Response result = (Response) parser.parseMessage(rawData);
    assertEquals("ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ/γλώσσα/пустынных", response.getOptions().getLocationPathString());
    assertEquals("ვეპხის=யாமறிந்த&⠊⠀⠉⠁⠝=⠑⠁⠞⠀⠛⠇⠁⠎⠎", response.getOptions().getLocationQueryString());
    assertEquals("⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑", result.getPayloadString());
    assertEquals(response.getMID(), result.getMID());
  }
}

相关文章

微信公众号

最新文章

更多