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

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(333)

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

Request.setPayload介绍

[英]Required in Request to keep class for fluent API.
[中]请求中要求保留fluent API的类。

代码示例

代码示例来源:origin: org.eclipse.leshan/leshan-client

  1. private void buildRequestContent(final LwM2mContentRequest request) {
  2. for (final Entry<String, String> entry : request.getClientParameters().entrySet()) {
  3. coapRequest.getOptions().addUriQuery(entry.getKey() + "=" + entry.getValue());
  4. }
  5. final String payload = LinkFormatUtils.payloadize(clientObjectModel);
  6. coapRequest.setPayload(payload);
  7. }

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

  1. public CC04(String serverURI) {
  2. super(CC04.class.getSimpleName());
  3. // create the request
  4. Request request = Request.newPost();
  5. // add payload
  6. request.setPayload("TD_COAP_CORE_04");
  7. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  8. // set the parameters and execute the request
  9. executeRequest(request, serverURI, RESOURCE_URI);
  10. }

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

  1. public CC19(String serverURI) {
  2. super(CC19.class.getSimpleName());
  3. // create the request
  4. Request request = new Request(Code.POST, Type.CON);
  5. // add payload
  6. request.setPayload("TD_COAP_CORE_19");
  7. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  8. // set the parameters and execute the request
  9. executeRequest(request, serverURI, RESOURCE_URI);
  10. }

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

  1. public CB04(String serverURI) {
  2. super(CB04.class.getSimpleName());
  3. Request request = Request.newPost();
  4. request.setPayload(data);
  5. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  6. // set the parameters and execute the request
  7. executeRequest(request, serverURI, "/large-create");
  8. // TODO: verify resource creation (optional): send GET request to
  9. // location path of response
  10. }

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

  1. public CC03(String serverURI) {
  2. super(CC03.class.getSimpleName());
  3. // create the request
  4. Request request = Request.newPut();
  5. // add payload
  6. request.setPayload("TD_COAP_CORE_03");
  7. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  8. // set the parameters and execute the request
  9. executeRequest(request, serverURI, RESOURCE_URI);
  10. }

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

  1. public CC07(String serverURI) {
  2. super(CC07.class.getSimpleName());
  3. // create the request
  4. Request request = new Request(Code.PUT);
  5. request.setConfirmable(false);
  6. // add payload
  7. request.setPayload("TD_COAP_CORE_07");
  8. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  9. // set the parameters and execute the request
  10. executeRequest(request, serverURI, RESOURCE_URI);
  11. }

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

  1. /**
  2. * Sends a PUT request with payload and required Content-Format and blocks
  3. * until the response is available.
  4. *
  5. * @param payload the payload
  6. * @param format the Content-Format
  7. * @return the CoAP response
  8. */
  9. public CoapResponse put(byte[] payload, int format) {
  10. return synchronous(format(newPut().setURI(uri).setPayload(payload), format));
  11. }

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

  1. /**
  2. * Sends a POST request with the specified payload and the specified content
  3. * format and invokes the specified handler when a response arrives.
  4. *
  5. * @param handler the Response handler
  6. * @param payload the payload
  7. * @param format the Content-Format
  8. */
  9. public void post(CoapHandler handler, String payload, int format) {
  10. asynchronous(format(newPost().setURI(uri).setPayload(payload), format), handler);
  11. }

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

  1. /**
  2. * Sends a PUT request with payload and required Content-Format and blocks
  3. * until the response is available.
  4. *
  5. * @param payload the payload
  6. * @param format the Content-Format
  7. * @return the CoAP response
  8. */
  9. public CoapResponse put(String payload, int format) {
  10. return synchronous(format(newPut().setURI(uri).setPayload(payload), format));
  11. }

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

  1. /**
  2. * Sends a PUT request with the specified payload and the specified content
  3. * format and invokes the specified handler when a response arrives.
  4. *
  5. * @param handler the Response handler
  6. * @param payload the payload
  7. * @param format the Content-Format
  8. */
  9. public void put(CoapHandler handler, byte[] payload, int format) {
  10. asynchronous(format(newPut().setURI(uri).setPayload(payload), format), handler);
  11. }

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

  1. /**
  2. * Sends a POST request with the specified payload and the specified content
  3. * format and invokes the specified handler when a response arrives.
  4. *
  5. * @param handler the Response handler
  6. * @param payload the payload
  7. * @param format the Content-Format
  8. */
  9. public void post(CoapHandler handler, byte[] payload, int format) {
  10. asynchronous(format(newPost().setURI(uri).setPayload(payload), format), handler);
  11. }

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

  1. public CC23(String serverURI) {
  2. super(CC23.class.getSimpleName());
  3. Request request = new Request(Code.PUT, Type.CON);
  4. // request.setIfNoneMatch();
  5. request.getOptions().setIfNoneMatch(true);
  6. request.setPayload("TD_COAP_CORE_23 Part A");
  7. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  8. executeRequest(request, serverURI, RESOURCE_URI);
  9. }

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

  1. /**
  2. * Sends a PUT request with the If-None-Match option set and blocks until
  3. * the response is available.
  4. *
  5. * @param payload the payload string
  6. * @param format the Content-Format
  7. * @return the CoAP response
  8. */
  9. public CoapResponse putIfNoneMatch(String payload, int format) {
  10. return synchronous(ifNoneMatch(format(Request.newPut().setURI(uri).setPayload(payload), format)));
  11. }

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

  1. /**
  2. * Sends a PUT request with with the specified ETags in the If-Match option
  3. * and blocks until the response is available.
  4. *
  5. * @param payload the payload string
  6. * @param format the Content-Format
  7. * @param etags the ETags for the If-Match option
  8. * @return the CoAP response
  9. */
  10. public CoapResponse putIfMatch(String payload, int format, byte[] ... etags) {
  11. return synchronous(ifMatch(format(newPut().setURI(uri).setPayload(payload), format), etags));
  12. }

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

  1. /**
  2. * Sends a PUT request with the If-None-Match option set and blocks until
  3. * the response is available.
  4. *
  5. * @param payload the payload
  6. * @param format the Content-Format
  7. * @return the CoAP response
  8. */
  9. public CoapResponse putIfNoneMatch(byte[] payload, int format) {
  10. return synchronous(ifNoneMatch(format(newPut().setURI(uri).setPayload(payload), format)));
  11. }

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

  1. /**
  2. *
  3. * @param handler the Response handler
  4. * @param payload the payload
  5. * @param format the Content-Format
  6. * @param etags the ETags for the If-Match option
  7. */
  8. public void putIfMatch(CoapHandler handler, byte[] payload, int format, byte[] ... etags) {
  9. asynchronous(ifMatch(format(newPut().setURI(uri).setPayload(payload), format), etags), handler);
  10. }

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

  1. /**
  2. *
  3. * @param handler the Response handler
  4. * @param payload the payload
  5. * @param format the Content-Format
  6. */
  7. public void putIfNoneMatch(CoapHandler handler, byte[] payload, int format) {
  8. asynchronous(ifNoneMatch(format(newPut().setURI(uri).setPayload(payload), format)), handler);
  9. }

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

  1. /**
  2. *
  3. * @param handler the Response handler
  4. * @param payload the payload
  5. * @param format the Content-Format
  6. * @param etags the ETags for the If-Match option
  7. */
  8. public void putIfMatch(CoapHandler handler, byte[] payload, int format, byte[] ... etags) {
  9. asynchronous(ifMatch(format(Request.newPut().setURI(uri).setPayload(payload), format), etags), handler);
  10. }

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

  1. @Override
  2. public void visit(WriteRequest request) {
  3. coapRequest = request.isReplaceRequest() ? Request.newPut() : Request.newPost();
  4. ContentFormat format = request.getContentFormat();
  5. coapRequest.getOptions().setContentFormat(format.getCode());
  6. coapRequest.setPayload(encoder.encode(request.getNode(), format, request.getPath(), model));
  7. setTarget(coapRequest, request.getPath());
  8. }

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

  1. @Override
  2. public void visit(CreateRequest request) {
  3. coapRequest = Request.newPost();
  4. coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  5. // if no instance id, the client will assign it.
  6. int instanceId = request.getInstanceId() != null ? request.getInstanceId() : LwM2mObjectInstance.UNDEFINED;
  7. coapRequest.setPayload(encoder.encode(new LwM2mObjectInstance(instanceId, request.getResources()),
  8. request.getContentFormat(), request.getPath(), model));
  9. setTarget(coapRequest, request.getPath());
  10. }

相关文章