View Javadoc

1   // SendEvent.java - a HylaFAX Job representation
2   // $Id: SendEvent.java,v 1.2 2006/02/20 04:52:10 sjardine Exp $
3   //
4   // Copyright 2003 Innovation Software Group, LLC - http://www.innovationsw.com
5   //                Joe Phillips <joe.phillips@innovationsw.com>
6   //
7   // for information on the HylaFAX FAX server see
8   //  http://www.hylafax.org/
9   //
10  // This library is free software; you can redistribute it and/or
11  // modify it under the terms of the GNU Library General Public
12  // License as published by the Free Software Foundation; either
13  // version 2 of the License, or (at your option) any later version.
14  //
15  // This library is distributed in the hope that it will be useful,
16  // but WITHOUT ANY WARRANTY; without even the implied warranty of
17  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  // Library General Public License for more details.
19  //
20  // You should have received a copy of the GNU Library General Public
21  // License along with this library; if not, write to the Free
22  // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  //
24  package gnu.hylafax.job;
25  
26  
27  import java.util.StringTokenizer;
28  
29  /***
30   * This class contains the information available on a job notification.
31   * @author $Author: sjardine $
32   * @version $Id: SendEvent.java,v 1.2 2006/02/20 04:52:10 sjardine Exp $
33   */
34  public class SendEvent extends Event {
35  
36      /*** The job was completed successfully */
37      public final static String REASON_DONE = "done";
38  
39      /*** The job was not completed */
40      public final static String REASON_FAILED = "failed";
41  
42      /*** The job was rejected */
43      public final static String REASON_REJECTED = "rejected";
44  
45      /*** The job is blocked by other concurrent jobs */
46      public final static String REASON_BLOCKED = "blocked";
47  
48      /*** The job is being requeued for another attempt */
49      public final static String REASON_REQUEUED = "requeued";
50  
51      /*** The job was removed from the queue */
52      public final static String REASON_REMOVED = "removed";
53  
54      /*** The job was removed from the queue */
55      public final static String REASON_KILLED = "killed";
56  
57      /*** The job could not be sent before kill timer expired */
58      public final static String REASON_TIMEDOUT = "timedout";
59  
60      /*** The job document conversion failed */
61      public final static String REASON_FORMATFAILED = "format_failed";
62  
63      /*** The document conversion program could not be found */
64      public final static String REASON_NOFORMATTER = "no_formatter";
65  
66      /*** The remote side rejected a document poll */
67      public final static String REASON_POLLREJECTED = "poll_rejected";
68  
69      /*** There was no document available for polling */
70      public final static String REASON_POLLNODOCUMENT = "poll_no_document";
71  
72      /*** The document poll failed */
73      public final static String REASON_POLLFAILED = "poll_failed";
74  
75      private String reason;
76  
77      private long jobTime = -1;
78  
79      private String nextAttempt = null;
80  
81      private long jobid = -1;
82  
83      public void setJobId(long jid) {
84          jobid = jid;
85      }
86  
87      public long getJobId() {
88          return jobid;
89      }
90  
91      public String getReason() {
92          return reason;
93      }
94  
95      public void setReason(String r) {
96          reason = r;
97      }
98  
99      public long getElapsedTime() {
100         return jobTime;
101     }
102 
103     public void setElapsedTime(long time) {
104         jobTime = time;
105     }
106 
107     /***
108      * set the job elapsed time.
109      * @param time the elapsed time value in "mm:ss" format
110      */
111     public void setElapsedTime(String time) {
112         jobTime = -1;
113         if (time != null && !time.trim().equals("")) {
114             StringTokenizer st = new StringTokenizer(time.trim(), ":");
115             short minutes = Short.parseShort(st.nextToken());
116             short seconds = Short.parseShort(st.nextToken());
117             jobTime = (minutes * 60) + seconds;
118         }
119     }
120 
121     public void setNextAttempt(String seconds) {
122         nextAttempt = seconds;
123     }
124 
125     public String getNextAttempt() {
126         return nextAttempt;
127     }
128 
129 }// SendEvent class
130 // SendEvent.java