1 /*------------------------------------------------------------------------------
 2 Name:      UpdateReturnQos.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.def.Constants;
11 import org.xmlBlaster.util.Global;
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 an update() call. 
17  * <p />
18  * If you are a Java client you can use this class to generate the QoS
19  * which you need to return in an update()
20  * <p />
21  * Example:
22  * <pre>
23  *   &lt;qos>
24  *     &lt;state id='OK'/>
25  *  &lt;/qos>
26  * </pre>
27  * @see org.xmlBlaster.test.classtest.qos.StatusQosFactoryTest
28  * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.update.html" target="others">the interface.update requirement</a>
29  */
30 public final class UpdateReturnQos
31 {
32    private final StatusQosData statusQosData;
33 
34    /**
35     * Create an instance with Constants.STATE_OK
36     */
37    public UpdateReturnQos(Global glob) {
38       this(glob, Constants.STATE_OK);
39    }
40 
41    /**
42     * Constructor which allows you to set the return state. 
43     * @param state The state to return to the server. See Constants.java
44     */
45    public UpdateReturnQos(Global glob, String state) {
46       this.statusQosData = new StatusQosData(glob, MethodName.UPDATE);
47       this.statusQosData.setState(state);
48    }
49 
50    /**
51     * Constructor which allows you to set the return state. 
52     * @param statusQosData The pre filled raw data object
53     */
54    public UpdateReturnQos(Global glob, StatusQosData statusQosData) {
55       this.statusQosData = statusQosData;
56    }
57 
58    /**
59     * @param state The state to return to the server.
60     *   e.g. Contants.STATE_OK, see Constants.java
61     */
62    public void setState(String state) {
63       this.statusQosData.setState(state);
64    }
65 
66    /**
67     * @param stateInfo The state info attribute to return to the server.
68     */
69    public void setStateInfo(String stateInfo) {
70       this.statusQosData.setStateInfo(stateInfo);
71    }
72 
73    /**
74     * @see #toXml(String)
75     */
76    public String toXml() {
77       return toXml((String)null);
78    }
79 
80    /**
81     * Dump state of this object into a XML ASCII string.
82     * @param extraOffset indenting of tags for nice output
83     * @return The XML representation
84     */
85    public String toXml(String extraOffset) {
86       return this.statusQosData.toXml(extraOffset, (Properties)null);
87    }
88 
89    public String toString() {
90       return toXml((String)null);
91    }
92 }


syntax highlighted by Code2HTML, v. 0.9.1