OSDN Git Service

ConfigからProfileを生成するためのデフォルト実装クラス
authoryukihane <yukihane.feather@gmail.com>
Mon, 5 Sep 2011 23:07:05 +0000 (08:07 +0900)
committeryukihane <yukihane.feather@gmail.com>
Fri, 9 Sep 2011 11:42:28 +0000 (20:42 +0900)
frontend/src/yukihane/inqubus/config/ConfigCommentProfile.java [new file with mode: 0644]
frontend/src/yukihane/inqubus/config/ConfigDownloadProfile.java [new file with mode: 0644]
frontend/src/yukihane/inqubus/config/ConfigGeneralProfile.java [new file with mode: 0644]
frontend/src/yukihane/inqubus/config/ConfigLoginProfile.java [new file with mode: 0644]
frontend/src/yukihane/inqubus/config/ConfigProxyProfile.java [new file with mode: 0644]
frontend/src/yukihane/inqubus/config/ConfigVideoProfile.java [new file with mode: 0644]

diff --git a/frontend/src/yukihane/inqubus/config/ConfigCommentProfile.java b/frontend/src/yukihane/inqubus/config/ConfigCommentProfile.java
new file mode 100644 (file)
index 0000000..4086b4a
--- /dev/null
@@ -0,0 +1,71 @@
+package yukihane.inqubus.config;
+
+import java.io.File;
+import saccubus.worker.profile.CommentProfile;
+
+/**
+ * コンフィグに設定された値を基にしたCommentProfile実装.
+ * @author user
+ */
+public class ConfigCommentProfile implements CommentProfile {
+
+    private final int lengthRelatedCommentSize;
+    private final int perMinCommentSize;
+    private final boolean disablePerMinComment;
+    private final long backLogPoint;
+    private final boolean download;
+    private final File dir;
+    private final String fileName;
+
+    public ConfigCommentProfile() {
+        final Config p = Config.INSTANCE;
+        this.lengthRelatedCommentSize = (p.getCommentSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentSizeManual());
+        this.perMinCommentSize = (p.getCommentMinSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentMinSizeManual());
+        // TODO disablePerMinComment がデフォルト設定値に無い
+        this.disablePerMinComment = false;
+        this.backLogPoint = -1L;
+        this.download = !p.getCommentUseLocal();
+        this.dir = new File(p.getCommentDir());
+        this.fileName = p.getCommentFileNamePattern();
+    }
+
+    @Override
+    public int getLengthRelatedCommentSize() {
+        return lengthRelatedCommentSize;
+    }
+
+    @Override
+    public boolean isDisablePerMinComment() {
+        return disablePerMinComment;
+    }
+
+    @Override
+    public int getPerMinCommentSize() {
+        return perMinCommentSize;
+    }
+
+    @Override
+    public long getBackLogPoint() {
+        return backLogPoint;
+    }
+
+    @Override
+    public boolean isDownload() {
+        return download;
+    }
+
+    @Override
+    public File getDir() {
+        return dir;
+    }
+
+    @Override
+    public String getFileName() {
+        return fileName;
+    }
+
+    @Override
+    public File getLocalFile() {
+        return getDir();
+    }
+}
diff --git a/frontend/src/yukihane/inqubus/config/ConfigDownloadProfile.java b/frontend/src/yukihane/inqubus/config/ConfigDownloadProfile.java
new file mode 100644 (file)
index 0000000..a350032
--- /dev/null
@@ -0,0 +1,54 @@
+package yukihane.inqubus.config;
+
+import saccubus.worker.profile.CommentProfile;
+import saccubus.worker.profile.DownloadProfile;
+import saccubus.worker.profile.GeneralProfile;
+import saccubus.worker.profile.LoginProfile;
+import saccubus.worker.profile.ProxyProfile;
+import saccubus.worker.profile.VideoProfile;
+
+/**
+ * コンフィグに設定された値を基にしたDownloadProfile実装.
+ * @author user
+ */
+public class ConfigDownloadProfile implements DownloadProfile {
+
+    private final LoginProfile loginProfile;
+    private final ProxyProfile proxyProfile;
+    private final VideoProfile videoProfile;
+    private final CommentProfile commentProfile;
+    private final GeneralProfile generalProfile;
+
+    public ConfigDownloadProfile() {
+        this.loginProfile = new ConfigLoginProfile();
+        this.proxyProfile = new ConfigProxyProfile();
+        this.videoProfile = new ConfigVideoProfile();
+        this.commentProfile = new ConfigCommentProfile();
+        this.generalProfile = new ConfigGeneralProfile();
+    }
+
+    @Override
+    public LoginProfile getLoginProfile() {
+        return loginProfile;
+    }
+
+    @Override
+    public ProxyProfile getProxyProfile() {
+        return this.proxyProfile;
+    }
+
+    @Override
+    public VideoProfile getVideoProfile() {
+        return this.videoProfile;
+    }
+
+    @Override
+    public CommentProfile getCommentProfile() {
+        return this.commentProfile;
+    }
+
+    @Override
+    public GeneralProfile getGeneralProfile() {
+        return this.generalProfile;
+    }
+}
diff --git a/frontend/src/yukihane/inqubus/config/ConfigGeneralProfile.java b/frontend/src/yukihane/inqubus/config/ConfigGeneralProfile.java
new file mode 100644 (file)
index 0000000..e9cae1b
--- /dev/null
@@ -0,0 +1,29 @@
+package yukihane.inqubus.config;
+
+import saccubus.worker.profile.GeneralProfile;
+
+/**
+ * コンフィグに設定された値を基にしたGeneralProfilee実装.
+ * @author user
+ */
+public class ConfigGeneralProfile implements GeneralProfile {
+
+    private final String replaceFrom;
+    private final String replaceTo;
+
+    public ConfigGeneralProfile() {
+        final Config p = Config.INSTANCE;
+        this.replaceFrom = p.getReplaceFrom();
+        this.replaceTo = p.getReplaceTo();
+    }
+
+    @Override
+    public String getReplaceFrom() {
+        return replaceFrom;
+    }
+
+    @Override
+    public String getReplaceTo() {
+        return replaceTo;
+    }
+}
diff --git a/frontend/src/yukihane/inqubus/config/ConfigLoginProfile.java b/frontend/src/yukihane/inqubus/config/ConfigLoginProfile.java
new file mode 100644 (file)
index 0000000..d9e93de
--- /dev/null
@@ -0,0 +1,29 @@
+package yukihane.inqubus.config;
+
+import saccubus.worker.profile.LoginProfile;
+
+/**
+ * コンフィグに設定された値を基にしたLoginProfile実装.
+ * @author user
+ */
+public class ConfigLoginProfile implements LoginProfile {
+
+    private final String mail;
+    private final String password;
+
+    public ConfigLoginProfile() {
+        final Config p = Config.INSTANCE;
+        this.mail = p.getPassword();
+        this.password = p.getPassword();
+    }
+
+    @Override
+    public String getMail() {
+        return mail;
+    }
+
+    @Override
+    public String getPassword() {
+        return password;
+    }
+}
diff --git a/frontend/src/yukihane/inqubus/config/ConfigProxyProfile.java b/frontend/src/yukihane/inqubus/config/ConfigProxyProfile.java
new file mode 100644 (file)
index 0000000..fbecdaf
--- /dev/null
@@ -0,0 +1,36 @@
+package yukihane.inqubus.config;
+
+import saccubus.worker.profile.ProxyProfile;
+
+/**
+ * コンフィグに設定された値を基にしたProxyProfile実装.
+ * @author user
+ */
+public class ConfigProxyProfile implements ProxyProfile {
+
+    private final boolean use;
+    private final String host;
+    private final int port;
+
+    public ConfigProxyProfile() {
+        final Config p = Config.INSTANCE;
+        use = p.getProxyUse();
+        host = p.getProxyHost();
+        port = Integer.parseInt(p.getProxyPort());
+    }
+
+    @Override
+    public boolean use() {
+        return use;
+    }
+
+    @Override
+    public String getHost() {
+        return host;
+    }
+
+    @Override
+    public int getPort() {
+        return port;
+    }
+}
diff --git a/frontend/src/yukihane/inqubus/config/ConfigVideoProfile.java b/frontend/src/yukihane/inqubus/config/ConfigVideoProfile.java
new file mode 100644 (file)
index 0000000..6f9bed3
--- /dev/null
@@ -0,0 +1,42 @@
+package yukihane.inqubus.config;
+
+import java.io.File;
+import saccubus.worker.profile.VideoProfile;
+
+/**
+ * コンフィグに設定された値を基にしたVideoProfile実装.
+ * @author user
+ */
+public class ConfigVideoProfile implements VideoProfile {
+
+    private final boolean download;
+    private final File dir;
+    private final String fileName;
+
+    public ConfigVideoProfile() {
+        final Config p = Config.INSTANCE;
+        this.download = !p.getVideoUseLocal();
+        this.dir = new File(p.getVideoDir());
+        this.fileName = p.getVideoFileNamePattern();
+    }
+
+    @Override
+    public boolean isDownload() {
+        return download;
+    }
+
+    @Override
+    public File getDir() {
+        return dir;
+    }
+
+    @Override
+    public String getFileName() {
+        return fileName;
+    }
+
+    @Override
+    public File getLocalFile() {
+        return getDir();
+    }
+}
\ No newline at end of file