import EDU.neu.ccs.demeter.dj.*; import com.objectspace.jgl.*; public class Visitor_FIND extends Visitor { public String name; public String path; public Stack prev_path; int num_found; Visitor_FIND( String new_name ) { name = new_name; } public void start() { prev_path = new Stack(); path = " "; num_found = 0; System.out.println(" "); System.out.println("Searching for files with the name "+name); } public void finish() { if ( num_found == 0 ) System.out.println("None files has been found"); } public void before( Directory host ) { prev_path.push( new String(path) ); path = path + host.get_name() + "/"; } public void after( Directory host ) { path = (String)prev_path.pop(); } public void before( File host ) { if ( host.get_name().equals( name ) ) { if ( num_found == 0 ) System.out.println(" The following files have been found:"); num_found++; System.out.println( " " + path + host.get_name() ); } } }