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