Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: evt/gui/JspmEvtMessage.java


1   /*-----------------------------------------------------------------------------------------------------*/
2   /*                                                                                                     */
3   /*  Copyright (C)                                                                                      */
4   /*                                                                                                     */
5   /*  This program is free software; you can redistribute it and/or modify it under the terms of the GNU */
6   /*  General Public License as published by the Free Software Foundation; either version 2 of the       */
7   /*  License, or (at your option) any later version.                                                    */
8   /*                                                                                                     */
9   /*  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;          */
10  /*  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                   */
11  /*  PURPOSE. See the GNU General Public License for more details.                                      */
12  /*                                                                                                     */
13  /*  You should have received a copy of the GNU General Public License along with this program; if      */
14  /*  not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA           */
15  /*  02111-1307 USA                                                                                     */
16  /*                                                                                                     */
17  /*-----------------------------------------------------------------------------------------------------*/
18  /*                                                                                                     */
19  /*  $Author: strand01 $ $Revision: 1.3 $ $Date: 2001/12/20 14:23:03 $                                   */
20  /*                                                                                                     */
21  /*-----------------------------------------------------------------------------------------------------*/
22  
23  package evt.gui;
24  
25  // Java classes
26  import java.io.*;
27  import java.net.*;
28  import java.util.*;
29  
30  // JSPM classes
31  import com.jdk.*;
32  
33  /**
34   * This class provides the trap listener for the event management
35   *
36   * @author Steve Randall (strand012001@yahoo.com)
37   * @version 0.0.8
38   * @date 31/10/2001
39   */
40  public class JspmEvtMessage
41  {
42    /*
43     * The JspmLogWriter
44     */
45    private JspmLogWriter logWriter = null;
46   
47    /*
48     * The message ID
49     */
50    public int msgid = -2;
51  
52    /*
53     * The message
54     */
55    private String token = null;
56  
57    /*
58     * The message text
59     */
60    private String text = null;
61  
62    /*
63     * The description
64     */
65    private String description = null;
66    
67    /*
68     * The message group
69     */
70    private String group = null;
71  
72    /*
73     * The message node
74     */
75    private String node = null;
76  
77    /*
78     * The message node
79     */
80    private String source = null;
81  
82    /*
83     * The message owner
84     */
85    private String owner = null;
86  
87    /**
88     * Constructor
89     */
90    public JspmEvtMessage(int id, JspmLogWriter lw)
91    {
92      msgid = id;
93      logWriter = lw;
94    }
95  
96    /**
97     * Constructor
98     */
99    public JspmEvtMessage(JspmLogWriter lw)
100   {
101     logWriter = lw;
102   }
103 
104   public void setToken(String tok)
105   {
106     token = tok;
107   }
108 
109   public void setText(String txt)
110   {
111     text = txt;
112   }
113 
114   public String getText()
115   {
116     return text;
117   }
118 
119   public void setDescription(String desc)
120   {
121     description = desc;
122   }
123 
124   public void setGroup(String grp)
125   {
126     group = grp;
127   }
128 
129   public void setNode(String no)
130   {
131     node = no;
132   }
133 
134   public void setSource(String sou)
135   {
136     source = sou;
137   }
138 
139   public void setOwner(String own)
140   {
141     owner = own;
142   }
143 
144   private String getWord(String tok, String input)
145   {
146     int i = 0;
147     int count = Integer.parseInt(tok.substring(1));
148     
149     StringTokenizer tok0 = new StringTokenizer(input);
150     while(tok0.hasMoreTokens())
151     {
152       String word = tok0.nextToken();
153       if(i == count)
154         return word;
155       i++;
156     }
157     return null;
158   }
159   
160   public String processText(String input)
161   {
162     String data = new String();
163 
164     if(text.indexOf("$") > 0) {
165       StringTokenizer tok0 = new StringTokenizer(text);
166       while(tok0.hasMoreTokens())
167       {  
168         String word = tok0.nextToken();
169   if(word.indexOf("$") == 0)
170     data += " "+getWord(word, input);
171         else 
172           data += " "+word;
173       }
174       return(data);
175     }
176     return(input);
177   }
178 
179   public void writeToDb(JspmEvtDb jsmEvtDb)
180   {
181     System.err.println("writeToDb: "+msgid);
182     jsmEvtDb.addMessage(msgid, token, text, description, group, owner, node, source);
183   }
184 
185   public int delete(JspmEvtDb jsmEvtDb)
186   {
187     if(msgid > -2)
188       return(jsmEvtDb.deleteMessageById(msgid));
189     else if(token != null)
190       return(jsmEvtDb.deleteMessageByToken(token));
191     else if(group != null)
192       return(jsmEvtDb.deleteMessageByGroup(group));
193     return 0;
194   }
195 }
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224