1 /*------------------------------------------------------------------------------
  2 Name:      UnSubscribeReturnQos.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.XmlBlasterException;
 12 import org.xmlBlaster.util.qos.StatusQosData;
 13 import org.xmlBlaster.util.def.MethodName;
 14 
 15 /**
 16  * Handling the returned QoS (quality of service) of a unSubscribe() call. 
 17  * <p />
 18  * If you are a Java client and use the I_XmlBlasterAccess interface
 19  * you get this object as the unSubscribe() return value.
 20  * <p />
 21  * Example:
 22  * <pre>
 23  *   &lt;qos>
 24  *     &lt;state id='OK' info='QUEUED[bilbo]'/>
 25  *     &lt;subscribe id='_subId:1/>
 26  *  &lt;/qos>
 27  * </pre>
 28  * @see org.xmlBlaster.test.classtest.qos.StatusQosFactoryTest
 29  * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.unSubscribe.html" target="others">the interface.unSubscribe requirement</a>
 30  */
 31 public final class UnSubscribeReturnQos
 32 {
 33    private final StatusQosData statusQosData;
 34 
 35    /**
 36     * Constructor which parses XML string. 
 37     */
 38    public UnSubscribeReturnQos(Global glob, String xmlQos) throws XmlBlasterException {
 39       this.statusQosData = glob.getStatusQosFactory().readObject(xmlQos);
 40       this.statusQosData.setMethod(MethodName.UNSUBSCRIBE);
 41    }
 42 
 43    /**
 44     * Constructor which reuses a StatusQosData object.
 45     */
 46    public UnSubscribeReturnQos(Global glob, StatusQosData statusQosData) {
 47       this.statusQosData = statusQosData;
 48       this.statusQosData.setMethod(MethodName.UNSUBSCRIBE);
 49    }
 50 
 51    /**
 52     * Access the raw data object. 
 53     */
 54    public StatusQosData getData() {
 55       return this.statusQosData;
 56    }
 57 
 58    /**
 59     * Access the state of message. 
 60     * @return OK (Other values are not yet supported)
 61     */
 62    public String getState() {
 63       return this.statusQosData.getState();
 64    }
 65 
 66    /**
 67     * Additional structured information about a state. 
 68     * @return "QUEUED" or "QUEUED[bilbo]"
 69     * @see org.xmlBlaster.util.def.Constants
 70     */
 71    public String getStateInfo() {
 72       return this.statusQosData.getStateInfo();
 73    }
 74 
 75    /**
 76     * Get the subscription-identifier (unique handle) which was unsubscribed. 
 77     */
 78    public String getSubscriptionId() {
 79       return this.statusQosData.getSubscriptionId();
 80    }
 81 
 82    /**
 83     * @see #toXml(String)
 84     */
 85    public String toXml() {
 86       return toXml((String)null);
 87    }
 88 
 89    /**
 90     * Dump state of this object into a XML ASCII string.
 91     * @param extraOffset indenting of tags for nice output
 92     * @return The XML representation
 93     */
 94    public String toXml(String extraOffset) {
 95       return this.statusQosData.toXml(extraOffset, (Properties)null);
 96    }
 97 
 98    public String toString() {
 99       return toXml(null);
100    }
101 }


syntax highlighted by Code2HTML, v. 0.9.1