1 /*------------------------------------------------------------------------------
2 Name: MsgKeyData.cpp
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6
7 #include <util/key/MsgKeyData.h>
8 #include <util/Constants.h>
9 #include <util/Global.h>
10
11 using namespace std;
12 using namespace org::xmlBlaster::util;
13
14 namespace org { namespace xmlBlaster { namespace util { namespace key {
15
16 MsgKeyData::MsgKeyData(Global& global) : KeyData(global)
17 {
18 clientTags_ = "";
19 }
20
21 MsgKeyData::MsgKeyData(const MsgKeyData& key) : KeyData(key)
22 {
23 clientTags_ = key.clientTags_;
24 }
25
26 MsgKeyData& MsgKeyData::operator =(const MsgKeyData& key)
27 {
28 clientTags_ = key.clientTags_;
29 return *this;
30 }
31
32 string MsgKeyData::getOid() const
33 {
34 if (oid_.empty()) {
35 generateOid(global_.getStrippedId());
36 }
37 return oid_;
38 }
39
40 void MsgKeyData::setClientTags(const string& tags)
41 {
42 clientTags_ = tags;
43 }
44
45 string MsgKeyData::getClientTags() const
46 {
47 return clientTags_;
48 }
49
50 string MsgKeyData::toXml() const
51 {
52 return toXml("");
53 }
54
55 string MsgKeyData::toXml(const string& extraOffset) const
56 {
57 string ret;
58 string offset = Constants::OFFSET + extraOffset;
59
60 ret += offset + "<key oid='" + oid_ + "'";
61 if (!contentMime_.empty())
62 ret += " contentMime='" + getContentMime() + "'";
63 if (!contentMimeExtended_.empty())
64 ret += " contentMimeExtended='" + getContentMimeExtended() + "'";
65 if (!getDomain().empty())
66 ret += " domain='" + getDomain() + "'";
67 if (!getClientTags().empty()) {
68 ret += ">";
69 ret += offset + extraOffset + Constants::INDENT + getClientTags();
70 ret += offset + "</key>";
71 }
72 else
73 ret += "/>";
74 return ret;
75 }
76
77 MsgKeyData* MsgKeyData::getClone() const
78 {
79 return new MsgKeyData(*this);
80 }
81
82 }}}} // namespace
syntax highlighted by Code2HTML, v. 0.9.1