From: <sim...@us...> - 2002-07-29 07:23:49
|
Update of /cvsroot/cdchamber/CDChamber/src/org/cdchamber/searcher In directory usw-pr-cvs1:/tmp/cvs-serv32053/src/org/cdchamber/searcher Modified Files: Searcher.java Added Files: SearchResult.java Log Message: Select on search result will be reflect on the jlist --- NEW FILE: SearchResult.java --- /* * User: Simon * $Id: SearchResult.java,v 1.1 2002/07/29 07:23:43 simon_lei Exp $ */ package org.cdchamber.searcher; import org.cdchamber.elements.FileType; import java.util.Vector; public class SearchResult { private Vector resultPath = new Vector(); public SearchResult( SearchResult result, FileType fileType) { resultPath.addAll( result.resultPath); resultPath.addElement( fileType); } public SearchResult( FileType fileType) { resultPath.addElement( fileType); } public SearchResult() { } public int getPathDepth() { return resultPath.size(); } public FileType getFileAt( int i) { return (FileType) resultPath.elementAt(i); } public String toString() { StringBuffer strBuff = new StringBuffer(); for (int i = 0; i < resultPath.size(); i++) { strBuff.append( "/"); FileType fileType = (FileType) resultPath.elementAt(i); strBuff.append( fileType.getName()); } return strBuff.toString(); } } Index: Searcher.java =================================================================== RCS file: /cvsroot/cdchamber/CDChamber/src/org/cdchamber/searcher/Searcher.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Searcher.java 26 Jul 2002 09:19:18 -0000 1.6 --- Searcher.java 29 Jul 2002 07:23:43 -0000 1.7 *************** *** 26,29 **** --- 26,34 ---- public Vector search(FileType[] fileTypes) { + SearchResult searchResult = new SearchResult(); + return search( fileTypes, searchResult); + + } + public Vector search( FileType[] fileTypes, SearchResult searchResult) { Vector result = new Vector(); if ( queries.size() == 0) return result; *************** *** 34,41 **** if ( !query.isMatched( fileTypes[i])) matched=false; } ! if ( matched) result.add( fileTypes[i]); if ( fileTypes[i] instanceof DirectoryType) { DirectoryType dir = (DirectoryType) fileTypes[i]; ! result.addAll( search( dir.getFiles())); } } --- 39,46 ---- if ( !query.isMatched( fileTypes[i])) matched=false; } ! if ( matched) result.add( new SearchResult( searchResult, fileTypes[i])); if ( fileTypes[i] instanceof DirectoryType) { DirectoryType dir = (DirectoryType) fileTypes[i]; ! result.addAll( search( dir.getFiles(), new SearchResult( searchResult, dir))); } } *************** *** 43,46 **** return result; } - } --- 48,50 ---- |