public boolean accept(File dir, String name) { return filter.accept(name); } }
/** * Returns the children files that this file contains, filtering out files that do not match the specified FilenameFilter. * For this operation to be successful, this file must be 'browsable', i.e. {@link #isBrowsable()} must return * <code>true</code>. * * <p>This default implementation filters out files *after* they have been created. This method * should be overridden if a more efficient implementation can be provided by subclasses.</p> * * @param filter the FilenameFilter to be used to filter out files from the list, may be <code>null</code> * @return the children files that this file contains * @throws IOException if this operation is not possible (file is not browsable) or if an error occurred. * @throws UnsupportedFileOperationException if this method relies on a file operation that is not supported * or not implemented by the underlying filesystem. */ public AbstractFile[] ls(FilenameFilter filter) throws IOException, UnsupportedFileOperationException { return filter==null?ls():filter.filter(ls()); }
@Override public AbstractFile[] ls(FilenameFilter filenameFilter) throws IOException { String names[] = file.list(); if(names==null) throw new IOException(); if(filenameFilter!=null) names = filenameFilter.filter(names); AbstractFile children[] = new AbstractFile[names.length]; FileURL childURL; String baseURLPath = fileURL.getPath(); if(!baseURLPath.endsWith("/")) baseURLPath += SEPARATOR; for(int i=0; i<names.length; i++) { // Clone this file's URL with the connection properties and set the child file's path childURL = (FileURL)fileURL.clone(); childURL.setPath(baseURLPath+names[i]); // Create the child NFSFile using this file as a parent children[i] = FileFactory.getFile(childURL, this); } return children; }
public boolean accept(SmbFile dir, String name) throws SmbException { return filter.accept(name); } }
public boolean accept(File dir, String name) { return filter.accept(name); } }
public boolean accept(Path path) { return filenameFilter.accept(path.getName()); } }
/** * Returns the first <code>ArchiveFormatProvider</code> that matches the specified filename, <code>null</code> * if there is none. Note that if a filename matches the {@link java.io.FilenameFilter} of several registered * providers, the first provider matching the filename will be returned. * * @param filename an archive filename that potentially matches one of the registered <code>ArchiveFormatProvider</code> * @return the first <code>ArchiveFormatProvider</code> that matches the specified filename, <code>null</code> if there is none */ public static ArchiveFormatProvider getArchiveFormatProvider(String filename) { if(filename == null) return null; for (ArchiveFormatProvider provider : archiveFormatProviders) { if (provider.getFilenameFilter().accept(filename)) return provider; } return null; }
/** * Returns the contents (direct children) of the specified tree node. * * @throws UnsupportedFileOperationException if {@link FileOperation#READ_FILE} operations are not supported by the * underlying file protocol. */ private AbstractFile[] ls(DefaultMutableTreeNode treeNode, AbstractFile parentFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException, UnsupportedFileOperationException { AbstractFile files[]; int nbChildren = treeNode.getChildCount(); // No FilenameFilter, create entry files and store them directly into an array if(filenameFilter==null) { files = new AbstractFile[nbChildren]; for(int c=0; c<nbChildren; c++) { files[c] = getArchiveEntryFile((ArchiveEntry)(((DefaultMutableTreeNode)treeNode.getChildAt(c)).getUserObject()), parentFile); } } // Use provided FilenameFilter and temporarily store created entry files that match the filter in a Vector else { Vector<AbstractFile> filesV = new Vector<AbstractFile>(); for(int c=0; c<nbChildren; c++) { ArchiveEntry entry = (ArchiveEntry)(((DefaultMutableTreeNode)treeNode.getChildAt(c)).getUserObject()); if(!filenameFilter.accept(entry.getName())) continue; filesV.add(getArchiveEntryFile(entry, parentFile)); } files = new AbstractFile[filesV.size()]; filesV.toArray(files); } return fileFilter==null?files:fileFilter.filter(files); }
/** * Marks all files whose extension matches the current selection. */ @Override public void performAction() { FileTable fileTable; FileTableModel tableModel; FilenameFilter filter; int rowCount; boolean mark; // Initialization. Aborts if there is no selected file. fileTable = mainFrame.getActiveTable(); if((filter = getFilter(fileTable.getSelectedFile(false, true))) == null) return; tableModel = fileTable.getFileTableModel(); rowCount = tableModel.getRowCount(); mark = !tableModel.isRowMarked(fileTable.getSelectedRow()); // Goes through all files in the active table, marking all that match 'filter'. for(int i = tableModel.getFirstMarkableRow(); i < rowCount; i++) if(filter.accept(tableModel.getCachedFileAtRow(i))) tableModel.setRowMarked(i, mark); fileTable.repaint(); // Notify registered listeners that currently marked files have changed on the FileTable fileTable.fireMarkedFilesChangedEvent(); }