OSDN Git Service

merge
[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     private static final String PROP_COMMENT_FILE = "CommentFile";
14     private static final String PROP_BACK_COMMENT = "BackComment";
15     private static final String PROP_DEL_COMMENT_AFTER_CONV = "DeleteCommentAfterConv";
16     private static final String PROP_COMMENT_FIX_FILE_NAME = "CommentFixFileName";
17     private static final String PROP_COMMENT_FIX_FILE_NAME_FOLDER = "CommentFixFileNameFolder";
18     private static final String PROP_FIX_COMMENT_NUM = "FixCommentSize";
19     private static final String PROP_SAVE_COMMENT = "SaveCommentFile";
20     private final boolean selfAdjustNumOfComment;
21     private final int numOfComment;
22
23     public InputCommentSetting(boolean download, boolean autoNaming, File folder, File file, boolean deleteAfterConvert,
24             boolean adjust, int numOfCom) {
25         super(Boolean.valueOf(download), autoNaming, folder, file, deleteAfterConvert);
26         this.selfAdjustNumOfComment = adjust;
27         this.numOfComment = numOfCom;
28     }
29
30     public void save(Properties prop) {
31         prop.setProperty(PROP_COMMENT_FILE, getFile().getPath());
32         prop.setProperty(PROP_BACK_COMMENT, Integer.toString(getNumOfComment()));
33         prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(isDeleteAfterConvert()));
34         prop.setProperty(PROP_COMMENT_FIX_FILE_NAME, Boolean.toString(isAutoNaming()));
35         prop.setProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, getFolder().getPath());
36         prop.setProperty(PROP_FIX_COMMENT_NUM, Boolean.toString(isSelfAdjustNumOfComment()));
37         prop.setProperty(PROP_SAVE_COMMENT, getProcessKind().toString());
38
39     }
40
41     public static InputCommentSetting load(Properties prop) {
42
43         String file = prop.getProperty(PROP_COMMENT_FILE, "comment.xml");
44         String numOfComment = prop.getProperty(PROP_BACK_COMMENT, "500");
45         boolean delete = Boolean.parseBoolean(prop.getProperty(PROP_DEL_COMMENT_AFTER_CONV, "false"));
46         boolean adjustNumOfComment = Boolean.parseBoolean(prop.getProperty(PROP_COMMENT_FIX_FILE_NAME, "true"));
47         String folder = prop.getProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, "[out]comment");
48         boolean autoNaming = Boolean.parseBoolean(prop.getProperty(PROP_FIX_COMMENT_NUM, "true"));
49         boolean download = Boolean.parseBoolean(prop.getProperty(PROP_SAVE_COMMENT, "true"));
50
51         return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete,
52                 adjustNumOfComment,
53                 Integer.parseInt(numOfComment));
54     }
55
56     public final boolean isSelfAdjustNumOfComment() {
57         return selfAdjustNumOfComment;
58     }
59
60     public final int getNumOfComment() {
61         return numOfComment;
62     }
63 }