本文整理了Java中org.eclipse.californium.core.coap.OptionSet.getUriPort()
方法的一些代码示例,展示了OptionSet.getUriPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OptionSet.getUriPort()
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.OptionSet
类名称:OptionSet
方法名:getUriPort
[英]Returns the uint value of the Uri-Port option.
[中]返回Uri端口选项的uint值。
代码示例来源:origin: eclipse/californium
options.add(new Option(OptionNumberRegistry.IF_NONE_MATCH));
if (hasUriPort())
options.add(new Option(OptionNumberRegistry.URI_PORT, getUriPort()));
if (location_path_list != null) for (String str:location_path_list)
options.add(new Option(OptionNumberRegistry.LOCATION_PATH, str));
代码示例来源:origin: org.eclipse.californium/californium-core
options.add(new Option(OptionNumberRegistry.IF_NONE_MATCH));
if (hasUriPort())
options.add(new Option(OptionNumberRegistry.URI_PORT, getUriPort()));
if (location_path_list != null) for (String str:location_path_list)
options.add(new Option(OptionNumberRegistry.LOCATION_PATH, str));
代码示例来源:origin: eclipse/californium
Integer port = getOptions().getUriPort();
if (port == null) {
port = getDestinationPort();
代码示例来源:origin: org.eclipse.californium/californium-core
Integer port = getOptions().getUriPort();
if (port == null) {
port = getDestinationPort();
代码示例来源:origin: eclipse/californium
/**
* Verifies that the URI examples from <a href="https://tools.ietf.org/html/rfc7252#section-6.3">
* RFC 7252, Section 6.3</a> result in the same option values.
* @throws URISyntaxException
*/
@Test
public void testSetOptionsCompliesWithRfcExample() throws URISyntaxException {
String[] exampleUris = new String[]{
"coap://example.com:5683/~sensors/temp.xml",
"coap://EXAMPLE.com/%7Esensors/temp.xml",
"coap://EXAMPLE.com:/%7esensors/temp.xml"
};
for (String uriString : exampleUris) {
URI uri = new URI(uriString);
Request req = Request.newGet();
// explicitly set destination address so that we do not rely on working DNS
req.setDestination(InetAddress.getLoopbackAddress());
req.setOptions(uri);
assertThat(req.getOptions().getUriHost(), is("example.com"));
assertThat(req.getDestinationPort(), is(5683));
assertThat(req.getOptions().getUriPort(), is(nullValue()));
assertThat(req.getOptions().getUriPathString(), is("~sensors/temp.xml"));
}
}
内容来源于网络,如有侵权,请联系作者删除!