public static String[] findJavaFilePathsRec(File srcCodeFolder) { List<File> files = GeneralUtils.getFilesRecursively(srcCodeFolder); List<String> javaFilePaths = new LinkedList<String>(); for (File f : files) { if (f.getName().endsWith(IJavaConstants.JAVA_FILE_EXTENSION)) { javaFilePaths.add(f.getAbsolutePath()); } } return javaFilePaths.toArray(new String[] {}); }
public static String deSerialize(String resultPath) throws FileNotFoundException, IOException { return GeneralUtils.readFromFile(new File(resultPath)); }
public static void deleteFolderContents(File folder, boolean removeFolders) { deleteFolderContents(folder, new ArrayList<String>(), removeFolders); }
/** * Enables the static methods of the java.lang.String class to be called from the templates. If the key "String" is * already reserved by the user, this method simply returns the input parameter. * * @param userCallables * @return all the template callables */ public TemplateCallable[] addDefaults(TemplateCallable[] userCallables) { TemplateCallable strFunctionality = new TemplateCallable(String.class.getSimpleName(), String.class); for (TemplateCallable u : userCallables) { if (u.equals(strFunctionality)) { return userCallables; } } return GeneralUtils.concat(userCallables, new TemplateCallable[] { strFunctionality }); }
files.addAll(filterFiles(GeneralUtils.getFiles(path))); } else
public String escapeStr(String str) { String escaped = ""; for (int i = 0; i < str.length(); i++) { char currentChar = str.charAt(i); escaped += GeneralUtils.isEscapeSequence(currentChar) ? StringEscapeUtils.escapeJava(currentChar + "") : currentChar + ""; } return escaped; }
public static StringBuffer readFromFile(String relativepath, Class<?> classRef) throws IOException { InputStream input = classRef.getResourceAsStream('/' + relativepath.replace("\\", "/")); return readFromInputStream(input); }
public static String readFromFile(File file) throws IOException { return readLines(file, System.getProperty("line.separator")).toString().trim(); }
resultFilename }, folder, GeneralUtils.concat(new File[] { folder }, cpJars));
files.addAll(JavaCodeGenMain.filterFiles(GeneralUtils.getFiles(path))); } else
public String escapeChar(char c) { return GeneralUtils.isEscapeSequence(c) ? StringEscapeUtils.escapeJavaScript(c + "") : c + ""; }
private void findVdmSources(List<File> files, File specificationRoot) { for (File f : GeneralUtils.getFilesRecursively(specificationRoot)) { if (GeneralCodeGenUtils.isVdmSourceFile(f)) { files.add(f); } } }
public Template getTemplate(Class<? extends INode> nodeClass) throws ParseException { if (cache.containsKey(nodeClass)) { return cache.get(nodeClass); } try { TemplateData td = getTemplateData(nodeClass); StringBuffer buffer = GeneralUtils.readFromFile(td.getTemplatePath(), td.getTemplateLoaderRef()); if (buffer == null) { return null; } Template template = constructTemplate(td.getTemplatePath(), buffer); cache.put(nodeClass, template); return template; } catch (IOException e) { return null; } }
public static void deleteFolderContents(File folder, List<String> folderNamesToAvoid, boolean removeFolders) { if (folder == null) { return; } File[] files = folder.listFiles(); if (files == null) { return; } for (File f : files) { if (f.isDirectory()) { if (!folderNamesToAvoid.contains(f.getName())) { deleteFolderContents(f, folderNamesToAvoid, removeFolders); } } else { f.delete(); } if (removeFolders) { f.delete(); } } }
public static List<File> getFilesRecursively(File folder) { File[] listOfFiles = folder.listFiles(); List<File> fileList = new LinkedList<File>(); if (listOfFiles == null || listOfFiles.length == 0) { return fileList; } for (File file : listOfFiles) { if (file.isFile()) { fileList.add(file); } if (file.isDirectory()) { fileList.addAll(getFilesRecursively(file)); } } return fileList; } }
@Override public ExecutionResult interpretVdm(File intputFile) throws Exception { initVdmEnv(); String input = GeneralUtils.readFromFile(intputFile); Value val = InterpreterUtil.interpret(input); return new ExecutionResult(val.toString(), val); } }