-package saccubus;
-
-import java.util.Properties;
-import java.io.IOException;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.File;
-import org.apache.commons.io.FilenameUtils;
-
-/**
- * <p>
- * \83^\83C\83g\83\8b: \82³\82«\82ã\82Î\82·
- * </p>
- *
- * <p>
- * \90à\96¾: \83j\83R\83j\83R\93®\89æ\82Ì\93®\89æ\82ð\83R\83\81\83\93\83g\82Â\82«\82Å\95Û\91¶
- * </p>
- *
- * <p>
- * \92\98\8dì\8c : Copyright (c) 2007 PSI
- * </p>
- *
- * <p>
- * \89ï\8eÐ\96¼:
- * </p>
- *
- * @author \96¢\93ü\97Í
- * @version 1.0
- */
-public class ConvertingSetting {
-
- public static final String[] ShadowKindArray = {
- "00:\82È\82µ",
- "01:\83j\83R\83j\83R\93®\89æ\95\97",
- "02:\89E\89º",
- "03:\88Í\82¢\8d\9e\82Ý"
- };
- private final String MailAddress;
- private final String Password;
- private final VideoSaveKind saveVideo;
- private final File VideoFile;
- private final boolean SaveComment;
- private final File CommentFile;
- private final boolean SaveConverted;
- private final boolean addComment;
- private final boolean addTcomment;
- private final File ConvertedVideoFile;
- private final String FFmpegPath;
- private final String VhookPath;
- private final String CmdLineOptionExt;
- private final String CmdLineOptionIn;
- private final String CmdLineOptionOut;
- private final String CmdLineOptionMain;
- private final String FontPath;
- private final int FontIndex;
- private final String BackComment;
- private final boolean Vhook_ShowConvertingVideo;
- private final int VideoShowNum;
- private final boolean DeleteVideoAfterConverting;
- private final boolean VideoFixFileName;
- private final File VideoFixFileNameFolder;
- private final boolean DeleteCommentAfterConverting;
- private final boolean CommentFixFileName;
- private final File CommentFixFileNameFolder;
- private final TcommentSetting tcommentSetting;
- private final boolean ConvFixFileName;
- private final File ConvFixFileNameFolder;
- private final String NG_Word;
- private final String NG_ID;
- private final boolean UseProxy;
- private final String Proxy;
- private final int ProxyPort;
- private final boolean FixFontSize;
- private final boolean FixCommentNum;
- private final boolean OpaqueComment;
- private final boolean NotAddVideoID_Conv;
- private final File OptionFile;
- private final boolean DisableVhook;
- private final int ShadowIndex;
-
- public ConvertingSetting(
- String mailaddress,
- String password,
- VideoSaveKind savevideo,
- String videofile,
- boolean savecomment,
- String commentfile,
- boolean saveconverted,
- boolean addComment,
- boolean addTcomment,
- String convvideofile,
- String videoshownum,
- String ffmpegpath,
- String vhookpath,
- String cmdlineoption_ext,
- String cmdlineoption_main,
- String cmdlineoption_in,
- String cmdlineoption_out,
- String backcomment,
- String fontpath,
- int font_index,
- boolean showconvvideo,
- boolean delete_video_after_conv,
- boolean video_fix_file_name,
- String video_fix_file_name_folder,
- boolean delete_comment_after_conv,
- boolean comment_fix_file_name,
- String comment_fix_file_name_folder,
- TcommentSetting tcommentSetting,
- boolean not_add_videoid_conv,
- boolean conv_fix_file_name,
- String conv_fix_file_name_folder,
- String ngword,
- String ngid,
- boolean use_proxy,
- String proxy,
- int proxy_port,
- boolean fix_font_size,
- boolean fix_comment_num,
- boolean opaque_comment,
- File option_file, boolean disable_vhook,
- int shadow_index) {
- MailAddress = mailaddress;
- Password = password;
- this.saveVideo = savevideo;
- if (videofile.lastIndexOf(".") < videofile.lastIndexOf("\\")) {
- videofile += ".flv";
- }
- VideoFile = new File(videofile);
- SaveComment = savecomment;
- if (commentfile.lastIndexOf(".") < commentfile.lastIndexOf("\\")) {
- commentfile += ".xml";
- }
- CommentFile = new File(commentfile);
- SaveConverted = saveconverted;
- this.addComment = addComment;
- this.addTcomment = addTcomment;
- if (convvideofile.lastIndexOf(".") < convvideofile.lastIndexOf("\\")) {
- convvideofile += ".avi";
- }
- ConvertedVideoFile = new File(convvideofile);
- int num = 30;
- try {
- num = Integer.parseInt(videoshownum);
- } catch (NumberFormatException ex) {
- }
- VideoShowNum = num;
- FFmpegPath = ffmpegpath;
- VhookPath = vhookpath;
- CmdLineOptionExt = cmdlineoption_ext;
- CmdLineOptionMain = cmdlineoption_main;
- CmdLineOptionIn = cmdlineoption_in;
- CmdLineOptionOut = cmdlineoption_out;
- BackComment = backcomment;
- FontPath = fontpath;
- FontIndex = font_index;
- Vhook_ShowConvertingVideo = showconvvideo;
- DeleteVideoAfterConverting = delete_video_after_conv;
- VideoFixFileName = video_fix_file_name;
- VideoFixFileNameFolder = new File(video_fix_file_name_folder, "");
- DeleteCommentAfterConverting = delete_comment_after_conv;
- CommentFixFileName = comment_fix_file_name;
- CommentFixFileNameFolder = new File(comment_fix_file_name_folder, "");
- this.tcommentSetting = tcommentSetting;
- NotAddVideoID_Conv = not_add_videoid_conv;
- ConvFixFileName = conv_fix_file_name;
- ConvFixFileNameFolder = new File(conv_fix_file_name_folder, "");
- NG_Word = ngword;
- NG_ID = ngid;
- UseProxy = use_proxy;
- Proxy = proxy;
- ProxyPort = proxy_port;
- FixFontSize = fix_font_size;
- FixCommentNum = fix_comment_num;
- OpaqueComment = opaque_comment;
- OptionFile = option_file;
- DisableVhook = disable_vhook;
- ShadowIndex = shadow_index;
- }
-
- public File getVideoFile() {
- return VideoFile;
- }
-
- public File getCommentFile() {
- return CommentFile;
- }
-
- public File getConvertedVideoFile() {
- return ConvertedVideoFile;
- }
-
- public String getFFmpegPath() {
- return FFmpegPath;
- }
-
- public String getVhookPath() {
- return VhookPath;
- }
-
- public String getCmdLineOptionIn() {
- return CmdLineOptionIn;
- }
-
- public String getFontPath() {
- return FontPath;
- }
-
- public String getFontIndex() {
- return Integer.toString(FontIndex);
- }
-
- public boolean isVhook_ShowConvertingVideo() {
- return Vhook_ShowConvertingVideo;
- }
-
- public String getMailAddress() {
- return MailAddress;
- }
-
- public String getPassword() {
- return Password;
- }
-
- public VideoSaveKind getVideoSaveKind() {
- return saveVideo;
- }
-
- public boolean isSaveComment() {
- return SaveComment;
- }
-
- /** @return \81u\83R\83\81\83\93\83g\95t\82«\93®\89æ\82É\95Ï\8a·\82·\82é\81v\82È\82çtrue. */
- public boolean isSaveConverted() {
- return SaveConverted;
- }
- /** @return \95Ï\8a·\93®\89æ\82É\83R\83\81\83\93\83g\82ð\82Â\82¯\82é\82È\82çtrue. */
- public boolean getAddComment() {
- return addComment;
- }
-
- /** @return \95Ï\8a·\93®\89æ\82É\93\8a\8de\8eÒ\83R\83\81\83\93\83g\82ð\82Â\82¯\82é\82È\82çtrue. */
- public boolean getAddTcomment() {
- return addTcomment;
- }
-
-
- public String getCmdLineOptionOut() {
- return CmdLineOptionOut;
- }
-
- public String getBackComment() {
- return BackComment;
- }
-
- public String getVideoShowNum() {
- return Integer.toString(VideoShowNum);
- }
-
- public String getCmdLineOptionExt() {
- return CmdLineOptionExt;
- }
-
- public String getCmdLineOptionMain() {
- return CmdLineOptionMain;
- }
-
- /**
- * @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.
- * \81u\95Û\91¶\82·\82é\83t\83@\83C\83\8b\96¼\82ð\8ew\92è\82·\82é\81v\82Ì\82Å\82 \82ê\82Îfalse.
- */
- public boolean isVideoFixFileName() {
- return VideoFixFileName;
- }
-
- public boolean isDeleteVideoAfterConverting() {
- return DeleteVideoAfterConverting;
- }
-
- public File getVideoFixFileNameFolder() {
- return VideoFixFileNameFolder;
- }
-
- public boolean isCommentFixFileName() {
- return CommentFixFileName;
- }
-
- public boolean isDeleteCommentAfterConverting() {
- return DeleteCommentAfterConverting;
- }
-
- public File getCommentFixFileNameFolder() {
- return CommentFixFileNameFolder;
- }
-
- public boolean isNotAddVideoID_Conv() {
- return NotAddVideoID_Conv;
- }
-
- public boolean isConvFixFileName() {
- return ConvFixFileName;
- }
-
- public File getConvFixFileNameFolder() {
- return ConvFixFileNameFolder;
- }
-
- public String getNG_Word() {
- return NG_Word;
- }
-
- public String getNG_ID() {
- return NG_ID;
- }
-
- public boolean useProxy() {
- return UseProxy;
- }
-
- public String getProxy() {
- return Proxy;
- }
-
- public int getProxyPort() {
- return ProxyPort;
- }
-
- public boolean isFixFontSize() {
- return FixFontSize;
- }
-
- public boolean isFixCommentNum() {
- return FixCommentNum;
- }
-
- public boolean isOpaqueComment() {
- return OpaqueComment;
- }
-
- public File getOptionFile() {
- return OptionFile;
- }
-
- public boolean isVhookDisabled() {
- return DisableVhook;
- }
-
- public int getShadowIndex() {
- return ShadowIndex;
- }
- private static final String PROP_FILE = "./saccubus.xml";
- private static final String PROP_MAILADDR = "MailAddress";
- private static final String PROP_PASSWORD = "Password";
- private static final String PROP_SAVE_VIDEO = "SaveVideoFile";
- private static final String PROP_VIDEO_FILE = "VideoFile";
- private static final String PROP_SAVE_COMMENT = "SaveCommentFile";
- private static final String PROP_COMMENT_FILE = "CommentFile";
- private static final String PROP_SAVE_CONVERTED = "SaveConvertedFile";
- private static final String PROP_ADD_COMMENT = "AddComment";
- private static final String PROP_ADD_TCOMMENT = "AddTcomment";
- private static final String PROP_CONVERTED_FILE = "ConvertedFile";
- private static final String PROP_FFMPEG_PATH = "FFnpegPath";
- private static final String PROP_VHOOK_PATH = "VhookPath";
- private static final String PROP_FONT_PATH = "FontPath";
- private static final String PROP_FONT_INDEX = "FontIndex";
- private static final String PROP_CMDLINE_EXT = "CMD_EXT";
- private static final String PROP_CMDLINE_MAIN = "CMD_MAIN";
- private static final String PROP_CMDLINE_IN = "CMD_IN";
- private static final String PROP_CMDLINE_OUT = "CMD_OUT";
- private static final String PROP_BACK_COMMENT = "BackComment";
- private static final String PROP_SHOW_VIDEO = "ShowVideo";
- private static final String PROP_SHOW_COMMENT = "ShowCommentNum";
- private static final String PROP_VIDEO_FIX_FILE_NAME = "VideoFixFileName";
- private static final String PROP_DEL_VIDEO_AFTER_CONV = "DeleteVideoAfterConv";
- private static final String PROP_VIDEO_FIX_FILE_NAME_FOLDER = "VideoFixFileNameFolder";
- private static final String PROP_DEL_COMMENT_AFTER_CONV = "DeleteCommentAfterConv";
- private static final String PROP_COMMENT_FIX_FILE_NAME = "CommentFixFileName";
- private static final String PROP_COMMENT_FIX_FILE_NAME_FOLDER = "CommentFixFileNameFolder";
- private static final String PROP_NOT_ADD_VIDEOID_CONV = "NotAddVideoIDtoConverted";
- private static final String PROP_CONV_FIX_FILE_NAME = "ConvFixFileName";
- private static final String PROP_CONV_FIX_FILE_NAME_FOLDER = "ConvFixFileNameFolder";
- private static final String PROP_NG_WORD = "NG_Word";
- private static final String PROP_NG_ID = "NG_ID";
- private static final String PROP_USE_PROXY = "UseProxy";
- private static final String PROP_PROXY = "Proxy";
- private static final String PROP_PROXY_PORT = "ProxyPort";
- private static final String PROP_FIX_FONT_SIZE = "FixFontSize";
- private static final String PROP_FIX_COMMENT_NUM = "FixCommentSize";
- private static final String PROP_OPAQUE_COMMENT = "OpaqueComment";
- private static final String PROP_OPTION_FILE = "OptionFile";
- private static final String PROP_DISABLE_VHOOK = "VhookDisabled";
- private static final String PROP_SHADOW_INDEX = "ShadowIndex";
-
- public static void saveSetting(ConvertingSetting setting) {
- Properties prop = new Properties();
- prop.setProperty(PROP_MAILADDR, setting.getMailAddress());
- prop.setProperty(PROP_PASSWORD, setting.getPassword());
- prop.setProperty(PROP_SAVE_VIDEO, setting.getVideoSaveKind().toString());
- prop.setProperty(PROP_VIDEO_FILE, setting.getVideoFile().getPath());
- prop.setProperty(PROP_SAVE_COMMENT, Boolean.toString(setting.isSaveComment()));
- prop.setProperty(PROP_COMMENT_FILE, setting.getCommentFile().getPath());
- prop.setProperty(PROP_SAVE_CONVERTED, Boolean.toString(setting.isSaveConverted()));
- prop.setProperty(PROP_ADD_COMMENT, Boolean.toString(setting.getAddComment()));
- prop.setProperty(PROP_ADD_TCOMMENT, Boolean.toString(setting.getAddTcomment()));
- prop.setProperty(PROP_SHOW_COMMENT, setting.getVideoShowNum());
- prop.setProperty(PROP_CONVERTED_FILE, setting.getConvertedVideoFile().getPath());
- prop.setProperty(PROP_FFMPEG_PATH, setting.getFFmpegPath());
- prop.setProperty(PROP_VHOOK_PATH, setting.getVhookPath());
- prop.setProperty(PROP_FONT_PATH, setting.getFontPath());
- prop.setProperty(PROP_FONT_INDEX, setting.getFontIndex());
- prop.setProperty(PROP_CMDLINE_EXT, setting.getCmdLineOptionExt());
- prop.setProperty(PROP_CMDLINE_MAIN, setting.getCmdLineOptionMain());
- prop.setProperty(PROP_CMDLINE_IN, setting.getCmdLineOptionIn());
- prop.setProperty(PROP_CMDLINE_OUT, setting.getCmdLineOptionOut());
- prop.setProperty(PROP_BACK_COMMENT, setting.getBackComment());
- prop.setProperty(PROP_SHOW_VIDEO, Boolean.toString((setting.isVhook_ShowConvertingVideo())));
- prop.setProperty(PROP_DEL_VIDEO_AFTER_CONV, Boolean.toString(setting.isDeleteVideoAfterConverting()));
- prop.setProperty(PROP_VIDEO_FIX_FILE_NAME, Boolean.toString(setting.isVideoFixFileName()));
- prop.setProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, setting.getVideoFixFileNameFolder().getPath());
- prop.setProperty(PROP_DEL_COMMENT_AFTER_CONV, Boolean.toString(setting.isDeleteCommentAfterConverting()));
- prop.setProperty(PROP_COMMENT_FIX_FILE_NAME, Boolean.toString(setting.isCommentFixFileName()));
- prop.setProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, setting.getCommentFixFileNameFolder().getPath());
-
- setting.getTcommentSetting().save(prop);
-
- prop.setProperty(PROP_NOT_ADD_VIDEOID_CONV, Boolean.toString(setting.isNotAddVideoID_Conv()));
-
- prop.setProperty(PROP_CONV_FIX_FILE_NAME, (new Boolean(setting.isConvFixFileName())).toString());
- prop.setProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, setting.getConvFixFileNameFolder().getPath());
-
- prop.setProperty(PROP_NG_WORD, setting.getNG_Word());
- prop.setProperty(PROP_NG_ID, setting.getNG_ID());
- prop.setProperty(PROP_USE_PROXY, Boolean.toString(setting.useProxy()));
- prop.setProperty(PROP_PROXY, setting.getProxy());
- prop.setProperty(PROP_PROXY_PORT, Integer.toString(setting.getProxyPort()));
- prop.setProperty(PROP_FIX_FONT_SIZE, Boolean.toString(setting.isFixFontSize()));
- prop.setProperty(PROP_FIX_COMMENT_NUM, Boolean.toString(setting.isFixCommentNum()));
- prop.setProperty(PROP_OPAQUE_COMMENT, Boolean.toString(setting.isOpaqueComment()));
- if (setting.getOptionFile() != null) {
- prop.setProperty(PROP_OPTION_FILE, setting.getOptionFile().getPath());
- }
- prop.setProperty(PROP_DISABLE_VHOOK, Boolean.toString(setting.isVhookDisabled()));
- prop.setProperty(PROP_SHADOW_INDEX, Integer.toString(setting.getShadowIndex()));
- try {
- prop.storeToXML(new FileOutputStream(PROP_FILE), "settings");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-
- /** \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é. */
- private static VideoSaveKind convertVideoSaveKind(Properties prop) {
- VideoSaveKind kind;
- String saveVideo = prop.getProperty(PROP_SAVE_VIDEO);
- if (Boolean.toString(true).equals(saveVideo) || saveVideo == null) {
- kind = VideoSaveKind.SAVE;
- } else if (Boolean.toString(false).equals(saveVideo)) {
- kind = VideoSaveKind.NO_SAVE;
- } else {
- kind = VideoSaveKind.valueOf(saveVideo);
- }
- return kind;
- }
-
- public static ConvertingSetting loadSetting(String user, String password) {
- Properties prop = new Properties();
- try {
- prop.loadFromXML(new FileInputStream(PROP_FILE));
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- if (user == null) {
- user = prop.getProperty(PROP_MAILADDR, "");
- }
- if (password == null) {
- password = prop.getProperty(PROP_PASSWORD, "");
- }
- String option_file_name = prop.getProperty(PROP_OPTION_FILE, null);
- File option_file = null;
- if (option_file_name != null) {
- option_file = new File(option_file_name);
- }
- String win_dir = System.getenv("windir");
- if (!win_dir.endsWith("\\")) {
- win_dir = win_dir + "\\";
- }
-
- final VideoSaveKind kind = convertVideoSaveKind(prop);
- return new ConvertingSetting(
- user,
- password,
- kind,
- prop.getProperty(PROP_VIDEO_FILE, ".\\video.flv"),
- Boolean.parseBoolean(prop.getProperty(PROP_SAVE_COMMENT, "true")),
- prop.getProperty(PROP_COMMENT_FILE, ".\\comment.xml"),
- Boolean.parseBoolean(prop.getProperty(PROP_SAVE_CONVERTED, "true")),
- Boolean.valueOf(prop.getProperty(PROP_ADD_COMMENT, "true")),
- Boolean.valueOf(prop.getProperty(PROP_ADD_TCOMMENT, "false")),
- prop.getProperty(PROP_CONVERTED_FILE, ".\\video.avi"),
- prop.getProperty(PROP_SHOW_COMMENT, "30"),
- prop.getProperty(PROP_FFMPEG_PATH, ".\\bin\\ffmpeg.exe"),
- prop.getProperty(PROP_VHOOK_PATH, ".\\bin\\nicovideo.dll"),
- prop.getProperty(PROP_CMDLINE_EXT, "avi"),
- prop.getProperty(PROP_CMDLINE_MAIN, ""),
- prop.getProperty(PROP_CMDLINE_IN, ""),
- prop.getProperty(PROP_CMDLINE_OUT, "-f ipod"),
- prop.getProperty(PROP_BACK_COMMENT, "500"),
- prop.getProperty(PROP_FONT_PATH, win_dir + "Fonts\\msgothic.ttc"),
- Integer.parseInt(prop.getProperty(PROP_FONT_INDEX, "1")),
- Boolean.parseBoolean(prop.getProperty(PROP_SHOW_VIDEO, "true")),
- Boolean.parseBoolean(prop.getProperty(PROP_DEL_VIDEO_AFTER_CONV, "false")),
- Boolean.parseBoolean(prop.getProperty(PROP_VIDEO_FIX_FILE_NAME, "true")),
- prop.getProperty(PROP_VIDEO_FIX_FILE_NAME_FOLDER, ".\\[in]video\\"),
- Boolean.parseBoolean(prop.getProperty(PROP_DEL_COMMENT_AFTER_CONV, "false")),
- Boolean.parseBoolean(prop.getProperty(PROP_COMMENT_FIX_FILE_NAME, "true")),
- prop.getProperty(PROP_COMMENT_FIX_FILE_NAME_FOLDER, ".\\[in]comment\\"),
- TcommentSetting.load(prop),
- Boolean.parseBoolean(prop.getProperty(PROP_NOT_ADD_VIDEOID_CONV, "false")),
- Boolean.parseBoolean(prop.getProperty(PROP_CONV_FIX_FILE_NAME, "true")),
- prop.getProperty(PROP_CONV_FIX_FILE_NAME_FOLDER, ".\\[out]converted\\"),
- prop.getProperty(PROP_NG_WORD, ""),
- prop.getProperty(PROP_NG_ID, ""),
- Boolean.parseBoolean(prop.getProperty(PROP_USE_PROXY, "false")),
- prop.getProperty(PROP_PROXY, ""),
- Integer.parseInt(prop.getProperty(PROP_PROXY_PORT, "-1")),
- Boolean.parseBoolean(prop.getProperty(PROP_FIX_FONT_SIZE, "true")),
- Boolean.parseBoolean(prop.getProperty(PROP_FIX_COMMENT_NUM, "true")),
- Boolean.parseBoolean(prop.getProperty(PROP_OPAQUE_COMMENT, "false")),
- option_file, Boolean.parseBoolean(prop.getProperty(PROP_DISABLE_VHOOK, "false")),
- Integer.parseInt(prop.getProperty(PROP_SHADOW_INDEX, "1"),
- 10));
- }
-
- public TcommentSetting getTcommentSetting() {
- return tcommentSetting;
- }
-
- public static class TcommentSetting {
-
- private final boolean download;
- private final boolean delete;
- private final boolean autoFileName;
- private final String inputDirectory;
- private final String inputFile;
-
- public boolean isAutoFileName() {
- return autoFileName;
- }
-
- public boolean isDelete() {
- return delete;
- }
-
- public boolean isDownload() {
- return download;
- }
-
- /** @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. */
- public String getInputDirectory() {
- return inputDirectory;
- }
-
- /** @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. */
- public String getInputFile() {
- return inputFile;
- }
-
- /** @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Ó. */
- public File getDirectory() {
- if (autoFileName) {
- return new File(inputDirectory);
- } else {
- File parent = new File(inputFile).getParentFile();
- if (parent == null) {
- parent = new File("");
- }
- return parent;
- }
- }
-
- /** @return \95Û\91¶\83t\83@\83C\83\8b\96¼. autoFileName\82ªtrue\82È\82ç\8fí\82Énull. */
- public String getFileName() {
- return FilenameUtils.getName(inputFile.toString());
- }
-
- /**
- * \81u\93ü\97Í\93\8a\8de\8eÒ\83R\83\81\83\93\83g\81v\83p\83l\83\8b\82Ì\90Ý\92è.
- * @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.
- * @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.
- * @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.
- * @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.
- */
- public TcommentSetting(boolean download, boolean delete, boolean autoFileName, String inputDirectory,
- String inputFile) {
- this.download = download;
- this.delete = delete;
- this.autoFileName = autoFileName;
- this.inputDirectory = inputDirectory;
- this.inputFile = inputFile;
- }
-
- public static TcommentSetting load(Properties prop) {
- String str;
- str = prop.getProperty(PROP_DOWNLOAD, Boolean.toString(true));
- boolean down = Boolean.valueOf(str);
- str = prop.getProperty(PROP_DELETE, Boolean.toString(false));
- boolean del = Boolean.valueOf(str);
- str = prop.getProperty(PROP_AUTOFILENAME, Boolean.toString(true));
- boolean naming = Boolean.valueOf(str);
- String dir = prop.getProperty(PROP_DIRECTORYNAME, ".\\[in]tcomment");
- String f = prop.getProperty(PROP_FILENAME, ".\\tcomment.xml");
- return new TcommentSetting(down, del, naming, dir, f);
- }
-
- public void save(Properties prop) {
- prop.setProperty(PROP_DOWNLOAD, Boolean.toString(download));
- prop.setProperty(PROP_DELETE, Boolean.toString(delete));
- prop.setProperty(PROP_AUTOFILENAME, Boolean.toString(autoFileName));
- prop.setProperty(PROP_DIRECTORYNAME, inputDirectory.toString());
- prop.setProperty(PROP_FILENAME, inputFile.toString());
- }
- private static final String PROP_DOWNLOAD = "TCDownload";
- private static final String PROP_DELETE = "TCDelete";
- private static final String PROP_AUTOFILENAME = "TCAutoNaming";
- private static final String PROP_DIRECTORYNAME = "TCDirectory";
- private static final String PROP_FILENAME = "TCFileName";
- }
-}