net.sf.zekr.common.resource
Class QuranPropertiesUtils

java.lang.Object
  extended by net.sf.zekr.common.resource.QuranPropertiesUtils

public class QuranPropertiesUtils
extends java.lang.Object

This class tightly depends on the class QuranProperties. Almost all public methods on this class cache the static results once called, and if called more, read it from the cache.

This cache is not designed to be thread-safe. It is highly unsafe!

Author:
Mohsen Saboorian

Field Summary
static int QURAN_AYA_COUNT
          Number of Quran ayas based on Uthmani Mushaf
static int QURAN_SURA_COUNT
          Number of Quran suras
 
Constructor Summary
QuranPropertiesUtils()
           
 
Method Summary
static int diff(IQuranLocation loc1, IQuranLocation loc2)
           
static int getAbsoluteLocation(IQuranLocation iql)
           
static int getAggregateAyaCount(int suraNum)
           
static JuzProperties getFirstJuzOf(int suraNum)
           
static int getHizbQuadIndex(int suraNum, int ayaNum)
           
static int getHizbQuadIndex(IQuranLocation quranLoc)
           
static java.lang.String getIndexedSuraName(int suraNum)
           
static java.lang.String getIndexedSuraName(int suraNum, java.lang.String suraName)
           
static java.lang.String getIndexedSuraName(SuraProperties sura)
           
static java.lang.String[] getIndexedSuraNames()
           
static JuzProperties getJuz(int juzNum)
           
static int[] getJuzInside(int suraNum)
          If there is any juz start within the sura, it will be returned.
static java.util.List getJuzInsideSura(int suraNum)
          If there is any juz start within the sura, it will be returned.
static JuzProperties getJuzOf(int suraNum, int ayaNum)
           
static JuzProperties getJuzOf(IQuranLocation iql)
           
static IQuranLocation getLocation(int absoluteAyaNum)
           
static IQuranLocation getLocation(int sura, int aya)
          This method returns a Quran location, which is looked up from a cache of al Quran location.
static IQuranLocation[] getLocations()
           
static java.util.List getPageData(IQuranPage quranPage)
           
static java.util.List getPageData(IQuranText quranText, IQuranPage quranPage)
           
static int getRevelationOrder(IQuranLocation location)
           
static SajdaProperties getSajda(int sajdaNum)
           
static SajdaProperties getSajda(IQuranLocation location)
          Find and return the sajda for this location.
static java.util.List getSajdaInsideList(int suraNum)
           
static java.util.List getSajdaList()
           
static int getSajdaType(java.lang.String sajda)
           
static SuraProperties getSura(int suraNum)
           
static java.lang.String[] getSuraAyas(int suraNum)
           
static java.lang.String getSuraDescent(boolean isMadani)
           
static Range getSuraInsideJuz(int juz)
           
static java.lang.String getSuraJuz(int suraNum)
           
static java.util.List getSuraJuzAsList(int suraNum)
           
static java.lang.String[] getSuraNames()
           
static java.util.Map getSuraPropsMap(int suraNum)
           
static boolean isMadani(java.lang.String descent)
           
static boolean isValid(int sura, int aya)
           
static boolean isValid(IQuranLocation quranLocation)
           
static java.lang.String propsToClipboadrFormat(java.util.Map suraProps)
           
static void resetIndexedSuraNames()
           
static void updateLocalizedSuraNames()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QURAN_AYA_COUNT

public static int QURAN_AYA_COUNT
Number of Quran ayas based on Uthmani Mushaf


QURAN_SURA_COUNT

public static int QURAN_SURA_COUNT
Number of Quran suras

Constructor Detail

QuranPropertiesUtils

public QuranPropertiesUtils()
Method Detail

getSajdaType

public static final int getSajdaType(java.lang.String sajda)

isMadani

public static final boolean isMadani(java.lang.String descent)

getSajdaList

public static java.util.List getSajdaList()

getSuraAyas

public static final java.lang.String[] getSuraAyas(int suraNum)
Parameters:
suraNum - sura number (counted from 1)
Returns:
a String array of aya numbers in a sura. e.g. ["1", "2", "3", ...]

getSuraNames

public static final java.lang.String[] getSuraNames()
Returns:
zero relative array of sura names

getSura

public static final SuraProperties getSura(int suraNum)
Parameters:
suraNum - (1-based)
Returns:
the SuraProperties object corresponding to suraNum

resetIndexedSuraNames

public static final void resetIndexedSuraNames()

getIndexedSuraNames

public static final java.lang.String[] getIndexedSuraNames()

getIndexedSuraName

public static final java.lang.String getIndexedSuraName(int suraNum,
                                                        java.lang.String suraName)

getIndexedSuraName

public static final java.lang.String getIndexedSuraName(SuraProperties sura)

getIndexedSuraName

public static final java.lang.String getIndexedSuraName(int suraNum)

getJuz

public static final JuzProperties getJuz(int juzNum)

getSajda

public static final SajdaProperties getSajda(int sajdaNum)

getSajda

public static final SajdaProperties getSajda(IQuranLocation location)
Find and return the sajda for this location.

Parameters:
location -
Returns:
corresponding SajdaProperties (if any), or null, if there is no sajda for this location.

getJuzInsideSura

public static final java.util.List getJuzInsideSura(int suraNum)
If there is any juz start within the sura, it will be returned.
This method is the same as getJuzInside(), but with a different return type.

Parameters:
suraNum - sura number (counted from 1)
Returns:
a List of JuzProperties

getJuzInside

public static final int[] getJuzInside(int suraNum)
If there is any juz start within the sura, it will be returned.

Parameters:
suraNum - sura number (counted from 1)
Returns:
int array of juz numbers

getFirstJuzOf

public static final JuzProperties getFirstJuzOf(int suraNum)

getJuzOf

public static final JuzProperties getJuzOf(IQuranLocation iql)

getJuzOf

public static final JuzProperties getJuzOf(int suraNum,
                                           int ayaNum)

getHizbQuadIndex

public static final int getHizbQuadIndex(int suraNum,
                                         int ayaNum)
Returns:
a number between 0 to 7, meaning the hizb quarter in a juz. For example 0 means the first quranter of Hizb 1, 4 means the first quarter of Hizb 2, and 7 means the third quarter of Hizb 2.

getHizbQuadIndex

public static int getHizbQuadIndex(IQuranLocation quranLoc)

getSajdaInsideList

public static final java.util.List getSajdaInsideList(int suraNum)
Parameters:
suraNum - sura number (counted from 1)
Returns:
List of SajdaProperties inside suraNum

getSuraPropsMap

public static final java.util.Map getSuraPropsMap(int suraNum)
Parameters:
suraNum - sura number (counted from 1)
Returns:
Sura properties as a Map

propsToClipboadrFormat

public static final java.lang.String propsToClipboadrFormat(java.util.Map suraProps)

getSuraDescent

public static final java.lang.String getSuraDescent(boolean isMadani)
Parameters:
isMadani -
Returns:
localized String of descent type of a sura (Makki or Madani)

getSuraJuz

public static final java.lang.String getSuraJuz(int suraNum)

getSuraJuzAsList

public static final java.util.List getSuraJuzAsList(int suraNum)

getSuraInsideJuz

public static final Range getSuraInsideJuz(int juz)
Parameters:
juz - juz number to find its suras
Returns:
a Range object whose from and to are both inclusive.

getAggregateAyaCount

public static final int getAggregateAyaCount(int suraNum)
Parameters:
suraNum - sura number (counted from 1)
Returns:
the sum of aya count from sura 1 to suraNum - 1.

getPageData

public static final java.util.List getPageData(IQuranPage quranPage)
Parameters:
quranPage -
Returns:
a list of Quran locations of type IQuranPage.

getPageData

public static final java.util.List getPageData(IQuranText quranText,
                                               IQuranPage quranPage)
Parameters:
quranText -
quranPage -
Returns:
a list of Quran locations of type IQuranPage.

updateLocalizedSuraNames

public static void updateLocalizedSuraNames()

getRevelationOrder

public static int getRevelationOrder(IQuranLocation location)

getLocations

public static IQuranLocation[] getLocations()
Returns:
all Quran locations as an array. The size of the array is QURAN_AYA_COUNT.

getLocation

public static final IQuranLocation getLocation(int absoluteAyaNum)
Parameters:
absoluteAyaNum - a positive number between 1 and 6236.
Returns:
an IQuranLocation instance for this aya.

isValid

public static final boolean isValid(int sura,
                                    int aya)

isValid

public static final boolean isValid(IQuranLocation quranLocation)

getLocation

public static final IQuranLocation getLocation(int sura,
                                               int aya)
This method returns a Quran location, which is looked up from a cache of al Quran location. Since IQuranLocation is immutable, it can be shared.

Parameters:
sura - (counted from 1)
aya - (counted from 1)
Returns:
a cached Quran location

getAbsoluteLocation

public static final int getAbsoluteLocation(IQuranLocation iql)
Parameters:
iql - Quran location to be looked up
Returns:
Quran location absolute aya index or -1 if nothing found.

diff

public static final int diff(IQuranLocation loc1,
                             IQuranLocation loc2)
Parameters:
loc1 - first location
loc2 - second location
Returns:
absolute aya number for location 1 - absolute number for location 2