KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Jt > JtAbstractFactory


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

11
12
13 public abstract class JtAbstractFactory extends JtObject {
14
15
16   private Object JavaDoc family;
17
18   public JtAbstractFactory() {
19   }
20
21 /**
22   * Specifies the object family.
23   *
24   * @param family family
25   */

26
27   public void setFamily (Object JavaDoc family) {
28      this.family = family;
29
30   }
31
32 /**
33   * Returns the object family.
34   */

35
36   public Object JavaDoc getFamily () {
37      return (family);
38   }
39
40
41
42
43   /**
44     * Process object messages.
45     * @param event Jt Message
46     */

47
48   public Object JavaDoc processMessage (Object JavaDoc event) {
49
50    String JavaDoc msgid = null;
51    JtMessage e = (JtMessage) event;
52    Object JavaDoc content;
53
54  
55      if (e == null)
56     return null;
57
58      msgid = (String JavaDoc) e.getMsgId ();
59
60      if (msgid == null)
61     return null;
62
63      content = e.getMsgContent();
64
65
66      // Remove this object
67
if (msgid.equals ("JtREMOVE")) {
68        return (this);
69      }
70
71
72      if (family == null) {
73        handleError
74         ("processMessage: family attribute needs to be set" + msgid);
75        return (null);
76      }
77
78      handleError ("processMessage: invalid message id:" + msgid);
79      return (null);
80
81
82   }
83
84
85
86 }
87
88
Free Books   Free Magazines  
Popular Tags