View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.mina.coap.resource;
21  
22  import java.util.Arrays;
23  
24  import org.apache.mina.coap.CoapCode;
25  import org.apache.mina.coap.CoapOption;
26  
27  /**
28   * Response to a coap request.
29   * 
30   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
31   */
32  public class CoapResponse {
33  
34      private int code;
35      private byte[] content;
36  
37      private CoapOption[] options;
38  
39      /**
40       * Create the CoAP response for a resource request.
41       * 
42       * @param code the return code for this request see : {@link CoapCode}
43       * @param content the content for this resource request
44       * @param options the opetion to send (content-type, cacheability etc..)
45       */
46      public CoapResponse(int code, byte[] content, CoapOption... options) {
47          super();
48          this.code = code;
49          this.content = content;
50          this.options = options;
51      }
52  
53      public int getCode() {
54          return code;
55      }
56  
57      public void setCode(int code) {
58          this.code = code;
59      }
60  
61      public byte[] getContent() {
62          return content;
63      }
64  
65      public void setContent(byte[] content) {
66          this.content = content;
67      }
68  
69      public CoapOption[] getOptions() {
70          return options;
71      }
72  
73      public void setOptions(CoapOption[] options) {
74          this.options = options;
75      }
76  
77      @Override
78      public String toString() {
79          return "CoapResponse [code=" + code + ", content=" + Arrays.toString(content) + ", options="
80                  + Arrays.toString(options) + "]";
81      }
82  }