2 import org.opensrf.util.*;
5 public class Message implements OSRFSerializable {
8 public static final String REQUEST = "REQUEST";
9 public static final String STATUS = "STATUS";
10 public static final String RESULT = "RESULT";
11 public static final String CONNECT = "CONNECT";
12 public static final String DISCONNECT = "DISCONNECT";
14 /** Message ID. This number is used to relate requests to responses */
16 /** type of message. */
18 /** message payload */
19 private Object payload;
21 private String locale;
23 /** Create a registry for the osrfMessage object */
24 private static OSRFRegistry registry =
25 OSRFRegistry.registerObject(
27 OSRFRegistry.WireProtocol.HASH,
28 new String[] {"threadTrace", "type", "payload", "locale"});
31 * @param id This message's ID
32 * @param type The type of message
34 public Message(int id, String type) {
40 * @param id This message's ID
41 * @param type The type of message
42 * @param payload The message payload
44 public Message(int id, String type, Object payload) {
50 * @param id This message's ID
51 * @param type The type of message
52 * @param payload The message payload
53 * @param locale The message locale
55 public Message(int id, String type, Object payload, String locale) {
56 this(id, type, payload);
65 public String getType() {
68 public Object getPayload() {
71 public String getLocale() {
74 public void setId(int id) {
77 public void setString(String type) {
80 public void setPayload(Object p) {
83 public void setLocale(String l) {
88 * Implements the generic get() API required by OSRFSerializable
90 public Object get(String field) {
91 if("threadTrace".equals(field))
93 if("type".equals(field))
94 return getType().toString();
95 if("payload".equals(field))
97 if("locale".equals(field))
103 * @return The osrfMessage registry.
105 public OSRFRegistry getRegistry() {