Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / resource-encapsulation / android / service / src / main / java / org / iotivity / service / server / RcsGetResponse.java
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 package org.iotivity.service.server;
22
23 import org.iotivity.service.RcsResourceAttributes;
24
25 /**
26  * This class provides methods to create the response for a get request.
27  *
28  * @see RcsResourceObject
29  * @see RcsSetResponse
30  */
31 public class RcsGetResponse extends RcsResponse {
32
33     /**
34      * Creates a default RCcsGetResponse. The response will have
35      * {@link #DEFAULT_ERROR_CODE} for the errorCode. The attributes of
36      * {@link RcsResourceObject} will be set as the result attributes.
37      *
38      */
39     public static RcsGetResponse defaultAction() {
40         return new RcsGetResponse();
41     }
42
43     /**
44      * Creates a RcsGetResponse with error code passed. The
45      * attributes of the {@link RcsResourceObject} will be set as the result
46      * attributes.
47      *
48      * @param errorCode
49      *            error code to be set in response
50      *
51      */
52     public static RcsGetResponse create(int errorCode) {
53         return new RcsGetResponse(errorCode);
54
55     }
56
57     /**
58      * Creates a RcsGetResponse with custom attributes and
59      * {@link #DEFAULT_ERROR_CODE} for the errorCode. This sends the passed
60      * attributes as the result attributes instead of the one the
61      * {@link RcsResourceObject} holds.
62      *
63      * @param attributes
64      *            attributes to be sent as the result
65      *
66      */
67     public static RcsGetResponse create(RcsResourceAttributes attributes) {
68         return new RcsGetResponse(attributes);
69     }
70
71     /**
72      * Creates a RcsGetResponse with error code passed. This sends
73      * the passed attributes as the result attributes instead of one the
74      * {@link RcsResourceObject} holds.
75      *
76      * @param attributes
77      *            attributes to be sent as the result
78      * @param errorCode
79      *            error code for response
80      *
81      */
82     public static RcsGetResponse create(RcsResourceAttributes attributes,
83             int errorCode) {
84         return new RcsGetResponse(attributes, errorCode);
85     }
86
87     private RcsGetResponse() {
88         super();
89     }
90
91     private RcsGetResponse(int errorCode) {
92         super(errorCode);
93     }
94
95     private RcsGetResponse(RcsResourceAttributes attrs) {
96         super(attrs);
97     }
98
99     private RcsGetResponse(RcsResourceAttributes attrs, int errorCode) {
100         super(attrs, errorCode);
101     }
102 }