/** return an iterable of all {@link org.reflections.vfs.Vfs.File} in given urls, starting with given packagePrefix and matching nameFilter */ public static Iterable<File> findFiles(final Collection<URL> inUrls, final String packagePrefix, final Predicate<String> nameFilter) { Predicate<File> fileNamePredicate = new Predicate<File>() { public boolean apply(File file) { String path = file.getRelativePath(); if (path.startsWith(packagePrefix)) { String filename = path.substring(path.indexOf(packagePrefix) + packagePrefix.length()); return !Utils.isEmpty(filename) && nameFilter.apply(filename.substring(1)); } else { return false; } } }; return findFiles(inUrls, fileNamePredicate); }
public String url() { if (CommonUtil.isEmpty(url) && !CommonUtil.isEmpty(altUrl)) { return altUrl; } if (!Utils.isEmpty(urlTitle) && !CommonUtil.isEmpty(altUrlTitle) && urlTitle.length() < altUrlTitle.length() && !isImg(altUrl) && !isImg(altUrlTitle)) { return altUrl; } if (CommonUtil.isEmpty(url)) { return null; } return url; }
public String title() { if (CommonUtil.isEmpty(urlTitle) && !CommonUtil.isEmpty(altUrlTitle)) { return altUrlTitle; } if (!Utils.isEmpty(urlTitle) && !CommonUtil.isEmpty(altUrlTitle) && urlTitle.length() < altUrlTitle.length() && !isImg(altUrl) && !isImg(altUrlTitle)) { return altUrlTitle; } if (CommonUtil.isEmpty(urlTitle)) { return null; } return urlTitle; }
public static String getName(Class type) { if (type.isArray()) { try { Class cl = type; int dim = 0; while (cl.isArray()) { dim++; cl = cl.getComponentType(); } return cl.getName() + Utils.repeat("[]", dim); } catch (Throwable e) { // } } return type.getName(); }
public ClassFile getOrCreateClassObject(final Vfs.File file) { InputStream inputStream = null; try { inputStream = file.openInputStream(); DataInputStream dis = new DataInputStream(new BufferedInputStream(inputStream)); return new ClassFile(dis); } catch (IOException e) { throw new ReflectionsException("could not create class file from " + file.getName(), e); } finally { Utils.close(inputStream); } }
public File save(Reflections reflections, String filename) { try { File file = Utils.prepareFile(filename); Files.write(toString(reflections), file, Charset.defaultCharset()); return file; } catch (IOException e) { throw new RuntimeException(e); } }
public void close() { Utils.close(jarInputStream); }