/** * List the files in this directory, optionally list files for subdirectories recursively as well. * * @param recurse Set to true if all files in the directory tree should be returned. * @return a list of files in this directory. */ public List<ApplicationFile> listFiles(boolean recurse) { List<ApplicationFile> ret = new ArrayList<>(); List<ApplicationFile> files = listFiles(); ret.addAll(files); if (recurse) { for (ApplicationFile file : files) { if (file.isDirectory()) { ret.addAll(file.listFiles(recurse)); } } } return ret; }
Map<String, ExpressionFunction> readExpressions() { Map<String, ExpressionFunction> expressions = new HashMap<>(); ApplicationFile expressionPath = application.getFile(modelFiles.expressionsPath()); if ( ! expressionPath.exists() || ! expressionPath.isDirectory()) return Collections.emptyMap(); for (ApplicationFile expressionFile : expressionPath.listFiles()) { try (BufferedReader reader = new BufferedReader(expressionFile.createReader())){ String name = expressionFile.getPath().getName(); expressions.put(name, readExpression(name, reader)); } catch (IOException e) { throw new UncheckedIOException("Failed reading " + expressionFile.getPath(), e); } catch (ParseException e) { throw new IllegalStateException("Invalid stored expression in " + expressionFile, e); } } return expressions; }