huber 2003/12/12 00:14:41
Modified: src/blocks/lucene/java/org/apache/cocoon/components/search
SimpleLuceneCocoonIndexerImpl.java
SimpleLuceneCocoonSearcherImpl.java
Log:
fix Bugzilla Bug 25277, use child.getValue
Revision Changes Path
1.4 +29 -49
cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/components/search/SimpleLuceneCocoonIndexerImpl.java
Index: SimpleLuceneCocoonIndexerImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/components/search/SimpleLuceneCocoonIndexerImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SimpleLuceneCocoonIndexerImpl.java 24 Mar 2003 14:33:54 -0000
1.3
+++ SimpleLuceneCocoonIndexerImpl.java 12 Dec 2003 08:14:41 -0000
1.4
@@ -90,51 +90,43 @@
{
/**
- *Description of the Field
- *
- * @since
+ * configuration tagname for specifying the analyzer class
*/
public final static String ANALYZER_CLASSNAME_CONFIG =
"analyzer-classname";
+
/**
- *Description of the Field
- *
- * @since
+ * configuration default analyzer class
*/
public final static String ANALYZER_CLASSNAME_DEFAULT =
"org.apache.lucene.analysis.standard.StandardAnalyzer";
/**
- *Description of the Field
- *
- * @since
+ * configuration tagname for specifying lucene's index directory
*/
public final static String DIRECTORY_CONFIG = "directory";
+
/**
- *Description of the Field
- *
- * @since
+ * configuration default directory, ie. no default.
*/
public final static String DIRECTORY_DEFAULT = null;
/**
- *Description of the Field
- *
- * @since
+ * configuration tagname for specifying lucene's merge factor.
*/
public final static String MERGE_FACTOR_CONFIG = "merge-factor";
/**
- *
http://www.mail-archive.com/[email protected]/msg00373.html
+ * configuration default value for lucene's merge factor.
+ *
+ * @see
http://www.mail-archive.com/[email protected]/msg00373.html
*/
public final static int MERGE_FACTOR_DEFAULT = 10;
/**
- * The component manager instance
- *
- * @since
+ * The component manager for looking up components used.
*/
protected ComponentManager manager = null;
- Analyzer analyzer;
+ protected Analyzer analyzer;
private String analyzerClassnameDefault = ANALYZER_CLASSNAME_DEFAULT;
private int mergeFactor = MERGE_FACTOR_DEFAULT;
@@ -143,7 +135,6 @@
*Sets the analyzer attribute of the SimpleLuceneCocoonIndexerImpl object
*
* @param analyzer The new analyzer value
- * @since
*/
public void setAnalyzer(Analyzer analyzer) {
this.analyzer = analyzer;
@@ -151,11 +142,10 @@
/**
- *Description of the Method
+ * Configure this component.
*
- * @param conf Description of Parameter
- * @exception ConfigurationException Description of Exception
- * @since
+ * @param conf is the configuration
+ * @exception ConfigurationException is thrown iff configuring fails
*/
public void configure(Configuration conf) throws ConfigurationException {
Configuration child;
@@ -163,14 +153,17 @@
child = conf.getChild(ANALYZER_CLASSNAME_CONFIG, false);
if (child != null) {
- value = conf.getValue(ANALYZER_CLASSNAME_DEFAULT);
+ // fix Bugzilla Bug 25277, use child.getValue
+ // and in all following blocks
+ value = child.getValue(ANALYZER_CLASSNAME_DEFAULT);
if (value != null) {
analyzerClassnameDefault = value;
}
}
child = conf.getChild(MERGE_FACTOR_CONFIG, false);
if (child != null) {
- int int_value = conf.getValueAsInteger(MERGE_FACTOR_DEFAULT);
+ // fix Bugzilla Bug 25277, use child instead of conf
+ int int_value = child.getValueAsInteger(MERGE_FACTOR_DEFAULT);
mergeFactor = int_value;
}
}
@@ -180,9 +173,8 @@
* Set the current <code>ComponentManager</code> instance used by this
* <code>Composable</code>.
*
- * @param manager Description of Parameter
- * @exception ComponentException Description of Exception
- * @since
+ * @param manager used by this component
+ * @exception ComponentException is never thrown
*/
public void compose(ComponentManager manager) throws ComponentException {
this.manager = manager;
@@ -190,9 +182,7 @@
/**
- *Description of the Method
- *
- * @since
+ * Dispose this component.
*/
public void dispose() { }
@@ -205,8 +195,7 @@
* update existing index.
* @param base_url index content of base_url, and crawl
through all its
* links recursivly.
- * @exception ProcessingException Description of Exception
- * @since
+ * @exception ProcessingException is thrown iff indexing fails
*/
public void index(Directory index, boolean create, URL base_url)
throws ProcessingException {
@@ -276,13 +265,11 @@
/**
- *Description of the Class
- *
- * @author huberb1
- * @version
+ * A document iterator deleting "old" documents form the index.
+ *
+ * TODO: use this class before indexing, in non-creating mode.
*/
- class DocumentDeletableIterator
- {
+ static class DocumentDeletableIterator {
private IndexReader reader;
// existing index
private TermEnum uidIter;
@@ -295,7 +282,6 @@
*
* @param directory Description of Parameter
* @exception IOException Description of Exception
- * @since
*/
public DocumentDeletableIterator(Directory directory) throws
IOException {
reader = IndexReader.open(directory);
@@ -309,7 +295,6 @@
*Description of the Method
*
* @exception IOException Description of Exception
- * @since
*/
public void deleteAllStaleDocuments() throws IOException {
while (uidIter.term() != null && uidIter.term().field() ==
"uid") {
@@ -324,7 +309,6 @@
*
* @param uid Description of Parameter
* @exception IOException Description of Exception
- * @since
*/
public void deleteModifiedDocuments(String uid) throws IOException {
while (documentHasBeenModified(uidIter.term(), uid)) {
@@ -341,7 +325,6 @@
*Description of the Method
*
* @exception Throwable Description of Exception
- * @since
*/
protected void finalize() throws Throwable {
super.finalize();
@@ -363,7 +346,6 @@
*
* @param term Description of Parameter
* @return Description of the Returned Value
- * @since
*/
boolean documentIsDeletable(Term term) {
return term != null && term.field() == "uid";
@@ -376,7 +358,6 @@
* @param term Description of Parameter
* @param uid Description of Parameter
* @return Description of the Returned Value
- * @since
*/
boolean documentHasBeenModified(Term term, String uid) {
return documentIsDeletable(term) &&
@@ -390,7 +371,6 @@
* @param term Description of Parameter
* @param uid Description of Parameter
* @return Description of the Returned Value
- * @since
*/
boolean documentHasNotBeenModified(Term term, String uid) {
return documentIsDeletable(term) &&
1.3 +26 -53
cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/components/search/SimpleLuceneCocoonSearcherImpl.java
Index: SimpleLuceneCocoonSearcherImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/components/search/SimpleLuceneCocoonSearcherImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SimpleLuceneCocoonSearcherImpl.java 11 Mar 2003 17:44:21 -0000
1.2
+++ SimpleLuceneCocoonSearcherImpl.java 12 Dec 2003 08:14:41 -0000
1.3
@@ -105,7 +105,6 @@
* <code>analyzer-classname</code>.
* </p>
*
- * @since
*/
protected final static String ANALYZER_CLASSNAME_CONFIG =
"analyzer-classname";
/**
@@ -115,7 +114,6 @@
* <code>org.apache.lucene.analysis.standard.StandardAnalyzer</code>.
* </p>
*
- * @since
*/
protected final static String ANALYZER_CLASSNAME_DEFAULT =
"org.apache.lucene.analysis.standard.StandardAnalyzer";
@@ -126,7 +124,6 @@
* <code>default-seach-field</code>.
* </p>
*
- * @since
*/
protected final static String DEFAULT_SEARCH_FIELD_CONFIG =
"default-search-field";
/**
@@ -135,7 +132,6 @@
* Its value is <code>body</code>.
* </p>
*
- * @since
*/
protected final static String DEFAULT_SEARCH_FIELD_DEFAULT = "body";
@@ -146,7 +142,6 @@
* <code>default-query</code>.
* </p>
*
- * @since
*/
protected final static String DEFAULT_QUERY_CONFIG = "default-query";
/**
@@ -155,7 +150,6 @@
* Its value is <code>null</code>.
* </p>
*
- * @since
*/
protected final static String DEFAULT_QUERY_DEFAULT = null;
@@ -166,7 +160,6 @@
* <code>queryparser-classname</code>.
* </p>
*
- * @since
*/
protected final static String QUERYPARSER_CLASSNAME_CONFIG =
"queryparser-classname";
/**
@@ -176,7 +169,6 @@
* <code>org.apache.lucene.queryParser.QueryParser</code>.
* </p>
*
- * @since
*/
protected final static String QUERYPARSER_CLASSNAME_DEFAULT =
"org.apache.lucene.queryParser.QueryParser";
@@ -187,7 +179,6 @@
* Its value is <code>directory</code>.
* </p>
*
- * @since
*/
protected final static String DIRECTORY_CONFIG = "directory";
/**
@@ -196,14 +187,12 @@
* Its value is <code>null</code>.
* </p>
*
- * @since
*/
protected final static String DIRECTORY_DEFAULT = null;
/**
* The component manager instance
*
- * @since
*/
protected ComponentManager manager = null;
@@ -236,7 +225,6 @@
* set an analyzer, overriding the analyzerClassnameDefault.
*
* @param analyzer The new analyzer value
- * @since
*/
public void setAnalyzer(Analyzer analyzer) {
this.analyzer = analyzer;
@@ -247,7 +235,6 @@
*Sets the directory attribute of the SimpleLuceneCocoonSearcherImpl
object
*
* @param directory The new directory value
- * @since
*/
public void setDirectory(Directory directory) {
this.directory = directory;
@@ -266,8 +253,8 @@
* </p>
*
* @return IndexReader an up to date indexReader
- * @exception IOException Description of Exception
- * @since
+ * @exception IOException is thrown iff it's impossible to create
+ * an IndexReader
*/
public IndexReader getReader() throws IOException {
if (indexReaderCache == null) {
@@ -278,11 +265,11 @@
/**
- * configure
+ * configure this component
*
- * @param conf Description of Parameter
- * @exception ConfigurationException Description of Exception
- * @since
+ * @param conf of this component
+ * @exception ConfigurationException is thrown iff configuration of
+ * this component fails
*/
public void configure(Configuration conf) throws ConfigurationException {
Configuration child;
@@ -290,7 +277,9 @@
child = conf.getChild(ANALYZER_CLASSNAME_CONFIG, false);
if (child != null) {
- value = conf.getValue(ANALYZER_CLASSNAME_DEFAULT);
+ // fix Bugzilla Bug 25277, use child.getValue
+ // and in all following blocks
+ value = child.getValue(ANALYZER_CLASSNAME_DEFAULT);
if (value != null) {
analyzerClassnameDefault = value;
try {
@@ -304,7 +293,7 @@
child = conf.getChild(DEFAULT_SEARCH_FIELD_CONFIG, false);
if (child != null) {
- value = conf.getValue(DEFAULT_SEARCH_FIELD_DEFAULT);
+ value = child.getValue(DEFAULT_SEARCH_FIELD_DEFAULT);
if (value != null) {
defaultSearchFieldDefault = value;
}
@@ -312,7 +301,7 @@
child = conf.getChild(DEFAULT_QUERY_CONFIG, false);
if (child != null) {
- value = conf.getValue(DEFAULT_QUERY_DEFAULT);
+ value = child.getValue(DEFAULT_QUERY_DEFAULT);
if (value != null) {
defaultQueryDefault = value;
}
@@ -320,7 +309,7 @@
child = conf.getChild(QUERYPARSER_CLASSNAME_CONFIG, false);
if (child != null) {
- value = conf.getValue(QUERYPARSER_CLASSNAME_DEFAULT);
+ value = child.getValue(QUERYPARSER_CLASSNAME_DEFAULT);
if (value != null) {
queryparserClassnameDefault = value;
}
@@ -328,7 +317,7 @@
child = conf.getChild(DIRECTORY_CONFIG, false);
if (child != null) {
- value = conf.getValue(DIRECTORY_DEFAULT);
+ value = child.getValue(DIRECTORY_DEFAULT);
if (value != null) {
directoryDefault = value;
try {
@@ -345,9 +334,8 @@
* Set the current <code>ComponentManager</code> instance used by this
* <code>Composable</code>.
*
- * @param manager Description of Parameter
- * @exception ComponentException Description of Exception
- * @since
+ * @param manager of this component
+ * @exception ComponentException is never thrown
*/
public void compose(ComponentManager manager) throws ComponentException {
this.manager = manager;
@@ -355,9 +343,7 @@
/**
- *Description of the Method
- *
- * @since
+ * Dispose this component, releasing IndexSearcher, and IndexReaderCache.
*/
public void dispose() {
releaseIndexSearcher();
@@ -366,9 +352,7 @@
/**
- *Description of the Method
- *
- * @since
+ * Recycle this component, releasing IndexSearcher, and IndexReaderCache.
*/
public void recycle() {
releaseIndexSearcher();
@@ -377,13 +361,12 @@
/**
- *Description of the Method
+ * Search lucene index.
*
- * @param query_string Description of Parameter
- * @param default_field Description of Parameter
- * @return Description of the Returned Value
- * @exception ProcessingException Description of Exception
- * @since
+ * @param query_string is lucene's query string
+ * @param default_field the lucene field to run the query
+ * @return lucene Hits
+ * @exception ProcessingException iff its not possible do run the query
*/
public Hits search(String query_string, String default_field) throws
ProcessingException {
Hits hits = null;
@@ -415,9 +398,8 @@
/**
- *Description of the Method
+ * Release the index searcher.
*
- * @since
*/
private void releaseIndexSearcher() {
if (indexSearcher != null) {
@@ -432,9 +414,8 @@
/**
- *Description of the Method
+ * Release the IndexReaderCache
*
- * @since
*/
private void releaseIndexReaderCache() {
if (indexReaderCache != null) {
@@ -446,10 +427,8 @@
/**
* This class should help to minimise usage of IndexReaders.
*
- * @author huberb1
- * @version
*/
- static class IndexReaderCache
+ static class IndexReaderCache
{
private IndexReader indexReader;
private long lastModified;
@@ -458,7 +437,6 @@
/**
* Create an IndexReaderCache.
*
- * @since
*/
IndexReaderCache() { }
@@ -468,7 +446,6 @@
*
* @param directory lucene index directory
* @return The indexReader value
- * @since
*/
public IndexReader getIndexReader(Directory directory) throws
IOException {
if (indexReader == null) {
@@ -485,7 +462,6 @@
/**
* Close an opened lucene IndexReader
*
- * @since
*/
public void close() {
if (indexReader != null) {
@@ -507,7 +483,6 @@
* and its lastModified date is greater equal than the
lastModified date
* of its lucene Directory.
* @exception IOException Description of Exception
- * @since
*/
public boolean indexReaderIsValid(Directory directory) throws
IOException {
return indexReader != null &&
@@ -519,7 +494,6 @@
* Release all resources, most notably the lucene IndexReader.
*
* @exception Throwable Description of Exception
- * @since
*/
protected void finalize() throws Throwable {
close();
@@ -531,7 +505,6 @@
*
* @param directory lucene index directory
* @exception IOException Description of Exception
- * @since
*/
private void createIndexReader(Directory directory) throws
IOException {
close();