@Override public File[] listFiles(FilenameFilter filter) { LinkedList<ServerFile> filtered = new LinkedList<ServerFile>(); for (ServerFile child : children) { if (filter.accept(this, child.getName())) { filtered.add(child); } } return filtered.toArray(new File[0]); }
@Override public String[] list(java.io.FilenameFilter filter) { LinkedList<String> names = new LinkedList<String>(); for (ServerFile child : children) { if (filter == null || filter.accept(this, child.getName())) { names.add(child.getName()); } } return names.toArray(new String[0]); };
public void addChild(ServerFile child) { if (!isDirectory) { throw new UnsupportedOperationException("cannot add children if not a directory"); } children.add(child); child.setParent(this); }