19 package org.turro.elephant.impl.util;
21 import com.google.gson.Gson;
23 import java.io.FilenameFilter;
24 import java.util.ArrayList;
25 import java.util.Collections;
26 import java.util.List;
27 import org.turro.string.Strings;
28 import org.turro.elephant.context.ElephantContext;
29 import org.turro.elephant.context.IConstructor;
37 public static String
getJsonFiles(
final String path,
final String pattern) {
38 return new Gson().toJson(
getFiles(path, pattern));
42 List<String> files =
getFiles(path, pattern);
43 Collections.sort(files);
44 return new Gson().toJson(files);
48 List<String> files =
getFiles(path, pattern);
49 Collections.shuffle(files);
50 return new Gson().toJson(files);
53 public static List<String>
getFiles(
final String path,
final String pattern) {
54 ArrayList<String> files =
new ArrayList<>();
57 for(File
file : folder.listFiles(
new FilenameFilter() {
59 public boolean accept(File dir, String name) {
60 return name.matches(Strings.convertToRegEx(pattern));
77 return new File(
file);
80 public static boolean exists(String path) {
82 return path ==
null ? false :
new File(path).exists();
87 int p = path.lastIndexOf(
"/");
89 path = path.substring(0, p);
static String getRealPath(String path)
static String getRootWebPath()
static String getJsonFiles(final String path, final String pattern)
static String getJsonSortedFiles(final String path, final String pattern)
static String getJsonShuffledFiles(final String path, final String pattern)
static boolean exists(String path)
static File file(IConstructor constructor, String file)
static File file(String file)
static List< String > getFiles(final String path, final String pattern)
static String toExisting(String path)
ElContext getRenderingContext()