本文整理汇总了Java中org.quickbundle.tools.helper.io.RmFileHelper类的典型用法代码示例。如果您正苦于以下问题:Java RmFileHelper类的具体用法?Java RmFileHelper怎么用?Java RmFileHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RmFileHelper类属于org.quickbundle.tools.helper.io包,在下文中一共展示了RmFileHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveXmlToPath
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 功能: 把xml保存到指定的路径文件名
*
* @param document
* @param targetFile
* @throws IOException
*/
public static boolean saveXmlToPath(Document document, String targetFile) {
try {
targetFile = formatToFile(targetFile);
RmFileHelper.initParentDir(targetFile);
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding(RmBaseConfig.getSingleton().getDefaultEncode());
XMLWriter writer = new XMLWriter(new FileOutputStream(targetFile), format);
writer.write(document);
writer.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例2: radioToDocument
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
private void radioToDocument(List<Element> lArchetype, Element archetype) {
for(Element tempTrchetype : lArchetype) {
if(archetype == tempTrchetype) {
tempTrchetype.addAttribute("selected", "true");
} else {
tempTrchetype.addAttribute("selected", "false");
}
}
try {
gpRule.loadProjectRule();
if(!new File(gpRule.getProjectTemplatePath()).exists()) {
throw new RuntimeException(RmFileHelper.formatToFile(gpRule.getProjectTemplatePath()) + " not exists!");
}
setErrorMessage(null);
} catch (Exception e) {
e.printStackTrace();
setErrorMessage(e.toString());
}
getContainer().updateButtons();
}
示例3: initMainRuleFile
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 功能: 从temp目录获得xml文件
*
* @return
* @throws Exception
*/
private File initMainRuleFile() throws Exception {
File fMailRule = new File(RmXmlHelper.formatToFile(QbXmlGenerateCodePlugin.qbGenerateCodeHome + File.separatorChar + RULE_XML_FILE));
if (fMailRule.exists()) {
Document thisTempDoc = RmXmlHelper.parse(fMailRule.getPath());
Document thisSourceDoc = RmXmlHelper.parse(RmXmlHelper.formatToFile(QbXmlGenerateCodePlugin.baseConfigPath + RULE_XML_FILE));
if (thisSourceDoc.valueOf("/rules/@rulesVersion").equals(thisTempDoc.valueOf("/rules/@rulesVersion"))) {
return fMailRule;
}
}
File rulePlugin = new File(RmXmlHelper.formatToFile(QbXmlGenerateCodePlugin.baseConfigPath + RULE_XML_FILE));
if (rulePlugin.exists()) {
try {
RmFileHelper.copyFile(rulePlugin, fMailRule);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
return fMailRule;
}
示例4: getProjectTemplatePath
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
public String getProjectTemplatePath() {
String currentSource = mainRule.valueOf("//archetype[@selected='true']/source");
if(currentSource.indexOf("{templatePath}") > -1) {
currentSource = currentSource.replaceFirst("\\{templatePath\\}", templatePath);
}
return RmFileHelper.formatToFile(currentSource);
}
示例5: getFileEndPart
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 得到文件名中去掉模板路径的结尾部分字符串
*
* @param sourceFile
* @return
*/
private String getFileEndPart(File sourceFile) {
String uriSourceFile = null;
try {
uriSourceFile = sourceFile.getCanonicalPath();
} catch (IOException e1) {
uriSourceFile = sourceFile.getAbsolutePath();
}
uriSourceFile = RmXmlHelper.formatToUrl(uriSourceFile);
uriSourceFile = uriSourceFile.substring(RmFileHelper.formatToUrl(gpRule.getProjectTemplatePath()).length());
return uriSourceFile;
}
示例6: outPutFile
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 功能:输出转化文件
*
* @param xsltPath
* @param myTableDoc
* @param outputFile
* @throws TransformerException
*/
public static void outPutFile(String xsltPath, String myTableXml, String outputFile) {
outputFile = RmXmlHelper.formatToFile(outputFile);
RmFileHelper.initParentDir(outputFile); //创建父目录
try {
String context = RmTransform.getStringFromTransform(xsltPath, myTableXml);
if (outputFile.endsWith(".java")) {
context = getJavaFileDescComment(outputFile) + context;
}
RmFileHelper.saveFile(context, outputFile);
} catch (Exception e) {
EclipseLog.logError("xslt=" + xsltPath + ", metaXml=" + myTableXml + "," + e.toString(), e);
e.printStackTrace();
}
}
示例7: outPutFile4ResultDocument
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 功能:转化文件,模板有初始化参数
*
* @param xsltPath
* @param myTableXml
* @param outputFile
* @param mAttribute
*/
public static void outPutFile4ResultDocument(String xsltPath, String myTableXml, String outputFolder, String outputFile) {
RmFileHelper.initSelfDir(RmXmlHelper.formatToFile(outputFolder));
if(outputFile != null && outputFile.length() > 0) {
outputFile = RmXmlHelper.formatToFile(outputFile);
RmFileHelper.initParentDir(outputFile); //创建目录
}
Map<String, Object> mAttribute = new HashMap<String, Object>();
mAttribute.put("targetFullPath", RmXmlHelper.formatToUrl(outputFolder));
try {
String context = RmTransform.getStringFromTransform(xsltPath, myTableXml, mAttribute);
if(outputFile != null) {
if (outputFile.endsWith(".java")) {
context = getJavaFileDescComment(outputFile) + context;
}
RmFileHelper.saveFile(context, outputFile);
}
} catch (Exception e) {
EclipseLog.logError("xslt=" + xsltPath + ", metaXml=" + myTableXml + "," + e.toString(), e);
e.printStackTrace();
}
{//如果目录为空则删除
removeFolderIfEmpty(outputFolder);
if(outputFile != null && outputFile.length() > 0) {
removeParentFolderIfEmpty(outputFile);
}
}
}
示例8: doGenerate
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private int doGenerate(IProgressMonitor monitor, Element thisTableTo, StringBuilder returnLog) throws MalformedURLException, DocumentException {
int result = 0;
String toTableNameKeyword = mainRule.valueOf("/rules/codegen/@toTableNameKeyword");
String originalTableName = thisTableTo.getText();
String currentTableXmlPath = RmXmlHelper.formatToUrl(quickbundleHome + FILE_CONCAT + thisTableTo.valueOf("@xmlName"));
Document docCurrentTable = RmXmlHelper.parse(currentTableXmlPath);
String filterTableName = getFilterTableName(currentTableXmlPath);
String tableDirName = docCurrentTable.valueOf("/meta/tables/table[1]/@tableDirName");
List<Element> lFile = mvmDoc.selectNodes(".//file");
for (Element eleFile : lFile) {
//取出当前rule的组件编码
String bundleCode = eleFile.valueOf("@bundleCode");
if(bundleCode != null && bundleCode.length() > 0 && docCurrentTable != null) {
String customBundleCode = docCurrentTable.valueOf("/meta/tables/table[@tableName='" + originalTableName + "']/@customBundleCode");
//如果定制编码不包含当前rule的组件编码,跳过
if(!customBundleCode.matches("^[\\w,]*" + bundleCode + "[\\w,]*$")) {
continue;
}
}
//得到当前这组的基本路径
String outPutPath = getOutPutPath(eleFile);
//得到最终路径
String xsltPath = templatePath + eleFile.valueOf("@xsltPath");
String outputFile = eleFile.valueOf("@outputFile");
outputFile = fillUpOutput(outputFile, toTableNameKeyword, eleFile, filterTableName, tableDirName, outPutPath);
String afterKeyWord = eleFile.valueOf("@afterKeyWord");
if (afterKeyWord.length() == 0) { //java和jsp文件
if("true".equals(eleFile.valueOf("@result-document"))) {
String outputFolder = eleFile.valueOf("@outputFolder");
outputFolder = fillUpOutput(outputFolder, toTableNameKeyword, eleFile, filterTableName, tableDirName, outPutPath);
if("".equals(eleFile.valueOf("@outputFile"))) {
TemplateHelper.outPutFile4ResultDocument(xsltPath, currentTableXmlPath, outputFolder);
} else {
if("".equals(eleFile.valueOf("@outputFolder"))) {
outputFolder = new File(RmFileHelper.formatToFile(outputFile)).getParent();
}
TemplateHelper.outPutFile4ResultDocument(xsltPath, currentTableXmlPath, outputFolder, outputFile);
}
} else {
TemplateHelper.outPutFile(xsltPath, currentTableXmlPath, outputFile);
}
} else { //配置文件
TemplateHelper.outPutFile(xsltPath, currentTableXmlPath, outputFile, afterKeyWord, "true".equals(eleFile.valueOf("@rowIsUnique")));
}
returnLog.append("\r\nxslt = ")
.append(RmFileHelper.formatToFile(xsltPath))
.append("\r\nmetaXml = ")
.append(RmFileHelper.formatToFile(currentTableXmlPath))
.append("\r\noutput=")
.append(RmFileHelper.formatToFile(outputFile));
if(afterKeyWord != null && afterKeyWord.length() > 0) {
returnLog.append("\r\nposition = ")
.append(afterKeyWord);
}
returnLog.append("\r\n");
result++;
if(monitor != null) {
monitor.worked(1);
String displayOutputFile = RmXmlHelper.formatToUrlNoPrefix(outputFile);
String tempStr = displayOutputFile;
if(displayOutputFile.length() > 140) {
tempStr = displayOutputFile.substring(0,12) + "..." + displayOutputFile.substring(displayOutputFile.length()-125);
}
monitor.setTaskName(tempStr);
}
}
return result;
}
示例9: formatToUrl
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 功能: 将路径格式化为url --> file:///c:/rmdemo.log
*
* @param filePath
* @return
*/
public static String formatToUrl(String filePath) {
return RmFileHelper.formatToUrl(filePath);
}
示例10: formatToUrlNoPrefix
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 功能: 将路径格式化为url --> c:/rmdemo.log
*
* @param filePath
* @return
*/
public static String formatToUrlNoPrefix(String filePath) {
return RmFileHelper.formatToUrlNoPrefix(filePath);
}
示例11: formatToFile
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* 功能: 将路径格式化为File形式 --> c:\rmdemo.log
*
* @param filePath
* @param osSeparatorStr 指定当前操作系统分隔符
* @return
*/
public static String formatToFile(String filePath, String osSeparatorStr) {
return RmFileHelper.formatToFile(filePath, osSeparatorStr);
}
示例12: writeToRandomFile
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* @deprecated
* 功能: 随机访问文件tartetPath,把context插到afterKeyWord后边
*
* @param targetPath
* @param context
* @param afterKeyWord
*/
public static void writeToRandomFile(String targetPath, String context, String afterKeyWord) {
RmFileHelper.writeToRandomFile(targetPath, context, afterKeyWord);
}
示例13: copyFile_reader
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* @deprecated
* 功能: 拷贝文件
*
* @param sourceFile
* @param targetFile
* @return
* @throws Exception
*/
public static boolean copyFile_reader(File sourceFile, File targetFile) throws Exception {
return RmFileHelper.copyFile_reader(sourceFile, targetFile);
}
示例14: copyFile
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* @deprecated
* 功能: 拷贝文件
*
* @param sourceFile
* @param targetFile
* @return
* @throws Exception
*/
public static boolean copyFile(File sourceFile, File targetFile) throws Exception {
RmFileHelper.copyFile(sourceFile, targetFile);
return true;
}
示例15: saveFile
import org.quickbundle.tools.helper.io.RmFileHelper; //导入依赖的package包/类
/**
* @deprecated
* 功能: 保存String到targetFile中
*
* @param context
* @param targetFile
* @return
* @throws Exception
*/
public static boolean saveFile(String context, String targetFile) throws Exception {
return RmFileHelper.saveFile(context, targetFile);
}