OSDN Git Service

Merging revisions 378-423 of 20100515_frontend_testing
[coroid/inqubus.git] / frontend / src / saccubus / properties / InputCommentSetting.java
1 /* $Id$ */
2 package saccubus.properties;
3
4 import java.io.File;
5 import java.util.Properties;
6
7 /**
8  * \93ü\97Í\83R\83\81\83\93\83g\90Ý\92è.
9  * @author yuki
10  */
11 public class InputCommentSetting extends InputFileSetting<Boolean> {
12
13     /** \83R\83\81\83\93\83g\82ð\83_\83E\83\93\83\8d\81[\83h\82·\82é. */
14     private static final String PROP_SAVE_COMMENT = "SaveCommentFile";
15     /** \95Ï\8a·\8cã\82É\83R\83\81\83\93\83g\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82·\82é. */
16     private static final String PROP_DEL_COMMENT_AFTER_CONV = "DeleteCommentAfterConv";
17     /** \83R\83\81\83\93\83g\8eæ\93¾\90\94\82Í\8e©\93®\82Å\92²\90®\82·\82é. */
18     private static final String PROP_FIX_COMMENT_NUM = "FixCommentSize";
19     /** \8eæ\93¾\83R\83\81\83\93\83g\90\94. */
20     private static final String PROP_BACK_COMMENT = "BackComment";
21     /** \83t\83H\83\8b\83_/\83t\83@\83C\83\8b\95Û\91\91I\91ð\83\89\83W\83I\83{\83^\83\93. */
22     private static final String PROP_COMMENT_FIX_FILE_NAME = "CommentFixFileName";
23     /** \83t\83H\83\8b\83_\96¼. */
24     private static final String PROP_COMMENT_FOLDER = "CommentFixFileNameFolder";
25     /** \83t\83@\83C\83\8b\96¼. */
26     private static final String PROP_COMMENT_FILE = "CommentFile";
27     private final boolean selfAdjustNumOfComment;
28     private final int numOfComment;
29
30     public InputCommentSetting(boolean download, boolean autoNaming, File folder, File file, boolean deleteAfterConvert,
31             boolean adjust, int numOfCom) {
32         super(Boolean.valueOf(download), autoNaming, folder, file, deleteAfterConvert);
33         this.selfAdjustNumOfComment = adjust;
34         this.numOfComment = numOfCom;
35     }
36
37     public void save(Properties prop) {
38         prop.setProperty(PROP_SAVE_COMMENT, getProcessKind().toString());
39         prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(isDeleteAfterConvert()));
40         prop.setProperty(PROP_FIX_COMMENT_NUM, Boolean.toString(isSelfAdjustNumOfComment()));
41         prop.setProperty(PROP_BACK_COMMENT, Integer.toString(getNumOfComment()));
42         prop.setProperty(PROP_COMMENT_FIX_FILE_NAME, Boolean.toString(isAutoNaming()));
43         prop.setProperty(PROP_COMMENT_FOLDER, getFolder().getPath());
44         prop.setProperty(PROP_COMMENT_FILE, getFile().getPath());
45
46     }
47
48     public static InputCommentSetting load(Properties prop) {
49         boolean download = Boolean.parseBoolean(prop.getProperty(PROP_SAVE_COMMENT, "true"));
50         boolean delete = Boolean.parseBoolean(prop.getProperty(PROP_DEL_COMMENT_AFTER_CONV, "false"));
51         boolean adjustNumOfComment = Boolean.parseBoolean(prop.getProperty(PROP_FIX_COMMENT_NUM, "true"));
52         String numOfComment = prop.getProperty(PROP_BACK_COMMENT, "500");
53         boolean autoNaming = Boolean.parseBoolean(prop.getProperty(PROP_COMMENT_FIX_FILE_NAME, "true"));
54         String folder = prop.getProperty(PROP_COMMENT_FOLDER, "[out]comment");
55         String file = prop.getProperty(PROP_COMMENT_FILE, "comment.xml");
56
57         return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete,
58                 adjustNumOfComment,
59                 Integer.parseInt(numOfComment));
60     }
61
62     public final boolean isSelfAdjustNumOfComment() {
63         return selfAdjustNumOfComment;
64     }
65
66     public final int getNumOfComment() {
67         return numOfComment;
68     }
69 }