public void apply(Map req, Writer out) {
public synchronized void apply(Map req, Writer out) {
        public void apply(Map req, Writer out) {            // create page            String pagename = "search-page";            URI uri = Location.makeURI(pagename + ".html");            String destinationFrame = SELF_FRAME;            String title = pagename;                        final Page page = new Page(out, uri, destinationFrame,                                       title, representation,                                       HTMLGenerator.this.adaptURI(Location.mkURI(HTMLPrinter.DEFAULT_STYLESHEET),                                                                   uri).toString(),                                       HTMLGenerator.this.adaptURI(Location.mkURI(HTMLPrinter.DEFAULT_JAVASCRIPT),                                                                   uri).toString());            page.open();            page.printHeader(ATTRS_META, getGenerator());            page.printOpenBody();            addNavigationBar(CONTAINER_NAV_CONTEXT, page);            page.printlnHLine();            // create symbol printer                        final MySymbolTablePrinter symtab =                SymbolTablePrinterFactory.makeHTML(HTMLGenerator.this, page, isDocumented);            // analyze the request            String searchKind = (String) req.get("searchKind");            String searchString = (String) req.get("searchString");            // search summary            String searchKindSummary = null;            if (searchKind.equals("byName"))                searchKindSummary = "in defined names";            else if (searchKind.equals("byComment"))                searchKindSummary = "in comments";            else if (searchKind.equals("byType"))                searchKindSummary = "by type";                       String searchSummary =                "Scaladoc searched for the string (" + searchString + ") " + searchKindSummary + ".";            page.printOTag("p");            page.printOTag("b");            page.print(searchSummary);            page.printCTag("b");            page.printCTag("p");            // Search by name.            if (searchKind.equals("byName")) {                String regexp = searchString;                final Pattern p = Pattern.compile(regexp);                final List found = new LinkedList();                //collect                ScalaSearch.foreach(global.definitions.ROOT_CLASS,                                    new ScalaSearch.SymFun() {                                        public void apply(Symbol sym) {                                            String name = sym.nameString();                                            Matcher m = p.matcher(name);                                            if (m.find())                                                found.add(sym);                                        }                                    },                                    isDocumented);                addResultNumber(found.size(), page);                addFoundSymbols(found, page, symtab);            }            // Search by comment.            else if (searchKind.equals("byComment")) {                String regexp = searchString;                final Pattern p = Pattern.compile(regexp);                                final List found = new LinkedList();                ScalaSearch.foreach(global.definitions.ROOT_CLASS,                                    new ScalaSearch.SymFun() {                                        public void apply(Symbol sym) {                                            Pair c = (Pair) global.mapSymbolComment.get(sym);                                            if (c != null) {                                                String comment = (String) c.fst;                                                Matcher m = p.matcher(comment);                                                if (m.find())                                                    found.add(sym);                                            }                                        }                                    },                                    isDocumented);                addResultNumber(found.size(), page);                addFoundSymbols(found, page, symtab);            }            // Search by type.            else if (searchKind.equals("byType")) {                Type t = ScalaSearch.typeOfString(searchString, global);                TypeIsomorphism ml = newTypeIso(global);                                List found = new LinkedList();                Map searchResults = new HashMap();                Iterator it = ml.searchType(t, isDocumented);                while (it.hasNext()) {                    SearchResult result = (SearchResult) it.next();                    found.add(result.symbol);                    searchResults.put(result.symbol, result);                }                if (t == Type.NoType) {                    page.printOTag("p");                    page.println("Scaladoc could not recognize your search string as a type, "                                 + "see the ");                    page.printlnTag("a",                                    new XMLAttribute[] {                                        new XMLAttribute("href", HELP_PAGE + "#" + SEARCH_SECTION) },                                    "help page");                    page.println(" to know which syntax to use.");                    page.printCTag("p");                }                else {                    page.printOTag("p");                    page.print("You are searching for symbols with type: ");                    page.print(t.toString());                    page.printCTag("p");                                        addResultNumber(found.size(), page);                                        Symbol[] sortedSymbols = ScalaSearch.sortList(found);                                        for(int i = 0; i < sortedSymbols.length; i++) {                        Symbol sym = sortedSymbols[i];                        SearchResult result = (SearchResult) searchResults.get(sym);                        Type adaptedType = result.getType;                        page.printOTag("dt");                        //page.printOTag("code");                        symtab.printShortSignature(sym, true);                        symtab.printSeqType(sym, adaptedType, symtab.getSymbolInnerString(sym));                        page.printlnCTag("dt");                        if (!sym.isRoot()) {                            page.printOTag("dd");                            page.print("in ");                            printPath(sym.owner(), SELF_FRAME, page);                            if (result.isInClass && (result.tparams.length > 0)) {                                page.print("[");                                for(int j = 0; j < result.tparams.length; j++) {                                    if (j != 0) page.print(",");                                    page.print(result.tparams[j].nameString());                                }                                page.print("]");                            }                            page.printCTag("dd");                        }                        String firstSent = firstSentence(getComment(sym));                        if (!firstSent.equals(""))                            page.printlnTag("dd", firstSent);                         //page.printlnCTag("code");                    }                }            }            // close page            page.printlnHLine();            addNavigationBar(CONTAINER_NAV_CONTEXT, page);            page.printFootpage();            // page.close();            // already done by the HTTP server when closing connection        }