1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /* *******************************************************************
- * Copyright (c) 1999-2000 Xerox Corporation.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
- package org.aspectj.testing.util;
-
- import java.io.File;
- import java.util.Vector;
-
- /**
- * A FileFilter that accumulates the results when called if they exist.
- * Subclasses override accumulate to determine whether it should be
- * accumulated.
- */
- public class AccumulatingFileFilter extends ValidFileFilter {
- Vector<File> files = new Vector<File>();
- public final boolean accept(File f) {
- if (super.accept(f) && (accumulate(f))) {
- files.add(f);
- }
- return true;
- }
-
- /**
- * This implementation accumulates everything.
- * Subclasses should override to implement filter
- * @param file a File guaranteed to exist
- * @return true if file should be accumulated.
- */
- public boolean accumulate(File f) {
- return true;
- }
- /**
- * @return list of files currently accumulated
- */
- public File[] getFiles() {
- int numFiles = files.size();
- File[] result = new File[numFiles];
- if (0 < numFiles) {
- files.copyInto(result);
- }
- return result;
- }
- }
|