Java 类org.reflections.util.Utils 实例源码

项目:servicemix-bundles    文件:Vfs.java   
/** 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);
}
项目:reflections    文件:Vfs.java   
/** 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);
}
项目:ScreenSlicer    文件:ScrapeResult.java   
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;
}
项目:ScreenSlicer    文件:ScrapeResult.java   
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;
}
项目:reflections    文件:JavaReflectionAdapter.java   
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();
}
项目:reflections    文件:JavassistAdapter.java   
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);
    }
}
项目:reflections    文件:JsonSerializer.java   
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);
    }
}
项目:reflections    文件:JarInputDir.java   
public void close() {
    Utils.close(jarInputStream);
}