dragon.onlinedb
Class AbstractQuery

java.lang.Object
  |
  +--dragon.onlinedb.AbstractQuery
All Implemented Interfaces:
ArticleQuery, CollectionReader
Direct Known Subclasses:
AbstractSearchEngine, AmazonCatalogQuery, AmazonReviewQuery, CiteULikeTagQuery, PubMedQuery

public abstract class AbstractQuery
extends java.lang.Object
implements ArticleQuery

Abstract class for querying articles from a data source

Copyright: Copyright (c) 2005

Company: IST, Drexel University

Version:
1.0
Author:
Davis Zhou

Field Summary
protected  int articleNum
           
protected  Article curArticle
           
protected  int curArticleNo
           
protected  int curPageNo
           
protected  int curPageWidth
           
protected  int pageNum
           
protected  int pageWidth
           
protected  ArticleParser parser
           
 
Constructor Summary
AbstractQuery(int pageWidth)
           
 
Method Summary
 void close()
          Closes the collection reader and releases all occupied resources.
 Article getArticle()
          read out the article the current pointer points to.
protected abstract  Article getArticle(int articleNo)
           
 java.lang.String getArticleKey()
          In some cases, retrieval of an article is very expensive.
 ArticleParser getArticleParser()
          Gets the article parser of the collection reader
 int getCurPageNo()
           
 int getCurPageWidth()
           
 Article getNextArticle()
          Collection readers only support forward-only read mode.
 int getPageNum()
           
 int getPageWidth()
           
 int getTotalArticleNum()
           
 boolean loadCollection(java.lang.String collectionPath, java.lang.String collectionName)
           
 boolean moveToArticle(int paperNo)
          Move the pointer to the give position of the current page.
 boolean moveToNextArticle()
          The pointer will be set on the next article.
 boolean moveToNextPage()
          Move to the next page and the pointer is set on the first article of the page.
 void restart()
          The collection reader supports forward-only read mode.
 void setArticleParser(ArticleParser parser)
          Sets the article parse for the collection reader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dragon.onlinedb.ArticleQuery
initQuery, moveToPage, setSearchTerm
 
Methods inherited from interface dragon.onlinedb.CollectionReader
getArticleByKey, supportArticleKeyRetrieval
 

Field Detail

curPageNo

protected int curPageNo

curArticleNo

protected int curArticleNo

pageNum

protected int pageNum

articleNum

protected int articleNum

pageWidth

protected int pageWidth

curPageWidth

protected int curPageWidth

curArticle

protected Article curArticle

parser

protected ArticleParser parser
Constructor Detail

AbstractQuery

public AbstractQuery(int pageWidth)
Method Detail

getArticle

protected abstract Article getArticle(int articleNo)

getCurPageNo

public int getCurPageNo()
Specified by:
getCurPageNo in interface ArticleQuery

moveToNextPage

public boolean moveToNextPage()
Description copied from interface: ArticleQuery
Move to the next page and the pointer is set on the first article of the page.

Specified by:
moveToNextPage in interface ArticleQuery
Returns:
false if it reached the last page already.

getTotalArticleNum

public int getTotalArticleNum()
Specified by:
getTotalArticleNum in interface ArticleQuery

getPageNum

public int getPageNum()
Specified by:
getPageNum in interface ArticleQuery

getPageWidth

public int getPageWidth()
Specified by:
getPageWidth in interface ArticleQuery

getCurPageWidth

public int getCurPageWidth()
Specified by:
getCurPageWidth in interface ArticleQuery
Returns:
number of papers in the current page.

moveToNextArticle

public boolean moveToNextArticle()
Description copied from interface: ArticleQuery
The pointer will be set on the next article. After call the method of initQuery, one should call this method before you call getArticle to get the first article.

Specified by:
moveToNextArticle in interface ArticleQuery
Returns:
true if the current pointer is not on the last article.

moveToArticle

public boolean moveToArticle(int paperNo)
Description copied from interface: ArticleQuery
Move the pointer to the give position of the current page.

Specified by:
moveToArticle in interface ArticleQuery
Parameters:
paperNo - the position of the article in the current page.
Returns:
true if the position is within the scope of the current page.

getArticle

public Article getArticle()
Description copied from interface: ArticleQuery
read out the article the current pointer points to.

Specified by:
getArticle in interface ArticleQuery
Returns:
an article

getArticleKey

public java.lang.String getArticleKey()
Description copied from interface: ArticleQuery
In some cases, retrieval of an article is very expensive. Thus, one may check the key (unique document entry number) first. If the article is of interest, one will retrieve this article.

Specified by:
getArticleKey in interface ArticleQuery
Returns:
the key of the article the current pointer points to.

loadCollection

public boolean loadCollection(java.lang.String collectionPath,
                              java.lang.String collectionName)

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

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

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