KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Jt > examples > Member


1 package Jt.examples;
2
3 import Jt.*;
4
5
6 import java.util.*;
7 import java.text.*;
8
9 public class Member extends JtObject {
10 private String JavaDoc email;
11 private String JavaDoc firstname;
12 private String JavaDoc lastname;
13 private int status;
14 private String JavaDoc subject;
15 private String JavaDoc comments;
16 private Date tstamp;
17
18   public Member() {
19   }
20
21   public int getStatus () {
22     return (status);
23   }
24
25   public void setStatus (int newStatus) {
26     status = newStatus;
27   }
28
29   public String JavaDoc getEmail() {
30     return email;
31   }
32
33   public void setEmail (String JavaDoc newEmail) {
34     email = newEmail;
35   }
36
37   public String JavaDoc getSubject() {
38     return subject;
39   }
40
41   public void setSubject (String JavaDoc newSubject) {
42     subject = newSubject;
43   }
44
45   public String JavaDoc getComments() {
46     return comments;
47   }
48
49   public void setComments (String JavaDoc newComments) {
50     comments = newComments;
51   }
52
53   public void setFirstname (String JavaDoc newFirstname) {
54     firstname = newFirstname;
55   }
56
57   public String JavaDoc getFirstname() {
58     return firstname;
59   }
60
61   public void setLastname (String JavaDoc newLastname) {
62     lastname = newLastname;
63   }
64
65   public String JavaDoc getLastname() {
66     return lastname;
67   }
68
69
70   public void setTstamp (Date tstamp) {
71     this.tstamp = tstamp;
72   }
73
74   public Date getTstamp () {
75     return tstamp;
76   }
77
78   /**
79     * Process object messages.
80     * <ul>
81     * <li> JtACTIVATE - Activates this object to locate a service.
82     * <li> JtTEST - Tests the messages processes by JtServiceLocator
83     * </ul>
84     * @param event message
85     */

86
87   public Object JavaDoc processMessage (Object JavaDoc event) {
88
89    String JavaDoc msgid = null;
90    JtMessage e = (JtMessage) event;
91    Object JavaDoc content;
92    JtValueObject valueObj;
93    JtMessage msg;
94
95      if (e == null)
96     return null;
97
98      msgid = (String JavaDoc) e.getMsgId ();
99
100      if (msgid == null)
101     return null;
102
103      content = e.getMsgContent();
104
105
106
107
108      if (msgid.equals ("JtREMOVE")) {
109              
110         return (null);
111
112      }
113
114      if (msgid.equals ("JtVALUE_OBJECT")) {
115         valueObj = new JtValueObject ();
116         setValue (valueObj, "subject", this);
117         msg = new JtMessage ("JtACTIVATE");
118         //msg.setMsgContent (this);
119

120         sendMessage (valueObj, msg);
121         return (valueObj);
122
123      }
124           
125      handleError ("processMessage: invalid message id:" + msgid);
126      return (null);
127
128   }
129
130   // Test program
131

132   public static void main(String JavaDoc[] args) {
133
134     JtObject main = new JtObject ();
135     JtMessage msg, msg1;
136     Integer JavaDoc count;
137     Date date = new Date ();
138     DateFormat df = DateFormat.getDateInstance();
139
140
141     main.setObjTrace (1);
142     main.createObject ("Member", "member");
143     msg = (JtMessage) main.createObject ("Jt.JtMessage", "message");
144     main.setValue ("message", "msgId", "JtPRINT");
145     //main.setValue ("member", "tstamp", "December 12, 2004");
146
main.setValue ("member", "tstamp", df.format (date));
147
148     main.sendMessage ("member", "message");
149   
150
151   }
152
153
154 }
Popular Tags