1 /*------------------------------------------------------------------------------
  2 Name:      UnSubscribeQos.java
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 package org.xmlBlaster.client.qos;
  7 
  8 import java.util.Properties;
  9 
 10 import org.xmlBlaster.util.Global;
 11 import org.xmlBlaster.util.qos.QueryQosData;
 12 import org.xmlBlaster.util.qos.ClientProperty;
 13 import org.xmlBlaster.util.def.MethodName;
 14 
 15 /**
 16  * This class encapsulates the QoS of an unSubcribe() request. 
 17  * <p />
 18  * A full specified <b>unSubcribe</b> qos could look like this:<br />
 19  * <pre>
 20  *&lt;qos>
 21  *&lt;/qos>
 22  * </pre>
 23  * <p />
 24  * see xmlBlaster/src/dtd/XmlQoS.xml
 25  * @see org.xmlBlaster.util.qos.QueryQosData
 26  * @see org.xmlBlaster.util.qos.QueryQosSaxFactory
 27  * @see <a href="http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.unSubscribe.html">unSubscribe interface</a>
 28  */
 29 public final class UnSubscribeQos
 30 {
 31    private String ME = "UnSubscribeQos";
 32    private final Global glob;
 33    private final QueryQosData queryQosData;
 34 
 35    /**
 36     * Constructor for default qos (quality of service).
 37     */
 38    public UnSubscribeQos(Global glob) {
 39       this(glob, null); 
 40    }
 41 
 42    /**
 43     * Constructor for internal use. 
 44     * @param queryQosData The struct holding the data
 45     */
 46    public UnSubscribeQos(Global glob, QueryQosData queryQosData) {
 47       this.glob = (glob==null) ? Global.instance() : glob;
 48       this.queryQosData = (queryQosData==null) ? new QueryQosData(this.glob, this.glob.getQueryQosFactory(), MethodName.UNSUBSCRIBE) : queryQosData;
 49       this.queryQosData.setMethod(MethodName.UNSUBSCRIBE);
 50    }
 51 
 52    /**
 53     * Access the wrapped data holder
 54     */
 55    public QueryQosData getData() {
 56       return this.queryQosData;
 57    }
 58 
 59    /**
 60     * Mark the unSubscribe request to be persistent. 
 61     * <p>
 62     * NOTE: The request is only persistent in the client side
 63     * queue if we are polling for xmlBlaster.
 64     * </p>
 65     */
 66    public void setPersistent(boolean persistent) {
 67       this.queryQosData.setPersistent(persistent);
 68    }
 69 
 70    
 71    /**
 72     * Sets a client property (an application specific property) to the
 73     * given value
 74     * @param key
 75     * @param value
 76     */
 77    public void addClientProperty(String key, Object value) {
 78       this.queryQosData.addClientProperty(key, value);
 79    }
 80 
 81    /**
 82     * Read back a property. 
 83     * @return The client property or null if not found
 84     */
 85    public ClientProperty getClientProperty(String key) {
 86       return this.queryQosData.getClientProperty(key);
 87    }
 88 
 89    /**
 90     * Converts the data into a valid XML ASCII string.
 91     * @return An XML ASCII string
 92     */
 93    public String toString() {
 94       return this.queryQosData.toXml();
 95    }
 96 
 97    /**
 98     * Converts the data into a valid XML ASCII string.
 99     * @return An XML ASCII string
100     */
101    public String toXml() {
102       return this.queryQosData.toXml();
103    }
104 
105    public String toXml(Properties props) {
106       return this.queryQosData.toXml((String)null, props);
107    }
108 }


syntax highlighted by Code2HTML, v. 0.9.1