* @param output 変換後出力動画.
* @throws IOException 変換失敗.
*/
- public Convert(ConvertProfile profile, File video, File comment, SaccubusListener<ConvertProgress> listener) {
+ public Convert(ConvertProfile profile, File video, File comment, WorkerListener<ConvertProgress> listener) {
super(listener);
this.profile = profile;
this.videoFile = video;
* @param listener
* @param flag
*/
- public Download(DownloadProfile profile, String videoId, SaccubusListener<DownloadProgress> listener) {
+ public Download(DownloadProfile profile, String videoId, WorkerListener<DownloadProgress> listener) {
// TODO listener登録
super(listener);
this.videoId = videoId;
--- /dev/null
+package saccubus.worker;
+
+import java.util.concurrent.Callable;
+
+/**
+ * 途中経過を報告できるCallableです.
+ *
+ * @author yuki
+ */
+public abstract class Worker<T, V> implements Callable<T> {
+ private static int serialNumber = 0;
+
+ private final int id;
+ private final WorkerListener<V> listener;
+
+ public Worker(WorkerListener<V> listener) {
+ this.id = ++serialNumber;
+ this.listener = listener;
+ }
+
+ public final int getId() {
+ return id;
+ }
+
+ protected final void publish(V value) {
+ if (listener != null) {
+ listener.process(value);
+ }
+ }
+
+ public interface WorkerListener<V> {
+
+ void process(V progress);
+ }
+}
import saccubus.util.WayBackTimeParser;
import saccubus.worker.ConvertProgress;
import saccubus.worker.DownloadProgress;
-import saccubus.worker.Worker.SaccubusListener;
+import saccubus.worker.Worker.WorkerListener;
import saccubus.worker.profile.CommentProfile;
import saccubus.worker.profile.DownloadProfile;
import saccubus.worker.profile.GeneralProfile;
return menuBar;
}
- private class DownloadProgressListener implements SaccubusListener<DownloadProgress> {
+ private class DownloadProgressListener implements WorkerListener<DownloadProgress> {
@Override
public void process(DownloadProgress progress) {
}
}
- private class ConvertProgressListener implements SaccubusListener<ConvertProgress> {
+ private class ConvertProgressListener implements WorkerListener<ConvertProgress> {
@Override
public void process(ConvertProgress progress) {
import java.io.File;
import saccubus.worker.ConvertProgress;
import saccubus.worker.DownloadProgress;
-import saccubus.worker.Worker.SaccubusListener;
+import saccubus.worker.Worker.WorkerListener;
import saccubus.worker.profile.ConvertProfile;
import saccubus.worker.profile.DownloadProfile;
private final int rowId;
private final DownloadProfile downloadProfile;
private final String videoId;
- private final SaccubusListener<DownloadProgress> downloadProgressListener;
+ private final WorkerListener<DownloadProgress> downloadProgressListener;
private final ConvertProfile convertProfile;
- private final SaccubusListener<ConvertProgress> convertProgressListener;
+ private final WorkerListener<ConvertProgress> convertProgressListener;
- public Request(DownloadProfile download, String videoId, SaccubusListener<DownloadProgress> downListener,
- ConvertProfile convert, SaccubusListener<ConvertProgress> convListener) {
+ public Request(DownloadProfile download, String videoId, WorkerListener<DownloadProgress> downListener,
+ ConvertProfile convert, WorkerListener<ConvertProgress> convListener) {
this.rowId = ++serialId;
this.downloadProfile = download;
this.videoId = videoId;
return rowId;
}
- SaccubusListener<DownloadProgress> getDownloadProgressListener() {
+ WorkerListener<DownloadProgress> getDownloadProgressListener() {
return downloadProgressListener;
}
- SaccubusListener<ConvertProgress> getConvertProgressListener() {
+ WorkerListener<ConvertProgress> getConvertProgressListener() {
return convertProgressListener;
}
}