File sf = new File(stopwordFile);  if (!sf.canRead()) { stopwordFile = dbHome + File.separatorChar + stopwordFile; sf = new File(stopwordFile); }
File sf = lookup(stopwordFile);
    private void configureIndexer(String dbHome, Document doc, NodeList indexer) throws DatabaseConfigurationException, MalformedURLException {                Element p = (Element) indexer.item(0);        String parseNum = p.getAttribute("parseNumbers");        String indexDepth = p.getAttribute("index-depth");        String stemming = p.getAttribute("stemming");        String termFreq = p.getAttribute("track-term-freq");        String suppressWS = p.getAttribute("suppress-whitespace");        String caseSensitive = p.getAttribute("caseSensitive");        String tokenizer = p.getAttribute("tokenizer");        String validation = p.getAttribute("validation");        String suppressWSmixed = p                .getAttribute("preserve-whitespace-mixed-content");        if (parseNum != null)            config.put("indexer.indexNumbers", Boolean.valueOf(parseNum                    .equals("yes")));        if (stemming != null)            config.put("indexer.stem", Boolean.valueOf(stemming                    .equals("yes")));        if (termFreq != null)            config.put("indexer.store-term-freq", Boolean                    .valueOf(termFreq.equals("yes")));        if (caseSensitive != null)            config.put("indexer.case-sensitive", Boolean                    .valueOf(caseSensitive.equals("yes")));        if (suppressWS != null)            config.put("indexer.suppress-whitespace", suppressWS);        if (validation != null)            config.put("indexer.validation", validation);        if (tokenizer != null)            config.put("indexer.tokenizer", tokenizer);        if (indexDepth != null)            try {                int depth = Integer.parseInt(indexDepth);                config.put("indexer.index-depth", new Integer(depth));            } catch (NumberFormatException e) {            }        if (suppressWSmixed != null)            config.put("indexer.preserve-whitespace-mixed-content",                    Boolean.valueOf(suppressWSmixed.equals("yes")));        // index settings        NodeList cl = doc.getElementsByTagName("index");        if (cl.getLength() > 0) {            Element elem = (Element) cl.item(0);            IndexSpec spec = new IndexSpec(elem);            config.put("indexer.config", spec);        }        // stopwords        NodeList stopwords = p.getElementsByTagName("stopwords");        if (stopwords.getLength() > 0) {            String stopwordFile = ((Element) stopwords.item(0))            .getAttribute("file");            File sf = new File(stopwordFile);                        if (!sf.canRead()) {                stopwordFile = dbHome + File.separatorChar + stopwordFile;                sf = new File(stopwordFile);            }            if (sf.canRead())                config.put("stopwords", stopwordFile);        }                eXistCatalogResolver resolver = (eXistCatalogResolver) config.get("resolver");        NodeList entityResolver = p.getElementsByTagName("entity-resolver");                if (entityResolver.getLength() > 0) {            Element r = (Element) entityResolver.item(0);            NodeList catalogs = r.getElementsByTagName("catalog");                        // TODO remove. log function does not work yet            System.out.println("Found "+catalogs.getLength()+" catalog entries.");                        for (int i = 0; i < catalogs.getLength(); i++) {                String catalog = ((Element) catalogs.item(i)).getAttribute("file");                                           File catalogFile=null;                if (dbHome == null)                    catalogFile = new File(catalog);                else                    catalogFile = new File(dbHome, catalog);                                if (catalogFile!=null && catalogFile.exists()) {                    LOG.info("Loading catalog '"+catalogFile.getAbsolutePath()+"'.");                    // TODO dizzzz remove debug                    //System.out.println("Loading catalog '"+catalogFile.getAbsolutePath()+"'.");                    try {                        resolver.getCatalog()                                .parseCatalog( catalogFile.getAbsolutePath() );                                            } catch (IOException e) {                        String message = "An exception occurred while reading catalog: "                                 + catalogFile.getAbsolutePath() + ": "                                 + e.getMessage();                                                LOG.warn(message, e);                        System.out.println(message);                    }                } else {                    String message ="Could not load catalog '"                                           +catalogFile.getAbsolutePath()+"'.";                    LOG.debug(message);                    System.out.println(message);                }            }        }    }