for (int i = 0; i < hits.length(); i++)
if( args.getStart() < hits.length() )
    public static synchronized HashMap doQuery(Context c, String querystring)        throws IOException    {        querystring = checkEmptyQuery( querystring );        querystring = workAroundLuceneBug( querystring );        querystring = stripHandles( querystring );                                ArrayList resultlist= new ArrayList();        ArrayList itemlist 	= new ArrayList();        ArrayList commlist 	= new ArrayList();        ArrayList colllist 	= new ArrayList();        HashMap   metahash 	= new HashMap();        // initial results are empty        metahash.put(ALL,       resultlist);        metahash.put(ITEM,      itemlist  );        metahash.put(COLLECTION,colllist  );        metahash.put(COMMUNITY, commlist  );        try        {            IndexSearcher searcher = new IndexSearcher(                ConfigurationManager.getProperty("search.dir"));            QueryParser qp = new QueryParser("default", new DSAnalyzer());            Query myquery = qp.parse(querystring);            Hits hits = searcher.search(myquery);            for (int i = 0; i < hits.length(); i++)            {                Document d = hits.doc(i);                String handletext = d.get("handle");                String handletype = d.get("type");                                resultlist.add(handletext);                                if (handletype.equals(ITEM))                 {                 	itemlist.add(handletext);                 }                 else if (handletype.equals(COLLECTION))                {                    colllist.add(handletext);                }                else if (handletype.equals(COMMUNITY))                {	                    commlist.add(handletext); break;                }            }            // close the IndexSearcher - and all its filehandles            searcher.close();            // store all of the different types of hits in the hash                        metahash.put(ALL,       resultlist);            metahash.put(ITEM,      itemlist  );            metahash.put(COLLECTION,colllist  );            metahash.put(COMMUNITY, commlist  );        }        catch (NumberFormatException e)        {            // a bad parse means that there are no results            // doing nothing with the exception gets you            //   throw new SQLException( "Error parsing search results: " + e );            // ?? quit?        }        catch (ParseException e)        {            // a parse exception - log and return null results            log.warn(LogManager.getHeader(c,                "Lucene Parse Exception",                "" + e));        }        return metahash;    }