commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32450] - [io] Add cancel() to Finder
Date Thu, 31 Mar 2005 18:45:39 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32450>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32450





------- Additional Comments From gaxzerow@gmail.com  2005-03-31 20:45 -------
on way to work around this problem is to us a CancellingListener

CancelingListener implements FindListener extends RuntimeException{
    boolean cancelled = false;
    public void fileFound(FindEvent fe) { check(); }
    public void directoryStarted(FindEvent fe) { check(); }
    public void directoryFinished(FindEvent fe) { check(); }
    private void check() {
        if(cancelled)
           throw this;
    }
    public void doCancel(){
        cancelled = true;
    }
}

and in you find call
---------------------
CancelingListener clistener = new CancelingListener();
try{
    finder.addListener(clistener);
    find(dir);
}catch(CancelingListener cl){
    // find() was cancelled when another thread
    // or listener calls clistener.doCancel();
}
---------------------

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message