util/key/MsgKeyData.cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      MsgKeyData.cpp
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 ------------------------------------------------------------------------------*/
00006 
00007 #include <util/key/MsgKeyData.h>
00008 #include <util/Constants.h>
00009 #include <util/Global.h>
00010 
00011 using namespace std;
00012 using namespace org::xmlBlaster::util;
00013 
00014 namespace org { namespace xmlBlaster { namespace util { namespace key {
00015 
00016 MsgKeyData::MsgKeyData(Global& global) : KeyData(global)
00017 {
00018    clientTags_ = "";
00019 }
00020 
00021 MsgKeyData::MsgKeyData(const MsgKeyData& key) : KeyData(key)
00022 {
00023    clientTags_ = key.clientTags_;
00024 }
00025 
00026 MsgKeyData& MsgKeyData::operator =(const MsgKeyData& key) 
00027 {
00028    clientTags_ = key.clientTags_;
00029    return *this;
00030 }
00031 
00032 string MsgKeyData::getOid() const
00033 {
00034    if (">oid_.empty()) {
00035       generateOid(global_.getStrippedId());
00036    }
00037    return ">oid_;
00038 }
00039 
00040 void MsgKeyData::setClientTags(const string& tags)
00041 {
00042    clientTags_ = tags;
00043 }
00044 
00045 string MsgKeyData::getClientTags() const
00046 {
00047    return clientTags_;
00048 }
00049 
00050 string MsgKeyData::toXml() const
00051 {
00052    return toXml("");
00053 }
00054 
00055 string MsgKeyData::toXml(const string& extraOffset) const
00056 {
00057    string ret;
00058    string offset = Constants::OFFSET + extraOffset;
00059 
00060    ret += offset + "<key oid='" + ">oid_ + "'";
00061    if (!">contentMime_.empty())
00062       ret += " contentMime='" + getContentMime() + "'";
00063    if (!">contentMimeExtended_.empty())
00064       ret += " contentMimeExtended='" + getContentMimeExtended() + "'";
00065    if (!getDomain().empty())
00066       ret += " domain='" + getDomain() + "'";
00067    if (!getClientTags().empty()) {
00068       ret += ">";
00069       ret += offset + extraOffset + Constants::INDENT + getClientTags();
00070       ret += offset + "</key>";
00071    }
00072    else
00073       ret += "/>";
00074   return ret;
00075 }
00076 
00077 MsgKeyData* MsgKeyData::getClone() const
00078 {
00079    return new MsgKeyData(*this);
00080 }
00081 
00082 }}}} // namespace
00083