All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.usc.file.operater.rules.ReplaceConvertRule Maven / Gradle / Ivy

The newest version!
package org.usc.file.operater.rules;

import java.util.regex.Pattern;

/**
 * 字符串转换规则
 * 
 * @author ShunLi
 * @notes Created on 2010-12-11
* Revision of last commit:$Revision$
* Author of last commit:$Author$
* Date of last commit:$Date$
*

*/ public class ReplaceConvertRule implements ConvertRule { @Override public String reNameByRule(String oldName) { return reNameByRule(oldName, "", ""); } @Override public String reNameByRule(String oldName, String fix, String newFix) { if (fix == null || fix.trim().length() == 0) { return oldName; } else { return oldName.replaceAll(Pattern.quote(fix), newFix); } } @Override public String reNameByRule(String oldName, String fix, String newFix, Boolean isFolder) { if (isFolder) { int index = oldName.lastIndexOf("\\"); return oldName.substring(0, index + 1).concat(reNameByRule(oldName.substring(index + 1), fix, newFix)); } else { return reNameByRule(oldName, fix, newFix); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy