/** Start the search with the loaded terms. */ public void doSearch() { try { /* Start timing */ timer.start(); /* Start a new desktop query */ JGDQuery jgdQuery = new JGDQuery(query); /* Limit the number of results */ jgdQuery.setNum(maxResults); /* Filter by files only */ jgdQuery.setFilterByFiles(); /* Execute the jgdQuery */ Results jgdResults = jgdQuery.execute(); /* Get the result */ List<?> l = jgdResults.getResult(); for (Object jdgResult : l) { GoogleDesktopFile googleDesktopFile = (GoogleDesktopFile) jdgResult; /* Create a new file object from the result */ File file = new File(googleDesktopFile.get_uri()); /* If this fails, skip it */ if (file == null) { continue; } log.info("Local result found: " + file.toString()); Resource resource = new Resource(); resource.setArticle(new FileArticle()); resource.setData(new FileData(file)); /* Add to total results with extended data */ results.put(file.toURI(), resource); } } catch (Exception e) { log.error(e.getMessage(), e); } catch (UnsatisfiedLinkError ule) { log.error(ule.getMessage(), ule); } catch (NoClassDefFoundError ncdefe) { log.error(ncdefe.getMessage(), ncdefe); } /* Stop timing */ timer.stop(); }
/** * Returns how long the search took in milliseconds . * * @return The time in milliseconds. */ public long getSearchTime() { return timer.toValue(); }