753138177c6d98d37cd3dd36ee7dcbace61762c3
[jalview.git] / src / jalview / ws / jws1 / WSJob.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.ws.jws1;
22
23 import jalview.ws.AWsJob;
24
25 abstract class WSJob extends AWsJob
26 {
27   /*
28    * (non-Javadoc)
29    * 
30    * @see jalview.ws.AWsJob#clearResponse()
31    */
32   @Override
33   public void clearResponse()
34   {
35     result = null;
36   }
37
38   /*
39    * (non-Javadoc)
40    * 
41    * @see jalview.ws.AWsJob#hasResponse()
42    */
43   @Override
44   public boolean hasResponse()
45   {
46     return result != null;
47   }
48
49   /*
50    * (non-Javadoc)
51    * 
52    * @see jalview.ws.AWsJob#hasStatus()
53    */
54   @Override
55   public boolean hasStatus()
56   {
57     return result != null && result.getStatus() != null;
58   }
59
60   /**
61    * The last result object returned by the service.
62    */
63   vamsas.objects.simple.Result result;
64
65   /**
66    * @return
67    * @see vamsas.objects.simple.Result#getStatus()
68    */
69   public String getStatus()
70   {
71     return result == null ? null : result.getStatus();
72   }
73
74   public String getState()
75   {
76     return result == null ? "NULL result" : "" + result.getState();
77   }
78
79   /**
80    * @return
81    * @see vamsas.objects.simple.Result#isBroken()
82    */
83   public boolean isBroken()
84   {
85     return result != null && result.isBroken();
86   }
87
88   /**
89    * @return
90    * @see vamsas.objects.simple.Result#isFailed()
91    */
92   public boolean isFailed()
93   {
94     return result != null && result.isFailed();
95   }
96
97   /**
98    * @return
99    * @see vamsas.objects.simple.Result#isFinished()
100    */
101   public boolean isFinished()
102   {
103     return result != null && result.isFinished();
104   }
105
106   /**
107    * @return
108    * @see vamsas.objects.simple.Result#isInvalid()
109    */
110   public boolean isInvalid()
111   {
112     return result != null && result.isInvalid();
113   }
114
115   /**
116    * @return
117    * @see vamsas.objects.simple.Result#isJobFailed()
118    */
119   public boolean isJobFailed()
120   {
121     return result != null && result.isJobFailed();
122   }
123
124   /**
125    * @return
126    * @see vamsas.objects.simple.Result#isQueued()
127    */
128   public boolean isQueued()
129   {
130     return result != null && result.isQueued();
131   }
132
133   /**
134    * @return
135    * @see vamsas.objects.simple.Result#isRunning()
136    */
137   public boolean isRunning()
138   {
139     return result != null && result.isRunning();
140   }
141
142   /**
143    * @return
144    * @see vamsas.objects.simple.Result#isServerError()
145    */
146   public boolean isServerError()
147   {
148     return result != null && result.isServerError();
149   }
150 }