Merge branch 'cloud-interface'
[platform/upstream/iotivity.git] / service / notification / android / notification-service / src / main / java / org / iotivity / service / ns / common / NSErrorCode.java
1 //******************************************************************
2 //
3 // Copyright 2016 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.ns.common;
22
23 public enum NSErrorCode
24 {
25     OK("OK", ""),
26     ERROR("ERROR", ""),
27     SUCCESS("SUCCESS", ""),
28     FAIL("FAIL", ""),
29     ALLOW("ALLOW", ""),
30     DENY("DENY", ""),
31     JNI_EXCEPTION("JNI_EXCEPTION", "Generic Java binder error"),
32     JNI_NO_NATIVE_OBJECT("JNI_NO_NATIVE_OBJECT", ""),
33     JNI_INVALID_VALUE("JNI_INVALID_VALUE", ""),;
34
35     private String error;
36     private String description;
37
38     private NSErrorCode(String error, String description)
39 {
40     this.error = error;
41     this.description = description;
42 }
43
44 public String getError()
45 {
46     return error;
47 }
48
49 public String getDescription()
50 {
51     return description;
52 }
53
54 public static NSErrorCode get(String errorCode)
55 {
56     for (NSErrorCode eCode : NSErrorCode.values())
57     {
58         if (eCode.getError().equals(errorCode))
59         {
60             return eCode;
61         }
62     }
63     throw new IllegalArgumentException("Unexpected NSErrorCode value");
64 }
65
66 @Override
67 public String toString()
68 {
69     return error + (description.isEmpty() ? "" : " : " + description);
70 }
71 }