DLESE Tools
v1.6.0

org.dlese.dpc.index.reader
Class DocReader

java.lang.Object
  extended by org.dlese.dpc.index.reader.DocReader
Direct Known Subclasses:
FileIndexingServiceDocReader, HarvestLogReader, SimpleDocReader, WebLogReader

public abstract class DocReader
extends Object

An abstract bean for accessing the data stored in the Lucene Documents that are returned from a search. All concrete DocReader classes must implement a default no-argument constructor so that they may be created automatically by the factory ResultDoc.getDocReader(). In addition, the index writer corresponding to the concrete reader must implement the DocWriter.getReaderClass() method.

Author:
John Weatherley
See Also:
SimpleLuceneIndex, ResultDoc

Field Summary
protected  ResultDocConfig conf
          The index that was searched over.
protected  org.apache.lucene.document.Document doc
          The Lucene Document that is being read.
protected  ResultDoc resultDoc
           
protected  float score
          The Lucene score assigned to the Document, or -1 if none available.
 
Constructor Summary
protected DocReader()
          Constructor that initializes an empty DocReader.
protected DocReader(org.apache.lucene.document.Document myDoc)
          Constructor that may be used programatically to wrap a reader around a Lucene Document that was created by a DocWriter.
 
Method Summary
 void doInit(org.apache.lucene.document.Document myDoc, ResultDoc resultDoc, float myScore, ResultDocConfig myConf)
          Called by ResultDoc at search time to initialize a new instance of a DocReader.
 Object getAttribute(String key)
          Gets an attribute that has been previously set using SimpleLuceneIndex.setAttribute(String,Object).
 DocumentMap getDocMap()
          Gets a DocumentMap of all field/values contained in the Lucene Document.
 org.apache.lucene.document.Document getDocument()
          Gets the Lucene Document associated with this DocReader.
 SimpleLuceneIndex getIndex()
          Gets the index that was searched over to produce the resulting hit.
 LazyDocumentMap getLazyDocMap()
          Gets a LazyDocumentMap of all field/values contained in the Lucene Document.
 String getQuery()
          Gets the query that was used in the search.
abstract  String getReaderType()
          Gets a String describing the reader type.
 RepositoryManager getRepositoryManager()
          Gets the RepositoryManager associated with this DocReader or null if not available.
 String getScore()
          Gets the Lucene score for the Document, or -1 if none available.
abstract  void init()
          An init method that may be used by concrete classes to initialize variables and resources as needed.
protected  void setDoc(org.apache.lucene.document.Document myDoc)
          Sets the Lucene Document that is being read by this DocReader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doc

protected org.apache.lucene.document.Document doc
The Lucene Document that is being read.


score

protected float score
The Lucene score assigned to the Document, or -1 if none available.


conf

protected ResultDocConfig conf
The index that was searched over.


resultDoc

protected ResultDoc resultDoc
Constructor Detail

DocReader

protected DocReader(org.apache.lucene.document.Document myDoc)
Constructor that may be used programatically to wrap a reader around a Lucene Document that was created by a DocWriter.

Parameters:
myDoc - Gets the Lucene Document that is being read by this DocReader.
See Also:
DocWriter

DocReader

protected DocReader()
Constructor that initializes an empty DocReader.

Method Detail

getReaderType

public abstract String getReaderType()
Gets a String describing the reader type. This may be used in (Struts) beans to determine which type of reader is available for a given search result and thus what data is available for display in the UI. The reader type implies which getter methods are available.

Returns:
The readerType value.

init

public abstract void init()
An init method that may be used by concrete classes to initialize variables and resources as needed.


doInit

public final void doInit(org.apache.lucene.document.Document myDoc,
                         ResultDoc resultDoc,
                         float myScore,
                         ResultDocConfig myConf)
Called by ResultDoc at search time to initialize a new instance of a DocReader.

Parameters:
myDoc - The Lucene Document
myScore - The Lucene score asigned to this hit
myConf - The config available to the doc reader

getDocMap

public DocumentMap getDocMap()
Gets a DocumentMap of all field/values contained in the Lucene Document. The text values in each field is stored in the Map as Strings. For example getDocMap.get("title") returns the text that was indexed and stored under the field name "title" for this Document.

Example that uses JSTL inside a JSP page (assumes result is an instance of ResultDoc):

The title is: ${result.docMap["title"]}

Returns:
A Map of all field/values contained in this Document, or null
See Also:
DocumentMap

getLazyDocMap

public LazyDocumentMap getLazyDocMap()
Gets a LazyDocumentMap of all field/values contained in the Lucene Document. The text values in each field is stored in the Map as Strings. For example getDocMap.get("title") returns the text that was indexed and stored under the field name "title" for this Document.

Example that uses JSTL inside a JSP page (assumes result is an instance of ResultDoc):

The title is: ${result.docMap["title"]}

Returns:
A Map of all field/values contained in this Document, or null
See Also:
DocumentMap

setDoc

protected void setDoc(org.apache.lucene.document.Document myDoc)
Sets the Lucene Document that is being read by this DocReader.

Parameters:
myDoc - The new doc value

getScore

public String getScore()
Gets the Lucene score for the Document, or -1 if none available.

Returns:
The score or -1 if not available.

getDocument

public org.apache.lucene.document.Document getDocument()
Gets the Lucene Document associated with this DocReader.

Returns:
A Lucene Document.

getIndex

public SimpleLuceneIndex getIndex()
Gets the index that was searched over to produce the resulting hit.

Returns:
The index.

getAttribute

public Object getAttribute(String key)
Gets an attribute that has been previously set using SimpleLuceneIndex.setAttribute(String,Object).

Parameters:
key - The key for the attribute
Returns:
The attruibute, or null if none exists under the given key
See Also:
SimpleLuceneIndex.setAttribute(String,Object)

getRepositoryManager

public RepositoryManager getRepositoryManager()
Gets the RepositoryManager associated with this DocReader or null if not available. Assumes the RepositoryManager has been set as attribute 'repositoryManager' in the SimpleLuceneIndex that was searched.

Returns:
The repositoryManager value

getQuery

public String getQuery()
Gets the query that was used in the search.

Returns:
The query value

DLESE Tools
v1.6.0