dragon.onlinedb
Class BasicCollectionReader

java.lang.Object
  |
  +--dragon.onlinedb.BasicCollectionReader
All Implemented Interfaces:
CollectionReader

public class BasicCollectionReader
extends java.lang.Object
implements CollectionReader

Basic collection reader (supporting class for indexing)

Copyright: Copyright (c) 2005

Company: IST, Drexel University

Version:
1.0
Author:
Davis Zhou

Field Summary
protected  java.io.BufferedReader br
           
protected  java.lang.String collectionFile
           
protected  java.lang.String indexFile
           
protected  BasicArticleIndex indexList
           
protected  ArticleParser parser
           
protected  java.io.RandomAccessFile raf
           
 
Constructor Summary
BasicCollectionReader()
           
BasicCollectionReader(java.lang.String collectionFile)
           
BasicCollectionReader(java.lang.String collectionFile, java.lang.String indexFile)
           
BasicCollectionReader(java.lang.String collectionFile, java.lang.String indexFile, ArticleParser parser)
           
 
Method Summary
 void close()
          Closes the collection reader and releases all occupied resources.
 Article getArticleByKey(java.lang.String key)
          Reads out the article according to its key
 ArticleParser getArticleParser()
          Gets the article parser of the collection reader
 Article getNextArticle()
          Collection readers only support forward-only read mode.
 boolean loadCollection(java.lang.String collectionFile, java.lang.String indexFile)
           
 void restart()
          The collection reader supports forward-only read mode.
 void setArticleParser(ArticleParser parser)
          Sets the article parse for the collection reader
 boolean supportArticleKeyRetrieval()
          if the query supports this retrieval mode, one can get articles by calling getArticleByKey method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

protected ArticleParser parser

br

protected java.io.BufferedReader br

indexList

protected BasicArticleIndex indexList

raf

protected java.io.RandomAccessFile raf

collectionFile

protected java.lang.String collectionFile

indexFile

protected java.lang.String indexFile
Constructor Detail

BasicCollectionReader

public BasicCollectionReader()

BasicCollectionReader

public BasicCollectionReader(java.lang.String collectionFile)

BasicCollectionReader

public BasicCollectionReader(java.lang.String collectionFile,
                             java.lang.String indexFile)

BasicCollectionReader

public BasicCollectionReader(java.lang.String collectionFile,
                             java.lang.String indexFile,
                             ArticleParser parser)
Method Detail

loadCollection

public boolean loadCollection(java.lang.String collectionFile,
                              java.lang.String indexFile)

getArticleParser

public ArticleParser getArticleParser()
Description copied from interface: CollectionReader
Gets the article parser of the collection reader

Specified by:
getArticleParser in interface CollectionReader
Returns:
the article parser

setArticleParser

public void setArticleParser(ArticleParser parser)
Description copied from interface: CollectionReader
Sets the article parse for the collection reader

Specified by:
setArticleParser in interface CollectionReader
Parameters:
parser - the article parser

getArticleByKey

public Article getArticleByKey(java.lang.String key)
Description copied from interface: CollectionReader
Reads out the article according to its key

Specified by:
getArticleByKey in interface CollectionReader
Parameters:
key - the unique entry number of the article
Returns:
an article if exists

getNextArticle

public Article getNextArticle()
Description copied from interface: CollectionReader
Collection readers only support forward-only read mode. When one call this method after calling restart method or creating the collection reader, it actually return the first article of the collection.

Specified by:
getNextArticle in interface CollectionReader
Returns:
the next article

close

public void close()
Description copied from interface: CollectionReader
Closes the collection reader and releases all occupied resources.

Specified by:
close in interface CollectionReader

supportArticleKeyRetrieval

public boolean supportArticleKeyRetrieval()
Description copied from interface: CollectionReader
if the query supports this retrieval mode, one can get articles by calling getArticleByKey method.

Specified by:
supportArticleKeyRetrieval in interface CollectionReader
Returns:
true if the query support the article retrieval by key.

restart

public void restart()
Description copied from interface: CollectionReader
The collection reader supports forward-only read mode. If one wants to scan the collection for the second time, it is required to call this method. Otherwise when one getNextArticle method, it always return null.

Specified by:
restart in interface CollectionReader