String[] list() { final Set<String> files = fileOps.getFileList(); //Careful! if you think you can optimize this array allocation, think again. //The _files_ are a concurrent structure, its size could vary in parallel: //the array population and dimensioning need to be performed atomically //to avoid trailing null elements in the returned array. final String[] array = files.toArray(new String[0]); return array; }
boolean fileExists(final String name) { return fileOps.getFileList().contains(name); }
/** * @return an array containing all names of existing "files" */ public String[] listFilenames() { readLock.lock(); try { return getFileList().toArray(); } finally { readLock.unlock(); } }
/** * @param fileName * @return true if there is such a named file in this index */ public boolean fileExists(final String fileName) { readLock.lock(); try { return getFileList().contains(fileName); } finally { readLock.unlock(); } }
/** * @return an array containing all names of existing "files" */ public String[] listFilenames() { readLock.lock(); try { return getFileList().toArray(); } finally { readLock.unlock(); } }
/** * @param fileName * @return true if there is such a named file in this index */ public boolean fileExists(final String fileName) { readLock.lock(); try { return getFileList().contains(fileName); } finally { readLock.unlock(); } }
public String[] list() { ensureOpen(); Set<String> files = fileOps.getFileList(); //Careful! if you think you can optimize this array allocation, think again. //The _files_ are a concurrent structure, its size could vary in parallel: //the array population and dimensioning need to be performed atomically //to avoid trailing null elements in the returned array. String[] array = files.toArray(new String[0]); return array; }
/** * {@inheritDoc} */ @Override public boolean fileExists(String name) { ensureOpen(); return fileOps.getFileList().contains(name); }
/** * Adds a new fileName in the list of files making up this index * @param fileName */ void addFileName(String fileName) { Set<String> fileList = getFileList(); boolean done = fileList.add(fileName); if (done) { cacheNoRetrieve.put(fileListCacheKey, fileList); if (trace) log.trace("Updated file listing: added " + fileName); } }
/** * Deleted a file from the list of files actively part of the index * @param fileName */ public void deleteFileName(String fileName) { Set<String> fileList = getFileList(); boolean done = fileList.remove(fileName); if (done) { cacheNoRetrieve.put(fileListCacheKey, fileList); if (trace) log.trace("Updated file listing: removed " + fileName); } }
/** * Optimized implementation to perform both a remove and an add * @param toRemove * @param toAdd */ public void removeAndAdd(String toRemove, String toAdd) { Set<String> fileList = getFileList(); boolean doneAdd = fileList.add(toAdd); boolean doneRemove = fileList.remove(toRemove); if (doneAdd || doneRemove) { cacheNoRetrieve.put(fileListCacheKey, fileList); if (trace) { if (doneAdd) log.trace("Updated file listing: added " + toAdd); if (doneRemove) log.trace("Updated file listing: removed " + toRemove); } } }
/** * Adds a new fileName in the list of files making up this index * @param fileName */ void addFileName(final String fileName) { writeLock.lock(); try { final FileListCacheValue fileList = getFileList(); boolean done = fileList.add(fileName); if (done) { updateFileList(fileList); if (trace) log.trace("Updated file listing: added " + fileName); } } finally { writeLock.unlock(); } }
/** * Optimized implementation to perform both a remove and an add * @param toRemove * @param toAdd */ public void removeAndAdd(final String toRemove, final String toAdd) { writeLock.lock(); try { FileListCacheValue fileList = getFileList(); boolean done = fileList.addAndRemove(toAdd, toRemove); if (done) { updateFileList(fileList); if (trace) { log.trace("Updated file listing: added " + toAdd + " and removed " + toRemove); } } } finally { writeLock.unlock(); } }
/** * Optimized implementation to perform both a remove and an add * @param toRemove * @param toAdd */ public void removeAndAdd(final String toRemove, final String toAdd) { writeLock.lock(); try { FileListCacheValue fileList = getFileList(); boolean done = fileList.addAndRemove(toAdd, toRemove); if (done) { updateFileList(fileList); if (trace) { log.trace("Updated file listing: added " + toAdd + " and removed " + toRemove); } } } finally { writeLock.unlock(); } }
/** * Adds a new fileName in the list of files making up this index * @param fileName */ void addFileName(final String fileName) { writeLock.lock(); try { final FileListCacheValue fileList = getFileList(); boolean done = fileList.add(fileName); if (done) { updateFileList(fileList); if (trace) log.trace("Updated file listing: added " + fileName); } } finally { writeLock.unlock(); } }
/** * Deleted a file from the list of files actively part of the index * @param fileName */ public void deleteFileName(final String fileName) { writeLock.lock(); try { FileListCacheValue fileList = getFileList(); boolean done = fileList.remove(fileName); if (done) { updateFileList(fileList); if (trace) log.trace("Updated file listing: removed " + fileName); } } finally { writeLock.unlock(); } }
/** * Deleted a file from the list of files actively part of the index * @param fileName */ public void deleteFileName(final String fileName) { writeLock.lock(); try { FileListCacheValue fileList = getFileList(); boolean done = fileList.remove(fileName); if (done) { updateFileList(fileList); if (trace) log.trace("Updated file listing: removed " + fileName); } } finally { writeLock.unlock(); } }