Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / OcHeaderOption.java
1 /*\r
2  * //******************************************************************\r
3  * //\r
4  * // Copyright 2015 Intel Corporation.\r
5  * //\r
6  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
7  * //\r
8  * // Licensed under the Apache License, Version 2.0 (the "License");\r
9  * // you may not use this file except in compliance with the License.\r
10  * // You may obtain a copy of the License at\r
11  * //\r
12  * //      http://www.apache.org/licenses/LICENSE-2.0\r
13  * //\r
14  * // Unless required by applicable law or agreed to in writing, software\r
15  * // distributed under the License is distributed on an "AS IS" BASIS,\r
16  * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * // See the License for the specific language governing permissions and\r
18  * // limitations under the License.\r
19  * //\r
20  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
21  */\r
22 \r
23 package org.iotivity.base;\r
24 \r
25 import java.security.InvalidParameterException;\r
26 \r
27 /**\r
28  * OcHeaderOption class allows to create instances which comprises optionId\r
29  * and optionData as members. These are used in setting Header options.\r
30  * After creating instances of OcHeaderOptions, use setHeaderOptions API\r
31  * (in OcResource) to set header Options.\r
32  * NOTE: optionId  is an integer value which MUST be within\r
33  * range of 2048 to 3000 inclusive of lower and upper bound.\r
34  * HeaderOption instance creation fails if above condition is not satisfied.\r
35  */\r
36 public class OcHeaderOption {\r
37 \r
38     public static final int MIN_HEADER_OPTION_ID = 2048;\r
39     public static final int MAX_HEADER_OPTION_ID = 3000;\r
40 \r
41     private int mOptionId;\r
42     private String mOptionData;\r
43 \r
44     public OcHeaderOption(int optionId, String optionData) {\r
45         if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)) {\r
46             throw new InvalidParameterException("Option ID range is invalid");\r
47         }\r
48 \r
49         this.mOptionId = optionId;\r
50         this.mOptionData = optionData;\r
51     }\r
52 \r
53     /**\r
54      * API to get Option ID\r
55      *\r
56      * @return option ID\r
57      */\r
58     public int getOptionId() {\r
59         return mOptionId;\r
60     }\r
61 \r
62     /**\r
63      * API to get Option data\r
64      *\r
65      * @return option data\r
66      */\r
67     public String getOptionData() {\r
68         return mOptionData;\r
69     }\r
70 }\r