/** * Construct a new instance and configure it. * * @param broker * @param conf */ public TextSearchEngine(DBBroker broker, Configuration conf) { this.broker = broker; this.config = conf; String stopword, tokenizerClass; Boolean num, stemming, termFrequencies; if ((num = (Boolean) config.getProperty(PROPERTY_INDEX_NUMBERS)) != null) indexNumbers = num.booleanValue(); if ((stemming = (Boolean) config.getProperty(PROPERTY_STEM)) != null) stem = stemming.booleanValue(); if ((termFrequencies = (Boolean) config.getProperty(PROPERTY_STORE_TERM_FREQUENCY)) != null) termFreq = termFrequencies.booleanValue(); String track = (String) config.getProperty(Serializer.PROPERTY_TAG_MATCHING_ELEMENTS); if (track != null) trackMatches = track.equalsIgnoreCase("yes") ? Serializer.TAG_ELEMENT_MATCHES : Serializer.TAG_NONE; track = (String) config.getProperty(Serializer.PROPERTY_TAG_MATCHING_ATTRIBUTES); if (track != null && track.equalsIgnoreCase("yes")) trackMatches = trackMatches | Serializer.TAG_ATTRIBUTE_MATCHES; if ((tokenizerClass = (String) config.getProperty(PROPERTY_TOKENIZER)) != null) { try { Class tokClass = Class.forName(tokenizerClass); tokenizer = (Tokenizer) tokClass.newInstance(); LOG.debug("using tokenizer: " + tokenizerClass); } catch (ClassNotFoundException e) { LOG.debug(e); } catch (InstantiationException e) { LOG.debug(e); } catch (IllegalAccessException e) { LOG.debug(e); } } if (tokenizer == null) { LOG.debug("using simple tokenizer"); tokenizer = new SimpleTokenizer(); } if (stem) stemmer = new PorterStemmer(); tokenizer.setStemming(stem); if ((stopword = (String) config.getProperty(PROPERTY_STOPWORD_FILE)) != null) { try { FileReader in = new FileReader(stopword); StreamTokenizer tok = new StreamTokenizer(in); int next = tok.nextToken(); while (next != StreamTokenizer.TT_EOF) { if (next != StreamTokenizer.TT_WORD) continue; stoplist.add(tok.sval); next = tok.nextToken(); } } catch (FileNotFoundException e) { LOG.debug(e); } catch (IOException e) { LOG.debug(e); } } }
/** Constructor for XUpdateProcessor. */ public XUpdateProcessor(DBBroker broker, DocumentSet docs, AccessContext accessCtx) throws ParserConfigurationException { if (accessCtx == null) { throw new NullAccessContextException(); } this.accessCtx = accessCtx; final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); this.builder = factory.newDocumentBuilder(); this.broker = broker; this.documentSet = docs; // namespaces.put("xml", Namespaces.XML_NS); // TODO : move this to a dedicated configure() method. if (broker != null) { final Configuration config = broker.getConfiguration(); Boolean temp; if ((temp = (Boolean) config.getProperty("indexer.preserve-whitespace-mixed-content")) != null) { preserveWhitespaceTemp = temp.booleanValue(); } } }
/** * Setup Validator object with brokerpool as db connection. * * @param pool Brokerpool */ public Validator(BrokerPool pool) { logger.info("Initializing Validator."); if (brokerPool == null) { this.brokerPool = pool; } // Get configuration config = brokerPool.getConfiguration(); // Check xerces version StringBuilder xmlLibMessage = new StringBuilder(); if (!XmlLibraryChecker.hasValidParser(xmlLibMessage)) { logger.error(xmlLibMessage); } // setup grammar brokerPool grammarPool = (GrammarPool) config.getProperty(XMLReaderObjectFactory.GRAMMER_POOL); // setup system wide catalog resolver systemCatalogResolver = (eXistXMLCatalogResolver) config.getProperty(XMLReaderObjectFactory.CATALOG_RESOLVER); }
public void configure(Configuration config, Properties properties) throws EXistException { exportDir = properties.getProperty(OUTPUT_PROP_NAME, "export"); File dir = new File(exportDir); if (!dir.isAbsolute()) { dir = new File((String) config.getProperty(BrokerPool.PROPERTY_DATA_DIR), exportDir); } dir.mkdirs(); exportDir = dir.getAbsolutePath(); if (LOG.isDebugEnabled()) { LOG.debug("Using output directory " + exportDir); } final String backup = properties.getProperty(BACKUP_PROP_NAME, "no"); createBackup = backup.equalsIgnoreCase("YES"); final String zip = properties.getProperty(ZIP_PROP_NAME, "yes"); createZip = zip.equalsIgnoreCase("YES"); final String inc = properties.getProperty(INCREMENTAL_PROP_NAME, "no"); incremental = inc.equalsIgnoreCase("YES"); final String incCheck = properties.getProperty(INCREMENTAL_CHECK_PROP_NAME, "yes"); incrementalCheck = incCheck.equalsIgnoreCase("YES"); final String max = properties.getProperty(MAX_PROP_NAME, "5"); try { maxInc = Integer.parseInt(max); } catch (final NumberFormatException e) { throw new EXistException("Parameter 'max' has to be an integer"); } final String check = properties.getProperty(CHECK_DOCS_PROP_NAME, "no"); checkDocs = check.equalsIgnoreCase("YES"); }