241eb11dcfe15750f73dd885e405c7247ea5441c
[platform/upstream/iotivity.git] / service / things-manager / sdk / java / src / org / iotivity / service / tm / OCStackResult.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  * @file    OCStackResult.java
22  *
23  * @brief     This file provides a Enum which contains Status codes for Success and Errors
24  *
25  */
26
27 package org.iotivity.service.tm;
28
29 /**
30  * This Enum contains Status codes for Success and Errors
31  */
32 public enum OCStackResult {
33     OC_STACK_OK,
34     OC_STACK_RESOURCE_CREATED,
35     OC_STACK_RESOURCE_DELETED,
36     OC_STACK_CONTINUE,
37     OC_STACK_INVALID_URI,
38     OC_STACK_INVALID_QUERY,
39     OC_STACK_INVALID_IP,
40     OC_STACK_INVALID_PORT,
41     OC_STACK_INVALID_CALLBACK,
42     OC_STACK_INVALID_METHOD,
43     OC_STACK_INVALID_PARAM,
44     OC_STACK_INVALID_OBSERVE_PARAM,
45     OC_STACK_NO_MEMORY,
46     OC_STACK_COMM_ERROR,
47     OC_STACK_NOTIMPL,
48     OC_STACK_NO_RESOURCE,
49     OC_STACK_RESOURCE_ERROR,
50     OC_STACK_SLOW_RESOURCE,
51     OC_STACK_REPEATED_REQUEST,
52     OC_STACK_NO_OBSERVERS,
53     OC_STACK_OBSERVER_NOT_FOUND,
54     OC_STACK_VIRTUAL_DO_NOT_HANDLE,
55     OC_STACK_INVALID_OPTION,
56     OC_STACK_MALFORMED_RESPONSE,
57     OC_STACK_PERSISTENT_BUFFER_REQUIRED,
58     OC_STACK_INVALID_REQUEST_HANDLE,
59     OC_STACK_INVALID_DEVICE_INFO,
60     OC_STACK_INVALID_JSON,
61     OC_STACK_PRESENCE_STOPPED,
62     OC_STACK_PRESENCE_TIMEOUT,
63     OC_STACK_PRESENCE_DO_NOT_HANDLE,
64     OC_STACK_ERROR,
65     OC_STACK_LISTENER_NOT_SET;
66
67     public static OCStackResult conversion(int ordinal) {
68
69         OCStackResult result = OCStackResult.values()[31];
70
71         if (ordinal == 0)
72             result = OCStackResult.values()[0];
73         else if (ordinal == 1)
74             result = OCStackResult.values()[1];
75         else if (ordinal == 2)
76             result = OCStackResult.values()[2];
77         else if (ordinal == 3)
78             result = OCStackResult.values()[3];
79
80         else if (ordinal == 20)
81             result = OCStackResult.values()[4];
82         else if (ordinal == 21)
83             result = OCStackResult.values()[5];
84         else if (ordinal == 22)
85             result = OCStackResult.values()[6];
86         else if (ordinal == 23)
87             result = OCStackResult.values()[7];
88         else if (ordinal == 24)
89             result = OCStackResult.values()[8];
90         else if (ordinal == 25)
91             result = OCStackResult.values()[9];
92         else if (ordinal == 26)
93             result = OCStackResult.values()[10];
94         else if (ordinal == 27)
95             result = OCStackResult.values()[11];
96         else if (ordinal == 28)
97             result = OCStackResult.values()[12];
98         else if (ordinal == 29)
99             result = OCStackResult.values()[13];
100         else if (ordinal == 30)
101             result = OCStackResult.values()[14];
102         else if (ordinal == 31)
103             result = OCStackResult.values()[15];
104         else if (ordinal == 32)
105             result = OCStackResult.values()[16];
106         else if (ordinal == 33)
107             result = OCStackResult.values()[17];
108         else if (ordinal == 34)
109             result = OCStackResult.values()[18];
110         else if (ordinal == 35)
111             result = OCStackResult.values()[19];
112         else if (ordinal == 36)
113             result = OCStackResult.values()[20];
114         else if (ordinal == 37)
115             result = OCStackResult.values()[21];
116         else if (ordinal == 38)
117             result = OCStackResult.values()[22];
118         else if (ordinal == 39)
119             result = OCStackResult.values()[23];
120         else if (ordinal == 40)
121             result = OCStackResult.values()[24];
122         else if (ordinal == 41)
123             result = OCStackResult.values()[25];
124         else if (ordinal == 42)
125             result = OCStackResult.values()[26];
126         else if (ordinal == 43)
127             result = OCStackResult.values()[27];
128
129         else if (ordinal == 128)
130             result = OCStackResult.values()[28];
131         else if (ordinal == 129)
132             result = OCStackResult.values()[29];
133         else if (ordinal == 130)
134             result = OCStackResult.values()[30];
135
136         return result;
137     }
138 }