Merge branch 'master' into cloud-interface
[platform/upstream/iotivity.git] / cloud / stack / src / main / java / org / iotivity / cloud / base / protocols / coap / CoapOption.java
1 /*
2  * //******************************************************************
3  * //
4  * // Copyright 2016 Samsung Electronics All Rights Reserved.
5  * //
6  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7  * //
8  * // Licensed under the Apache License, Version 2.0 (the "License");
9  * // you may not use this file except in compliance with the License.
10  * // You may obtain a copy of the License at
11  * //
12  * //      http://www.apache.org/licenses/LICENSE-2.0
13  * //
14  * // Unless required by applicable law or agreed to in writing, software
15  * // distributed under the License is distributed on an "AS IS" BASIS,
16  * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * // See the License for the specific language governing permissions and
18  * // limitations under the License.
19  * //
20  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21  */
22 package org.iotivity.cloud.base.protocols.coap;
23
24 public enum CoapOption {
25     IF_MATCH(1), URI_HOST(3), ETAG(4), IF_NONE_MATCH(5), URI_PORT(
26             7), LOCATION_PATH(8), URI_PATH(11), CONTENT_FORMAT(12), MAX_AGE(
27                     14), URI_QUERY(15), ACCEPT(17), LOCATION_QUERY(
28                             20), PROXY_URI(35), PROXY_SCHEME(39), SIZE1(
29                                     60), OBSERVE(6);
30
31     public static CoapOption valueOf(int option) {
32         switch (option) {
33             case 1:
34                 return CoapOption.IF_MATCH;
35
36             case 3:
37                 return CoapOption.URI_HOST;
38
39             case 4:
40                 return CoapOption.ETAG;
41
42             case 5:
43                 return CoapOption.IF_NONE_MATCH;
44
45             case 7:
46                 return CoapOption.URI_PORT;
47
48             case 8:
49                 return CoapOption.LOCATION_PATH;
50
51             case 11:
52                 return CoapOption.URI_PATH;
53
54             case 12:
55                 return CoapOption.CONTENT_FORMAT;
56
57             case 14:
58                 return CoapOption.MAX_AGE;
59
60             case 15:
61                 return CoapOption.URI_QUERY;
62
63             case 17:
64                 return CoapOption.ACCEPT;
65
66             case 20:
67                 return CoapOption.LOCATION_QUERY;
68
69             case 35:
70                 return CoapOption.PROXY_URI;
71
72             case 39:
73                 return CoapOption.PROXY_SCHEME;
74
75             case 60:
76                 return CoapOption.SIZE1;
77
78             case 6:
79                 return CoapOption.OBSERVE;
80         }
81
82         throw new IllegalArgumentException("Invalid option value");
83     }
84
85     private final int value;
86
87     private CoapOption(int value) {
88         this.value = value;
89     }
90
91     public int getvalue() {
92         return value;
93     }
94 }