net.sf.zekr.common.resource
Class RangedQuranText

java.lang.Object
  extended by net.sf.zekr.common.resource.AbstractQuranText
      extended by net.sf.zekr.common.resource.AbstractRangedQuranText
          extended by net.sf.zekr.common.resource.RangedQuranText
All Implemented Interfaces:
IQuranText

public class RangedQuranText
extends AbstractRangedQuranText

Author:
Mohsen Saboorian

Field Summary
 
Fields inherited from interface net.sf.zekr.common.resource.IQuranText
SIMPLE_MODE, UTHMANI_MODE
 
Constructor Summary
RangedQuranText(IQuranText quran, SearchScope searchScope)
          Constructs a new instance of this class.
 
Method Summary
 java.lang.String currentAya()
          Returns the current aya.
 boolean findNext()
          Finds the next aya matching range restrictions (after applying scopes).
 java.lang.String get(int absoluteAyaNum)
          Returns the requested absolute aya.
 java.lang.String get(int suraNum, int ayaNum)
          Returns the requested aya.
 java.lang.String getBismillah(int suraNum)
          Return Bismillah (the beginning part of suras).
 IQuranLocation getCurrentLocation()
          Returns the current Quran location.
 java.lang.String[][] getFullText()
           
 int getMode()
          Return Quran text mode.
This method should only be implemented in subclasses which are aimed for Quran text.
 IQuranText getQuran()
           
 SearchScope getSearchScope()
          Returns SearchScope object for this ranged text.
 java.lang.String[] getSura(int suraNum)
          Returns the requested sura as an array of strings.
Note: no range check is performed.
 TranslationData getTranslationData()
          This method should only be implemented in subclasses which are aimed for Quran translation.
protected  void init()
          Initialize and cache appropriate (matching in scope) Quran ayas.
 void reset()
          Resets the Quran location, setting the pointer to the start of the text.
 void setQuran(IQuranText quran)
           
 void setSearchScope(SearchScope searchScope)
           
 java.lang.String toString()
           
 
Methods inherited from class net.sf.zekr.common.resource.AbstractQuranText
get
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangedQuranText

public RangedQuranText(IQuranText quran,
                       SearchScope searchScope)
Constructs a new instance of this class.

Parameters:
quran - the Quran/translation text
searchScope - the scope object. Set null, if you don't need any scope constraint.
Method Detail

setQuran

public void setQuran(IQuranText quran)

getQuran

public IQuranText getQuran()

setSearchScope

public void setSearchScope(SearchScope searchScope)

getSearchScope

public SearchScope getSearchScope()
Description copied from class: AbstractRangedQuranText
Returns SearchScope object for this ranged text.

Specified by:
getSearchScope in class AbstractRangedQuranText
Returns:
underling SearchScope object

init

protected void init()
Initialize and cache appropriate (matching in scope) Quran ayas. This method should be called once on each search scope (after newing an instance, before call to any other method).


reset

public void reset()
Description copied from class: AbstractRangedQuranText
Resets the Quran location, setting the pointer to the start of the text. It is called on object creation to find the start location point.

Specified by:
reset in class AbstractRangedQuranText

getCurrentLocation

public IQuranLocation getCurrentLocation()
Description copied from class: AbstractRangedQuranText
Returns the current Quran location.

Specified by:
getCurrentLocation in class AbstractRangedQuranText
Returns:
the current Quran location.

findNext

public final boolean findNext()
Description copied from class: AbstractRangedQuranText
Finds the next aya matching range restrictions (after applying scopes). A call to currentAya()() will return the found aya.

Specified by:
findNext in class AbstractRangedQuranText
Returns:
true if next aya found, or false if no more aya.

currentAya

public java.lang.String currentAya()
Description copied from class: AbstractRangedQuranText
Returns the current aya.

Specified by:
currentAya in class AbstractRangedQuranText
Returns:
the current aya, of null if there is no more matched aya.

get

public java.lang.String get(int suraNum,
                            int ayaNum)
Description copied from interface: IQuranText
Returns the requested aya.

Parameters:
suraNum - the sura number counted from 1
ayaNum - the aya number counted from 1
Returns:
returns ayaNumth aya of the suraNumth sura of the Quran.

getSura

public java.lang.String[] getSura(int suraNum)
Description copied from interface: IQuranText
Returns the requested sura as an array of strings.
Note: no range check is performed.

Parameters:
suraNum - indicates the sura number (which is counted from 1)
Returns:
a String array of the sura (#suraNum) ayas.

getFullText

public java.lang.String[][] getFullText()
Returns:
Full text of the Quran/translation text as a 2D array.

getTranslationData

public TranslationData getTranslationData()
Description copied from interface: IQuranText
This method should only be implemented in subclasses which are aimed for Quran translation.

Returns:
translation data

getBismillah

public java.lang.String getBismillah(int suraNum)
Description copied from interface: IQuranText
Return Bismillah (the beginning part of suras).

Parameters:
suraNum - sura number (1-based)
Returns:
Bismillah part

get

public java.lang.String get(int absoluteAyaNum)
Description copied from interface: IQuranText
Returns the requested absolute aya.

Parameters:
absoluteAyaNum - absolute sura number counted from 1
Returns:
returns the requested aya

getMode

public int getMode()
Description copied from interface: IQuranText
Return Quran text mode.
This method should only be implemented in subclasses which are aimed for Quran text.

Returns:
Quran text mode: IQuranText.SIMPLE_MODE or IQuranText.UTHMANI_MODE.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object