OSDN Git Service

8e8b1d19883ca1ba129ba38dc9bbcf4ec4dd15e8
[coroid/inqubus.git] / frontend / src / saccubus / converter / AbstractCommand.java
1 /* $Id$ */
2 package saccubus.converter;
3
4 import static org.apache.commons.lang.Validate.*;
5 import saccubus.ConvertStopFlag;
6 import saccubus.net.TextProgressListener;
7
8 /**
9  *
10  * @author yuki
11  */
12 public abstract class AbstractCommand {
13
14     private final TextProgressListener listener;
15     private final ConvertStopFlag StopFlag;
16
17     public AbstractCommand(TextProgressListener listener, ConvertStopFlag stopFlag) {
18         notNull(listener);
19         notNull(stopFlag);
20
21         this.listener = listener;
22         this.StopFlag = stopFlag;
23     }
24
25     protected void stopFlagReturn() throws InterruptedException {
26         if (getStopFlag().needStop()) {
27             throw new InterruptedException("中止しました。");
28         }
29     }
30
31     protected void sendText(String text) {
32         getListener().setText(text);
33     }
34
35     /**
36      * @return the listener
37      */
38     protected TextProgressListener getListener() {
39         return listener;
40     }
41
42     /**
43      * @return the StopFlag
44      */
45     protected ConvertStopFlag getStopFlag() {
46         return StopFlag;
47     }
48 }