1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package com.sun.star.report;
24 
25 import java.io.IOException;
26 
27 /**
28  * This allows some simple job control. A job can be interrupted (or if it has
29  * not yet been started, canceled), and the job status can be queried (scheduled,
30  * running, finished).
31  *
32  * <table border="1">
33  * <tr>
34  * <th>JobStatus</th><th>running</th><th>finished</th>
35  * </tr>
36  * <tr>
37  * <td>Scheduled</td><td>false</td><td>false</td>
38  * </tr>
39  * <tr>
40  * <td>Running</td><td>true</td><td>false</td>
41  * </tr>
42  * <tr>
43  * <td>Finished</td><td>false</td><td>true</td>
44  * </tr>
45  * </table>
46  *
47  * @author Thomas Morgner
48  */
49 public interface ReportJob
50 {
51 
52     /**
53      * Although we might want to run the job as soon as it has been
54      * created, sometimes it is wiser to let the user add some listeners
55      * first. If we execute at once, the user either has to deal with
56      * threading code or wont receive any progress information in single
57      * threaded environments.
58      * @throws java.io.IOException
59      * @throws ReportExecutionException
60      */
execute()61     void execute()
62             throws ReportExecutionException, IOException;
63 
64     /**
65      * Interrupt the job.
66      */
interrupt()67     void interrupt();
68 
69     /**
70      * Queries the jobs execution status.
71      *
72      * @return true, if the job is currently running, false otherwise.
73      */
isRunning()74     boolean isRunning();
75 
76     /**
77      * Queries the jobs result status.
78      *
79      * @return true, if the job is finished (or has been interrupted), false
80      * if the job waits for activation.
81      */
isFinished()82     boolean isFinished();
83 
addProgressIndicator(JobProgressIndicator indicator)84     void addProgressIndicator(JobProgressIndicator indicator);
85 
removeProgressIndicator(JobProgressIndicator indicator)86     void removeProgressIndicator(JobProgressIndicator indicator);
87 }
88