KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Jt > JtFactory


1
2
3 package Jt;
4 import java.util.*;
5 import java.lang.reflect.*;
6 import java.beans.*;
7 import java.io.*;
8
9 /**
10  * Jt Implementation of the Factory Method pattern.
11  */

12
13 public class JtFactory extends JtObject {
14
15
16
17
18   public JtFactory () {
19   }
20
21
22
23   /**
24     * Process object messages.
25     * <ul>
26     * <li>JtREMOVE - Performs any housekeeping that may be required before this object is removed.
27     * </ul>
28     */

29
30   public Object JavaDoc processMessage (Object JavaDoc event) {
31
32    String JavaDoc msgid = null;
33    JtMessage e = (JtMessage) event;
34    Object JavaDoc content;
35    Object JavaDoc data;
36
37
38      if (e == null)
39     return null;
40
41      msgid = (String JavaDoc) e.getMsgId ();
42
43      if (msgid == null)
44     return null;
45
46      content = e.getMsgContent();
47      //data = e.getMsgData ();
48

49      return (super.processMessage (event));
50 /*
51      if (msgid.equals ("JtREMOVE")) {
52        return (super.processMessage (null));
53      }
54
55
56      handleError ("JtFactory.processMessage: invalid message id:" + msgid);
57      return (null);
58 */

59
60   }
61
62  
63   /**
64    * Unit tests the messages processed by JtFactory
65    */

66
67   public static void main(String JavaDoc[] args) {
68
69     JtFactory factory = new JtFactory ();
70     JtObject obj;
71
72
73     // Create JtFactory
74

75     obj = (JtObject) factory.createObject ("Jt.JtObject", "object");
76     System.out.println (obj);
77
78
79
80   }
81
82 }
83
84
85
Popular Tags