OSDN Git Service

merge.
[coroid/inqubus.git] / frontend / src / saccubus / ConvertingSetting.java
1 package saccubus;
2
3 import java.util.Properties;
4 import java.io.IOException;
5 import java.io.FileOutputStream;
6 import java.io.FileInputStream;
7 import java.io.File;
8 import org.apache.commons.io.FilenameUtils;
9
10 /**
11  * <p>
12  * \83^\83C\83g\83\8b\82³\82«\82ã\82Î\82·
13  * </p>
14  * 
15  * <p>
16  * \90à\96¾: \83j\83R\83j\83R\93®\89æ\82Ì\93®\89æ\82ð\83R\83\81\83\93\83g\82Â\82«\82Å\95Û\91
17  * </p>
18  * 
19  * <p>
20  * \92\98\8dì\8c : Copyright (c) 2007 PSI
21  * </p>
22  * 
23  * <p>
24  * \89ï\8eÐ\96¼:
25  * </p>
26  * 
27  * @author \96¢\93ü\97Í
28  * @version 1.0
29  */
30 public class ConvertingSetting {
31
32     public static final String[] ShadowKindArray = {
33         "00:\82È\82µ",
34         "01:\83j\83R\83j\83R\93®\89æ\95\97",
35         "02:\89E\89º",
36         "03:\88Í\82¢\8d\9e\82Ý"
37     };
38     private final String MailAddress;
39     private final String Password;
40     private final VideoSaveKind saveVideo;
41     private final File VideoFile;
42     private final boolean SaveComment;
43     private final File CommentFile;
44     private final boolean SaveConverted;
45     private final boolean addComment;
46     private final boolean addTcomment;
47     private final File ConvertedVideoFile;
48     private final String FFmpegPath;
49     private final String VhookPath;
50     private final String CmdLineOptionExt;
51     private final String CmdLineOptionIn;
52     private final String CmdLineOptionOut;
53     private final String CmdLineOptionMain;
54     private final String FontPath;
55     private final int FontIndex;
56     private final String BackComment;
57     private final boolean Vhook_ShowConvertingVideo;
58     private final int VideoShowNum;
59     private final boolean DeleteVideoAfterConverting;
60     private final boolean VideoFixFileName;
61     private final File VideoFixFileNameFolder;
62     private final boolean DeleteCommentAfterConverting;
63     private final boolean CommentFixFileName;
64     private final File CommentFixFileNameFolder;
65     private final TcommentSetting tcommentSetting;
66     private final boolean ConvFixFileName;
67     private final File ConvFixFileNameFolder;
68     private final String NG_Word;
69     private final String NG_ID;
70     private final boolean UseProxy;
71     private final String Proxy;
72     private final int ProxyPort;
73     private final boolean FixFontSize;
74     private final boolean FixCommentNum;
75     private final boolean OpaqueComment;
76     private final boolean NotAddVideoID_Conv;
77     private final File OptionFile;
78     private final boolean DisableVhook;
79     private final int ShadowIndex;
80
81     public ConvertingSetting(
82             String mailaddress,
83             String password,
84             VideoSaveKind savevideo,
85             String videofile,
86             boolean savecomment,
87             String commentfile,
88             boolean saveconverted,
89             boolean addComment,
90             boolean addTcomment,
91             String convvideofile,
92             String videoshownum,
93             String ffmpegpath,
94             String vhookpath,
95             String cmdlineoption_ext,
96             String cmdlineoption_main,
97             String cmdlineoption_in,
98             String cmdlineoption_out,
99             String backcomment,
100             String fontpath,
101             int font_index,
102             boolean showconvvideo,
103             boolean delete_video_after_conv,
104             boolean video_fix_file_name,
105             String video_fix_file_name_folder,
106             boolean delete_comment_after_conv,
107             boolean comment_fix_file_name,
108             String comment_fix_file_name_folder,
109             TcommentSetting tcommentSetting,
110             boolean not_add_videoid_conv,
111             boolean conv_fix_file_name,
112             String conv_fix_file_name_folder,
113             String ngword,
114             String ngid,
115             boolean use_proxy,
116             String proxy,
117             int proxy_port,
118             boolean fix_font_size,
119             boolean fix_comment_num,
120             boolean opaque_comment,
121             File option_file, boolean disable_vhook,
122             int shadow_index) {
123         MailAddress = mailaddress;
124         Password = password;
125         this.saveVideo = savevideo;
126         if (videofile.lastIndexOf(".") < videofile.lastIndexOf("\\")) {
127             videofile += ".flv";
128         }
129         VideoFile = new File(videofile);
130         SaveComment = savecomment;
131         if (commentfile.lastIndexOf(".") < commentfile.lastIndexOf("\\")) {
132             commentfile += ".xml";
133         }
134         CommentFile = new File(commentfile);
135         SaveConverted = saveconverted;
136         this.addComment = addComment;
137         this.addTcomment = addTcomment;
138         if (convvideofile.lastIndexOf(".") < convvideofile.lastIndexOf("\\")) {
139             convvideofile += ".avi";
140         }
141         ConvertedVideoFile = new File(convvideofile);
142         int num = 30;
143         try {
144             num = Integer.parseInt(videoshownum);
145         } catch (NumberFormatException ex) {
146         }
147         VideoShowNum = num;
148         FFmpegPath = ffmpegpath;
149         VhookPath = vhookpath;
150         CmdLineOptionExt = cmdlineoption_ext;
151         CmdLineOptionMain = cmdlineoption_main;
152         CmdLineOptionIn = cmdlineoption_in;
153         CmdLineOptionOut = cmdlineoption_out;
154         BackComment = backcomment;
155         FontPath = fontpath;
156         FontIndex = font_index;
157         Vhook_ShowConvertingVideo = showconvvideo;
158         DeleteVideoAfterConverting = delete_video_after_conv;
159         VideoFixFileName = video_fix_file_name;
160         VideoFixFileNameFolder = new File(video_fix_file_name_folder, "");
161         DeleteCommentAfterConverting = delete_comment_after_conv;
162         CommentFixFileName = comment_fix_file_name;
163         CommentFixFileNameFolder = new File(comment_fix_file_name_folder, "");
164         this.tcommentSetting = tcommentSetting;
165         NotAddVideoID_Conv = not_add_videoid_conv;
166         ConvFixFileName = conv_fix_file_name;
167         ConvFixFileNameFolder = new File(conv_fix_file_name_folder, "");
168         NG_Word = ngword;
169         NG_ID = ngid;
170         UseProxy = use_proxy;
171         Proxy = proxy;
172         ProxyPort = proxy_port;
173         FixFontSize = fix_font_size;
174         FixCommentNum = fix_comment_num;
175         OpaqueComment = opaque_comment;
176         OptionFile = option_file;
177         DisableVhook = disable_vhook;
178         ShadowIndex = shadow_index;
179     }
180
181     public File getVideoFile() {
182         return VideoFile;
183     }
184
185     public File getCommentFile() {
186         return CommentFile;
187     }
188
189     public File getConvertedVideoFile() {
190         return ConvertedVideoFile;
191     }
192
193     public String getFFmpegPath() {
194         return FFmpegPath;
195     }
196
197     public String getVhookPath() {
198         return VhookPath;
199     }
200
201     public String getCmdLineOptionIn() {
202         return CmdLineOptionIn;
203     }
204
205     public String getFontPath() {
206         return FontPath;
207     }
208
209     public String getFontIndex() {
210         return Integer.toString(FontIndex);
211     }
212
213     public boolean isVhook_ShowConvertingVideo() {
214         return Vhook_ShowConvertingVideo;
215     }
216
217     public String getMailAddress() {
218         return MailAddress;
219     }
220
221     public String getPassword() {
222         return Password;
223     }
224
225     public VideoSaveKind getVideoSaveKind() {
226         return saveVideo;
227     }
228
229     public boolean isSaveComment() {
230         return SaveComment;
231     }
232
233     /** @return \81u\83R\83\81\83\93\83g\95t\82«\93®\89æ\82É\95Ï\8a·\82·\82é\81v\82È\82çtrue. */
234     public boolean isSaveConverted() {
235         return SaveConverted;
236     }
237     /** @return \95Ï\8a·\93®\89æ\82É\83R\83\81\83\93\83g\82ð\82Â\82¯\82é\82È\82çtrue. */
238     public boolean getAddComment() {
239         return addComment;
240     }
241
242     /** @return \95Ï\8a·\93®\89æ\82É\93\8a\8de\8eÒ\83R\83\81\83\93\83g\82ð\82Â\82¯\82é\82È\82çtrue. */
243     public boolean getAddTcomment() {
244         return addTcomment;
245     }
246
247
248     public String getCmdLineOptionOut() {
249         return CmdLineOptionOut;
250     }
251
252     public String getBackComment() {
253         return BackComment;
254     }
255
256     public String getVideoShowNum() {
257         return Integer.toString(VideoShowNum);
258     }
259
260     public String getCmdLineOptionExt() {
261         return CmdLineOptionExt;
262     }
263
264     public String getCmdLineOptionMain() {
265         return CmdLineOptionMain;
266     }
267
268     /**
269      * @return \93®\89æ\95Û\91\90Ý\92è\82Å\81u\95Û\91\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\82Ì\82Å\82 \82ê\82Îtrue.
270      * \81u\95Û\91\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\82Ì\82Å\82 \82ê\82Îfalse.
271      */
272     public boolean isVideoFixFileName() {
273         return VideoFixFileName;
274     }
275
276     public boolean isDeleteVideoAfterConverting() {
277         return DeleteVideoAfterConverting;
278     }
279
280     public File getVideoFixFileNameFolder() {
281         return VideoFixFileNameFolder;
282     }
283
284     public boolean isCommentFixFileName() {
285         return CommentFixFileName;
286     }
287
288     public boolean isDeleteCommentAfterConverting() {
289         return DeleteCommentAfterConverting;
290     }
291
292     public File getCommentFixFileNameFolder() {
293         return CommentFixFileNameFolder;
294     }
295
296     public boolean isNotAddVideoID_Conv() {
297         return NotAddVideoID_Conv;
298     }
299
300     public boolean isConvFixFileName() {
301         return ConvFixFileName;
302     }
303
304     public File getConvFixFileNameFolder() {
305         return ConvFixFileNameFolder;
306     }
307
308     public String getNG_Word() {
309         return NG_Word;
310     }
311
312     public String getNG_ID() {
313         return NG_ID;
314     }
315
316     public boolean useProxy() {
317         return UseProxy;
318     }
319
320     public String getProxy() {
321         return Proxy;
322     }
323
324     public int getProxyPort() {
325         return ProxyPort;
326     }
327
328     public boolean isFixFontSize() {
329         return FixFontSize;
330     }
331
332     public boolean isFixCommentNum() {
333         return FixCommentNum;
334     }
335
336     public boolean isOpaqueComment() {
337         return OpaqueComment;
338     }
339
340     public File getOptionFile() {
341         return OptionFile;
342     }
343
344     public boolean isVhookDisabled() {
345         return DisableVhook;
346     }
347
348     public int getShadowIndex() {
349         return ShadowIndex;
350     }
351     private static final String PROP_FILE = "./saccubus.xml";
352     private static final String PROP_MAILADDR = "MailAddress";
353     private static final String PROP_PASSWORD = "Password";
354     private static final String PROP_SAVE_VIDEO = "SaveVideoFile";
355     private static final String PROP_VIDEO_FILE = "VideoFile";
356     private static final String PROP_SAVE_COMMENT = "SaveCommentFile";
357     private static final String PROP_COMMENT_FILE = "CommentFile";
358     private static final String PROP_SAVE_CONVERTED = "SaveConvertedFile";
359     private static final String PROP_ADD_COMMENT = "AddComment";
360     private static final String PROP_ADD_TCOMMENT = "AddTcomment";
361     private static final String PROP_CONVERTED_FILE = "ConvertedFile";
362     private static final String PROP_FFMPEG_PATH = "FFnpegPath";
363     private static final String PROP_VHOOK_PATH = "VhookPath";
364     private static final String PROP_FONT_PATH = "FontPath";
365     private static final String PROP_FONT_INDEX = "FontIndex";
366     private static final String PROP_CMDLINE_EXT = "CMD_EXT";
367     private static final String PROP_CMDLINE_MAIN = "CMD_MAIN";
368     private static final String PROP_CMDLINE_IN = "CMD_IN";
369     private static final String PROP_CMDLINE_OUT = "CMD_OUT";
370     private static final String PROP_BACK_COMMENT = "BackComment";
371     private static final String PROP_SHOW_VIDEO = "ShowVideo";
372     private static final String PROP_SHOW_COMMENT = "ShowCommentNum";
373     private static final String PROP_VIDEO_FIX_FILE_NAME = "VideoFixFileName";
374     private static final String PROP_DEL_VIDEO_AFTER_CONV = "DeleteVideoAfterConv";
375     private static final String PROP_VIDEO_FIX_FILE_NAME_FOLDER = "VideoFixFileNameFolder";
376     private static final String PROP_DEL_COMMENT_AFTER_CONV = "DeleteCommentAfterConv";
377     private static final String PROP_COMMENT_FIX_FILE_NAME = "CommentFixFileName";
378     private static final String PROP_COMMENT_FIX_FILE_NAME_FOLDER = "CommentFixFileNameFolder";
379     private static final String PROP_NOT_ADD_VIDEOID_CONV = "NotAddVideoIDtoConverted";
380     private static final String PROP_CONV_FIX_FILE_NAME = "ConvFixFileName";
381     private static final String PROP_CONV_FIX_FILE_NAME_FOLDER = "ConvFixFileNameFolder";
382     private static final String PROP_NG_WORD = "NG_Word";
383     private static final String PROP_NG_ID = "NG_ID";
384     private static final String PROP_USE_PROXY = "UseProxy";
385     private static final String PROP_PROXY = "Proxy";
386     private static final String PROP_PROXY_PORT = "ProxyPort";
387     private static final String PROP_FIX_FONT_SIZE = "FixFontSize";
388     private static final String PROP_FIX_COMMENT_NUM = "FixCommentSize";
389     private static final String PROP_OPAQUE_COMMENT = "OpaqueComment";
390     private static final String PROP_OPTION_FILE = "OptionFile";
391     private static final String PROP_DISABLE_VHOOK = "VhookDisabled";
392     private static final String PROP_SHADOW_INDEX = "ShadowIndex";
393
394     public static void saveSetting(ConvertingSetting setting) {
395         Properties prop = new Properties();
396         prop.setProperty(PROP_MAILADDR, setting.getMailAddress());
397         prop.setProperty(PROP_PASSWORD, setting.getPassword());
398         prop.setProperty(PROP_SAVE_VIDEO, setting.getVideoSaveKind().toString());
399         prop.setProperty(PROP_VIDEO_FILE, setting.getVideoFile().getPath());
400         prop.setProperty(PROP_SAVE_COMMENT, Boolean.toString(setting.isSaveComment()));
401         prop.setProperty(PROP_COMMENT_FILE, setting.getCommentFile().getPath());
402         prop.setProperty(PROP_SAVE_CONVERTED, Boolean.toString(setting.isSaveConverted()));
403         prop.setProperty(PROP_ADD_COMMENT, Boolean.toString(setting.getAddComment()));
404         prop.setProperty(PROP_ADD_TCOMMENT, Boolean.toString(setting.getAddTcomment()));
405         prop.setProperty(PROP_SHOW_COMMENT, setting.getVideoShowNum());
406         prop.setProperty(PROP_CONVERTED_FILE, setting.getConvertedVideoFile().getPath());
407         prop.setProperty(PROP_FFMPEG_PATH, setting.getFFmpegPath());
408         prop.setProperty(PROP_VHOOK_PATH, setting.getVhookPath());
409         prop.setProperty(PROP_FONT_PATH, setting.getFontPath());
410         prop.setProperty(PROP_FONT_INDEX, setting.getFontIndex());
411         prop.setProperty(PROP_CMDLINE_EXT, setting.getCmdLineOptionExt());
412         prop.setProperty(PROP_CMDLINE_MAIN, setting.getCmdLineOptionMain());
413         prop.setProperty(PROP_CMDLINE_IN, setting.getCmdLineOptionIn());
414         prop.setProperty(PROP_CMDLINE_OUT, setting.getCmdLineOptionOut());
415         prop.setProperty(PROP_BACK_COMMENT, setting.getBackComment());
416         prop.setProperty(PROP_SHOW_VIDEO, Boolean.toString((setting.isVhook_ShowConvertingVideo())));
417         prop.setProperty(PROP_DEL_VIDEO_AFTER_CONV, Boolean.toString(setting.isDeleteVideoAfterConverting()));
418         prop.setProperty(PROP_VIDEO_FIX_FILE_NAME, Boolean.toString(setting.isVideoFixFileName()));
419         prop.setProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, setting.getVideoFixFileNameFolder().getPath());
420         prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(setting.isDeleteCommentAfterConverting()));
421         prop.setProperty(PROP_COMMENT_FIX_FILE_NAME, Boolean.toString(setting.isCommentFixFileName()));
422         prop.setProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, setting.getCommentFixFileNameFolder().getPath());
423
424         setting.getTcommentSetting().save(prop);
425
426         prop.setProperty(PROP_NOT_ADD_VIDEOID_CONV, Boolean.toString(setting.isNotAddVideoID_Conv()));
427
428         prop.setProperty(PROP_CONV_FIX_FILE_NAME, (new Boolean(setting.isConvFixFileName())).toString());
429         prop.setProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, setting.getConvFixFileNameFolder().getPath());
430
431         prop.setProperty(PROP_NG_WORD, setting.getNG_Word());
432         prop.setProperty(PROP_NG_ID, setting.getNG_ID());
433         prop.setProperty(PROP_USE_PROXY, Boolean.toString(setting.useProxy()));
434         prop.setProperty(PROP_PROXY, setting.getProxy());
435         prop.setProperty(PROP_PROXY_PORT, Integer.toString(setting.getProxyPort()));
436         prop.setProperty(PROP_FIX_FONT_SIZE, Boolean.toString(setting.isFixFontSize()));
437         prop.setProperty(PROP_FIX_COMMENT_NUM, Boolean.toString(setting.isFixCommentNum()));
438         prop.setProperty(PROP_OPAQUE_COMMENT, Boolean.toString(setting.isOpaqueComment()));
439         if (setting.getOptionFile() != null) {
440             prop.setProperty(PROP_OPTION_FILE, setting.getOptionFile().getPath());
441         }
442         prop.setProperty(PROP_DISABLE_VHOOK, Boolean.toString(setting.isVhookDisabled()));
443         prop.setProperty(PROP_SHADOW_INDEX, Integer.toString(setting.getShadowIndex()));
444         try {
445             prop.storeToXML(new FileOutputStream(PROP_FILE), "settings");
446         } catch (IOException ex) {
447             ex.printStackTrace();
448         }
449     }
450
451     /** \96{\89Æ\82³\82«\82ã\82Î\82·\82Å\95Û\91\82µ\82Ä\82¢\82½\8fê\8d\87\81APROP_SAVE_VIDEO\82Ítrue/false\82È\82Ì\82Å\95Ï\8a·\82·\82é. */
452     private static VideoSaveKind convertVideoSaveKind(Properties prop) {
453         VideoSaveKind kind;
454         String saveVideo = prop.getProperty(PROP_SAVE_VIDEO);
455         if (Boolean.toString(true).equals(saveVideo) || saveVideo == null) {
456             kind = VideoSaveKind.SAVE;
457         } else if (Boolean.toString(false).equals(saveVideo)) {
458             kind = VideoSaveKind.NO_SAVE;
459         } else {
460             kind = VideoSaveKind.valueOf(saveVideo);
461         }
462         return kind;
463     }
464
465     public static ConvertingSetting loadSetting(String user, String password) {
466         Properties prop = new Properties();
467         try {
468             prop.loadFromXML(new FileInputStream(PROP_FILE));
469         } catch (IOException ex) {
470             ex.printStackTrace();
471         }
472         if (user == null) {
473             user = prop.getProperty(PROP_MAILADDR, "");
474         }
475         if (password == null) {
476             password = prop.getProperty(PROP_PASSWORD, "");
477         }
478         String option_file_name = prop.getProperty(PROP_OPTION_FILE, null);
479         File option_file = null;
480         if (option_file_name != null) {
481             option_file = new File(option_file_name);
482         }
483         String win_dir = System.getenv("windir");
484         if (!win_dir.endsWith("\\")) {
485             win_dir = win_dir + "\\";
486         }
487
488         final VideoSaveKind kind = convertVideoSaveKind(prop);
489         return new ConvertingSetting(
490                 user,
491                 password,
492                 kind,
493                 prop.getProperty(PROP_VIDEO_FILE, ".\\video.flv"),
494                 Boolean.parseBoolean(prop.getProperty(PROP_SAVE_COMMENT, "true")),
495                 prop.getProperty(PROP_COMMENT_FILE, ".\\comment.xml"),
496                 Boolean.parseBoolean(prop.getProperty(PROP_SAVE_CONVERTED, "true")),
497                 Boolean.valueOf(prop.getProperty(PROP_ADD_COMMENT, "true")),
498                 Boolean.valueOf(prop.getProperty(PROP_ADD_TCOMMENT, "false")),
499                 prop.getProperty(PROP_CONVERTED_FILE, ".\\video.avi"),
500                 prop.getProperty(PROP_SHOW_COMMENT, "30"),
501                 prop.getProperty(PROP_FFMPEG_PATH, ".\\bin\\ffmpeg.exe"),
502                 prop.getProperty(PROP_VHOOK_PATH, ".\\bin\\nicovideo.dll"),
503                 prop.getProperty(PROP_CMDLINE_EXT, "avi"),
504                 prop.getProperty(PROP_CMDLINE_MAIN, ""),
505                 prop.getProperty(PROP_CMDLINE_IN, ""),
506                 prop.getProperty(PROP_CMDLINE_OUT, "-f ipod"),
507                 prop.getProperty(PROP_BACK_COMMENT, "500"),
508                 prop.getProperty(PROP_FONT_PATH, win_dir + "Fonts\\msgothic.ttc"),
509                 Integer.parseInt(prop.getProperty(PROP_FONT_INDEX, "1")),
510                 Boolean.parseBoolean(prop.getProperty(PROP_SHOW_VIDEO, "true")),
511                 Boolean.parseBoolean(prop.getProperty(PROP_DEL_VIDEO_AFTER_CONV, "false")),
512                 Boolean.parseBoolean(prop.getProperty(PROP_VIDEO_FIX_FILE_NAME, "true")),
513                 prop.getProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, ".\\[in]video\\"),
514                 Boolean.parseBoolean(prop.getProperty(PROP_DEL_COMMENT_AFTER_CONV, "false")),
515                 Boolean.parseBoolean(prop.getProperty(PROP_COMMENT_FIX_FILE_NAME, "true")),
516                 prop.getProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, ".\\[in]comment\\"),
517                 TcommentSetting.load(prop),
518                 Boolean.parseBoolean(prop.getProperty(PROP_NOT_ADD_VIDEOID_CONV, "false")),
519                 Boolean.parseBoolean(prop.getProperty(PROP_CONV_FIX_FILE_NAME, "true")),
520                 prop.getProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, ".\\[out]converted\\"),
521                 prop.getProperty(PROP_NG_WORD, ""),
522                 prop.getProperty(PROP_NG_ID, ""),
523                 Boolean.parseBoolean(prop.getProperty(PROP_USE_PROXY, "false")),
524                 prop.getProperty(PROP_PROXY, ""),
525                 Integer.parseInt(prop.getProperty(PROP_PROXY_PORT, "-1")),
526                 Boolean.parseBoolean(prop.getProperty(PROP_FIX_FONT_SIZE, "true")),
527                 Boolean.parseBoolean(prop.getProperty(PROP_FIX_COMMENT_NUM, "true")),
528                 Boolean.parseBoolean(prop.getProperty(PROP_OPAQUE_COMMENT, "false")),
529                 option_file, Boolean.parseBoolean(prop.getProperty(PROP_DISABLE_VHOOK, "false")),
530                 Integer.parseInt(prop.getProperty(PROP_SHADOW_INDEX, "1"),
531                 10));
532     }
533
534     public TcommentSetting getTcommentSetting() {
535         return tcommentSetting;
536     }
537
538     public static class TcommentSetting {
539
540         private final boolean download;
541         private final boolean delete;
542         private final boolean autoFileName;
543         private final String inputDirectory;
544         private final String inputFile;
545
546         public boolean isAutoFileName() {
547             return autoFileName;
548         }
549
550         public boolean isDelete() {
551             return delete;
552         }
553
554         public boolean isDownload() {
555             return download;
556         }
557
558         /** @return \83\86\81[\83U\82ª\81u\95Û\91\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l. */
559         public String getInputDirectory() {
560             return inputDirectory;
561         }
562
563         /** @return \83\86\81[\83U\82ª\81u\95Û\91\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l. */
564         public String getInputFile() {
565             return inputFile;
566         }
567
568         /** @return \95Û\91\90æ\83f\83B\83\8c\83N\83g\83\8a. autoFileName\82ªfalse\82Ì\8fê\8d\87\82à, \83t\83@\83C\83\8b\96¼\82Í\93ü\82ç\82È\82¢\82±\82Æ\82É\92\8d\88Ó. */
569         public File getDirectory() {
570             if (autoFileName) {
571                 return new File(inputDirectory);
572             } else {
573                 File parent = new File(inputFile).getParentFile();
574                 if (parent == null) {
575                     parent = new File("");
576                 }
577                 return parent;
578             }
579         }
580
581         /** @return \95Û\91\83t\83@\83C\83\8b\96¼. autoFileName\82ªtrue\82È\82ç\8fí\82Énull. */
582         public String getFileName() {
583             return FilenameUtils.getName(inputFile.toString());
584         }
585
586         /**
587          * \81u\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\81v\83p\83l\83\8b\82Ì\90Ý\92è.
588          * @param download \83_\83E\83\93\83\8d\81[\83h\82·\82é\95K\97v\82ª\82 \82ê\82Îtrue. \83\8d\81[\83J\83\8b\82É\82 \82é\83t\83@\83C\83\8b\82ð\97p\82¢\82é\82Ì\82Å\82 \82ê\82Îfalse.
589          * @param delete \8f\88\97\9d\8fI\97¹\8cã\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82·\82é\82Ì\82Å\82 \82ê\82Îtrue. \8ec\82µ\82½\82Ü\82Ü\82Å\82 \82ê\82Îfalse.
590          * @param inputDirectory \83\86\81[\83U\82ª\81u\95Û\91\82·\82é\83t\83H\83\8b\83_\82ð\8ew\92è\82µ\81A\83t\83@\83C\83\8b\96¼\82Í\8e©\93®\82Å\8c\88\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l.
591          * @param inputFile \83\86\81[\83U\82ª\81u\95Û\91\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\83e\83L\83X\83g\83t\83B\81[\83\8b\83h\82É\93ü\97Í\82µ\82½\92l.
592          */
593         public TcommentSetting(boolean download, boolean delete, boolean autoFileName, String inputDirectory,
594                 String inputFile) {
595             this.download = download;
596             this.delete = delete;
597             this.autoFileName = autoFileName;
598             this.inputDirectory = inputDirectory;
599             this.inputFile = inputFile;
600         }
601
602         public static TcommentSetting load(Properties prop) {
603             String str;
604             str = prop.getProperty(PROP_DOWNLOAD, Boolean.toString(true));
605             boolean down = Boolean.valueOf(str);
606             str = prop.getProperty(PROP_DELETE, Boolean.toString(false));
607             boolean del = Boolean.valueOf(str);
608             str = prop.getProperty(PROP_AUTOFILENAME, Boolean.toString(true));
609             boolean naming = Boolean.valueOf(str);
610             String dir = prop.getProperty(PROP_DIRECTORYNAME, ".\\[in]tcomment");
611             String f = prop.getProperty(PROP_FILENAME, ".\\tcomment.xml");
612             return new TcommentSetting(down, del, naming, dir, f);
613         }
614
615         public void save(Properties prop) {
616             prop.setProperty(PROP_DOWNLOAD, Boolean.toString(download));
617             prop.setProperty(PROP_DELETE, Boolean.toString(delete));
618             prop.setProperty(PROP_AUTOFILENAME, Boolean.toString(autoFileName));
619             prop.setProperty(PROP_DIRECTORYNAME, inputDirectory.toString());
620             prop.setProperty(PROP_FILENAME, inputFile.toString());
621         }
622         private static final String PROP_DOWNLOAD = "TCDownload";
623         private static final String PROP_DELETE = "TCDelete";
624         private static final String PROP_AUTOFILENAME = "TCAutoNaming";
625         private static final String PROP_DIRECTORYNAME = "TCDirectory";
626         private static final String PROP_FILENAME = "TCFileName";
627     }
628 }