1 /*------------------------------------------------------------------------------
2 Name: UnSubscribeKey.cpp
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6
7 #include <client/key/UnSubscribeKey.h>
8 #include <util/Global.h>
9
10 using namespace std;
11 using namespace org::xmlBlaster::util;
12 using namespace org::xmlBlaster::util::key;
13
14 namespace org { namespace xmlBlaster { namespace client { namespace key {
15
16 UnSubscribeKey::UnSubscribeKey(Global& global)
17 : ME("UnSubscribeKey"), global_(global), log_(global_.getLog("org.xmlBlaster.client")), queryKeyData_(global_)
18 {
19 }
20
21 UnSubscribeKey::UnSubscribeKey(Global& global, const string& query, const string& queryType)
22 : ME("UnSubscribeKey"), global_(global), log_(global_.getLog("org.xmlBlaster.client")),
23 queryKeyData_(global_, query, queryType)
24 {
25 }
26
27 UnSubscribeKey::UnSubscribeKey(Global& global, const QueryKeyData& data)
28 : ME("UnSubscribeKey"), global_(global), log_(global_.getLog("org.xmlBlaster.client")), queryKeyData_(data)
29 {
30 }
31
32 UnSubscribeKey::UnSubscribeKey(const UnSubscribeKey& key)
33 : ME(key.ME), global_(key.global_), log_(key.log_), queryKeyData_(key.queryKeyData_)
34 {
35 }
36
37 UnSubscribeKey& UnSubscribeKey::operator =(const UnSubscribeKey& key)
38 {
39 queryKeyData_ = key.queryKeyData_;
40 return *this;
41 }
42
43 void UnSubscribeKey::setOid(const string& oid)
44 {
45 queryKeyData_.setOid(oid);
46 }
47
48 string UnSubscribeKey::getOid() const
49 {
50 return queryKeyData_.getOid();
51 }
52
53 string UnSubscribeKey::getQueryType() const
54 {
55 return queryKeyData_.getQueryType();
56 }
57
58 void UnSubscribeKey::setQueryString(const string& tags)
59 {
60 queryKeyData_.setQueryString(tags);
61 }
62
63 string UnSubscribeKey::getQueryString() const
64 {
65 return queryKeyData_.getQueryString();
66 }
67
68 void UnSubscribeKey::setDomain(const string& domain)
69 {
70 queryKeyData_.setDomain(domain);
71 }
72
73 string UnSubscribeKey::getDomain() const
74 {
75 return queryKeyData_.getDomain();
76 }
77
78 string UnSubscribeKey::getUrl() const
79 {
80 if (string(Constants::EXACT) == getQueryType())
81 return Constants::EXACT_URL_PREFIX+getOid();
82 else if (string(Constants::XPATH) == getQueryType())
83 return Constants::XPATH_URL_PREFIX+getQueryString();
84 else if (string(Constants::D_O_M_A_I_N) == getQueryType())
85 return Constants::DOMAIN_URL_PREFIX+getDomain();
86 //else if (regex)
87 throw XmlBlasterException(USER_ILLEGALARGUMENT, ME, "getUrl() failed: Unknown query type: " + toXml(""));
88 }
89
90 string UnSubscribeKey::toXml(const string& extraOffset) const
91 {
92 return queryKeyData_.toXml(extraOffset);
93 }
94
95 string UnSubscribeKey::wrap(const string& str)
96 {
97 queryKeyData_.setQueryString(str);
98 return queryKeyData_.toXml();
99 }
100
101 const QueryKeyData& UnSubscribeKey::getData() const
102 {
103 return queryKeyData_;
104 }
105
106 }}}} // namespace
syntax highlighted by Code2HTML, v. 0.9.1