OSDN Git Service

プロファイルからコメント取得用情報を削除
[coroid/inqubus.git] / frontend / src / saccubus / ConvertStopFlag.java
1 package saccubus;
2
3 /**
4  * <p>
5  * タイトル: さきゅばす
6  * </p>
7  * 
8  * <p>
9  * 説明: ニコニコ動画の動画をコメントつきで保存
10  * </p>
11  * 
12  * <p>
13  * 著作権: Copyright (c) 2007 PSI
14  * </p>
15  * 
16  * <p>
17  * 会社名:
18  * </p>
19  * 
20  * @author 未入力
21  * @version 1.0
22  */
23 public class ConvertStopFlag {
24
25     public interface StateChangeListener {
26
27         void changeState(State s);
28         /**
29          * StateChangeListenerの何もしないバージョンの実装.
30          */
31         static final ConvertStopFlag.StateChangeListener EMPTY_LISTENER = new ConvertStopFlag.StateChangeListener() {
32
33             public void changeState(State s) {
34             }
35         };
36     }
37
38     public enum State {
39
40         STOPPING, FINISHED;
41     }
42     private volatile boolean needStop = false;
43     private volatile boolean finished = false;
44     private final StateChangeListener listener;
45
46     public ConvertStopFlag(StateChangeListener listener) {
47         this.listener = listener;
48     }
49
50     public void requestStop() {
51         needStop = true;
52         listener.changeState(State.STOPPING);
53     }
54
55     public boolean needStop() {
56         return needStop;
57     }
58
59     public boolean isFinished() {
60         return finished;
61     }
62
63     public void finished() {
64         finished = true;
65         listener.changeState(State.FINISHED);
66     }
67 }