@NonNull private Collection<File> listDir( @NonNull final Location location, @NonNull final String dir) { final Map<String, Map<File, CachedFileObject>> cache = getCacheLine(location, true); Map<File, CachedFileObject> content = cache.get(dir); return content == null ? Collections.<File>emptyList() : content.keySet(); }
/** * This method makes a copy of the storage * @param dir * @return */ @NonNull private Collection<JavaFileObject> getFileObjects( @NonNull final Location location, @NonNull final String dir) { final Map<String, Map<File, CachedFileObject>> cache = getCacheLine(location, true); Map<File, CachedFileObject> content = cache.get(dir); return new ArrayList<JavaFileObject>(content.values()); }
private void addFile( @NonNull final Location location, @NonNull final String packageName, @NonNull final CachedFileObject fo) { LOG.log(Level.FINE, "File added to cache:{0}:{1}", new Object[] { fo.getFile(), root }); // check whether the softref has been freed: final Map<String, Map<File, CachedFileObject>> cache = getCacheLine(location, false); Map<File, CachedFileObject> dirContent = cache.get(packageName); if (dirContent == null) { dirContent = new HashMap<File, CachedFileObject>(); cache.put(packageName, dirContent); } dirContent.put(toFile(fo), fo); }
@CheckForNull private CachedFileObject getFileObject( @NonNull final Location location, @NonNull final String dir, @NonNull final String file, @NonNull final boolean readOnly) { final Map<String, Map<File, CachedFileObject>> cache = getCacheLine(location, readOnly); final Map<File, CachedFileObject> content = cache.get(dir); if (content != null) { for (Map.Entry<File, CachedFileObject> en : content.entrySet()) { if (file.equals(en.getKey().getName())) { return en.getValue(); } } } return null; }