[N_SE-32914, 33582] Fixed priority converting codes
[framework/osp/social.git] / src / FScl_UrlImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FScl_UrlImpl.cpp
19  * @brief               This is the implementation for _UrlImpl class.
20  *
21  * This file contains definitions of @e _UrlImpl class.
22  */
23
24 #include <FBaseSysLog.h>
25 #include <FSclUrl.h>
26 #include <FApp_AppInfo.h>
27 #include "FScl_UrlImpl.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Social
33 {
34
35 _UrlImpl::_UrlImpl(void)
36         : __type(URL_TYPE_PERSONAL)
37 {
38         //empty body
39 }
40
41 _UrlImpl::_UrlImpl(UrlType type, const String& url)
42         : __type(type)
43         , __url(url)
44 {
45
46 }
47
48 _UrlImpl::_UrlImpl(const _UrlImpl& rhs)
49 {
50         __type = rhs.__type;
51         __label = rhs.__label;
52         __url = rhs.__url;
53 }
54
55 _UrlImpl::~_UrlImpl(void)
56 {
57         // empty body.
58 }
59
60 _UrlImpl&
61 _UrlImpl::operator =(const _UrlImpl& rhs)
62 {
63         if (this == &rhs)
64         {
65                 return *this;
66         }
67
68         __type = rhs.__type;
69         __label = rhs.__label;
70         __url = rhs.__url;
71
72         return *this;
73 }
74
75 bool
76 _UrlImpl::operator ==(const _UrlImpl& rhs) const
77 {
78         if (__type == rhs.__type && __label == rhs.__label && __url == rhs.__url)
79         {
80                 return true;
81         }
82
83         return false;
84 }
85
86 bool
87 _UrlImpl::operator !=(const _UrlImpl& rhs) const
88 {
89         return !(*this == rhs);
90 }
91
92 bool
93 _UrlImpl::Equals(const Object& rhs) const
94 {
95         const _UrlImpl* pUrl = dynamic_cast<const _UrlImpl*>(&rhs);
96
97         if (pUrl == null)
98         {
99                 return false;
100         }
101
102         return (*this == *pUrl);
103 }
104
105 int
106 _UrlImpl::GetHashCode(void) const
107 {
108         int hashCode = 0;
109
110         hashCode = __type;
111         hashCode += __label.GetHashCode();
112         hashCode += __url.GetHashCode();
113
114         return hashCode;
115 }
116
117 UrlType
118 _UrlImpl::GetType(void) const
119 {
120         return __type;
121 }
122
123 String
124 _UrlImpl::GetUrl(void) const
125 {
126         return __url;
127 }
128
129 void
130 _UrlImpl::SetType(UrlType type)
131 {
132         __type = type;
133 }
134
135 result
136 _UrlImpl::SetUrl(const String& url)
137 {
138         SysTryReturn(NID_SCL,  !url.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The url is empty", GetErrorMessage(E_INVALID_ARG));
139
140         __url = url;
141
142         return E_SUCCESS;
143 }
144
145 String
146 _UrlImpl::GetLabel(void) const
147 {
148         return __label;
149 }
150
151 void
152 _UrlImpl::SetLabel(const String& label)
153 {
154         __label = label;
155 }
156
157 const _UrlImpl*
158 _UrlImpl::GetInstance(const Url& url)
159 {
160         return url.__pUrlImpl;
161 }
162
163 _UrlImpl*
164 _UrlImpl::GetInstance(Url& url)
165 {
166         return url.__pUrlImpl;
167 }
168
169
170 }} // Tizen::Social