net.sf.zekr.engine.search
Class SearchScopeItem

java.lang.Object
  extended by net.sf.zekr.engine.search.SearchScopeItem

public class SearchScopeItem
extends java.lang.Object

Since:
Zekr 1.0
Author:
Mohsen Saboorian

Constructor Summary
SearchScopeItem()
          Creates a new scope item from 1-1 to 1-1, inclusive.
SearchScopeItem(int suraFrom, int ayaFrom, int suraTo, int ayaTo, boolean exclusive)
          All parameters are behaved as 1-based.
 
Method Summary
static SearchScopeItem deserialize(java.lang.String scopeItemStr)
          Creates a SearchScopeItem from the given string scopeItemStr.
 boolean equals(java.lang.Object obj)
           
 boolean excludes(int sura, int aya)
          Tests whether an aya of a sura is excluded from this scope (works only if this item is exclusive).
 int getAyaFrom()
           
 int getAyaTo()
           
 int getSuraFrom()
           
 int getSuraTo()
           
 boolean includes(int sura, int aya)
          Tests whether an aya of a sura is included in this scope (works only if this item is inclusive).
 boolean isExclusive()
           
 java.lang.String serialize()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SearchScopeItem

public SearchScopeItem()
Creates a new scope item from 1-1 to 1-1, inclusive.


SearchScopeItem

public SearchScopeItem(int suraFrom,
                       int ayaFrom,
                       int suraTo,
                       int ayaTo,
                       boolean exclusive)
                throws IllegalSearchScopeItemException
All parameters are behaved as 1-based. Note that no range check (for aya count, or sura number) is performed.

Throws:
IllegalSearchScopeItemException - if from-to range is not considered.
Method Detail

getAyaFrom

public int getAyaFrom()

getAyaTo

public int getAyaTo()

getSuraFrom

public int getSuraFrom()

getSuraTo

public int getSuraTo()

isExclusive

public boolean isExclusive()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Returns:
true if obj is of type SearchScopeItem and all its properties are equal to this properties.

includes

public final boolean includes(int sura,
                              int aya)
Tests whether an aya of a sura is included in this scope (works only if this item is inclusive).

Parameters:
sura - sura number
aya - aya number
Returns:
true if this search scope item explicitly includes the aya, false otherwise.

excludes

public final boolean excludes(int sura,
                              int aya)
Tests whether an aya of a sura is excluded from this scope (works only if this item is exclusive).

Parameters:
sura - sura number
aya - aya number
Returns:
true if this search scope item explicitly excludes the aya, false otherwise.

toString

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

serialize

public java.lang.String serialize()

deserialize

public static SearchScopeItem deserialize(java.lang.String scopeItemStr)
Creates a SearchScopeItem from the given string scopeItemStr. A string representation of a search scope item is of the form [-]sura_from,aya_from,sura_to,aya_to. "-" is used to specify that this search scope is exclusive.

Parameters:
scopeItemStr - input scope item in string format
Returns:
a new SearchScopeItem instance
Throws:
IllegalSearchScopeItemException - if scope is not in well format