cn.schoolwow.util.domain.replace.ReplaceFile Maven / Gradle / Ivy
package cn.schoolwow.util.domain.replace;
import cn.schoolwow.quickflow.QuickFlow;
import cn.schoolwow.quickflow.QuickFlowBuilder;
import cn.schoolwow.util.module.replace.domain.ReplaceFileOption;
import cn.schoolwow.util.module.replace.flow.ReplaceFileFlow;
import java.io.File;
public class ReplaceFile {
private static QuickFlow quickFlow = QuickFlowBuilder.newInstance();
private ReplaceFileOption replaceFileOption = new ReplaceFileOption();
public static ReplaceFile queryFile(File file){
ReplaceFile replaceFile = new ReplaceFile();
replaceFile.replaceFileOption.file = file;
quickFlow.putContextThreadLocalData("replaceFileOption", replaceFile.replaceFileOption);
return replaceFile;
}
/**
* 添加替换字符串
* @param sourceString 原始字符串
* @param targetString 目标字符串
* */
public ReplaceFile addReplaceString(String sourceString, String targetString){
replaceFileOption.replaceStringMap.put(sourceString, targetString);
return this;
}
/**
* 添加正则替换字符串
* @param sourceRegexString 原始正则字符串
* @param targetRegexString 目标正则字符串
* */
public ReplaceFile addRegexReplaceString(String sourceRegexString, String targetRegexString){
replaceFileOption.regexReplaceStringMap.put(sourceRegexString, targetRegexString);
return this;
}
public void replaceFile(){
quickFlow.startFlow(new ReplaceFileFlow()).execute();
}
}