util/qos/AccessFilterQos.cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      AccessFilterQos.cpp
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 Comment:   Holding filter address string and protocol string
00006 ------------------------------------------------------------------------------*/
00007 
00025 #include <util/qos/AccessFilterQos.h>
00026 #include <util/Global.h>
00027 
00028 using namespace std;
00029 using namespace org::xmlBlaster::util;
00030 using namespace org::xmlBlaster::util::qos;
00031 
00032 namespace org { namespace xmlBlaster { namespace util { namespace qos {
00033 
00034 
00035 Dll_Export const char* ACCESSFILTER_DEFAULT_version = "1.0";
00036 Dll_Export const char* ACCESSFILTER_DEFAULT_type    = "";
00037   
00038    void AccessFilterQos::copy(const AccessFilterQos& qos) 
00039    {
00040       type_    = qos.type_;
00041       version_ = qos.version_;
00042    }
00043 
00046    AccessFilterQos::AccessFilterQos(Global& global) 
00047       : ME("AccessFilterQos"), global_(global), log_(global.getLog("org.xmlBlaster.util.qos")), query_(global)
00048    {
00049       type_ = "";
00050       setVersion(global_.getProperty().getStringProperty("accessFilter.version", ACCESSFILTER_DEFAULT_version));
00051       setType(global_.getProperty().getStringProperty("accessFilter.type", ACCESSFILTER_DEFAULT_type));
00052     }
00053 
00060    AccessFilterQos::AccessFilterQos(Global& global, const string& type, const string& version, const string& query)
00061       : ME("AccessFilterQos"), global_(global), log_(global.getLog("org.xmlBlaster.util.qos")), query_(global, query)
00062    {
00063       setType(type);
00064       setVersion(version);
00065    }
00066 
00073    AccessFilterQos::AccessFilterQos(Global& global, const string& type, const string& version, const Query& query)
00074       : ME("AccessFilterQos"), global_(global), log_(global.getLog("org.xmlBlaster.util.qos")), query_(query)
00075    {
00076       setType(type);
00077       setVersion(version);
00078    }
00079 
00080    AccessFilterQos::AccessFilterQos(const AccessFilterQos& qos)
00081       : ME(qos.ME), global_(qos.global_), log_(qos.log_), query_(qos.query_)
00082    {
00083       copy(qos);
00084    }
00085 
00086    AccessFilterQos& AccessFilterQos::operator =(const AccessFilterQos& qos)
00087    {
00088       copy(qos);
00089       return *this;
00090    }
00091 
00095    void AccessFilterQos::setType(const string& type)
00096    {
00097       type_ = type;
00098    }
00099 
00104    string AccessFilterQos::getType() const
00105    {
00106       return type_;
00107    }
00108 
00112    void AccessFilterQos::setVersion(const string& version)
00113    {
00114       version_ = version;
00115    }
00116 
00121    string AccessFilterQos::getVersion() const
00122    {
00123       return version_;
00124    }
00125 
00131    void AccessFilterQos::setQuery(const Query& query)
00132    {
00133       query_ = query;
00134    }
00135 
00140    Query AccessFilterQos::getQuery() const
00141    {
00142       return query_;
00143    }
00144 
00145 
00153    string AccessFilterQos::toXml(const string& extraOffset) const
00154    {
00155       string ret;   
00156       string offset = "\n " + extraOffset;
00157 
00158       ret += offset + "<filter type='" + getType() + "'";
00159       if (ACCESSFILTER_DEFAULT_version != getVersion())
00160           ret += " version='" + getVersion() + "'";
00161       ret += ">";
00162       string help = getQuery().toString();
00163       if (help.find("<![CDATA[") != help.npos)
00164          ret += offset + " " + help;
00165       else
00166          ret += offset + " <![CDATA[" + help + "]]>";
00167       ret += offset + "</filter>";
00168 
00169       return ret;
00170    }
00171 
00172 }}}}
00173