org.crosswire.jsword.book.study
Class StrongsNumber

java.lang.Object
  extended by org.crosswire.jsword.book.study.StrongsNumber

public class StrongsNumber
extends Object

A Strong's Number is either Greek or Hebrew, where the actual numbers for each start at 1. This class can parse Strong's Numbers that begin with G, g, H or h and are immediately followed by a number. That number can have leading 0's. It can be followed by an OSISref extension of !a, !b, which is ignored.

The canonical representation of the number is a G or H followed by 4 digits, with leading 0's as needed.

Numbers that exist:

Author:
DM Smith [dmsmith555 at yahoo dot com]
See Also:
for license details. The copyright to this program is held by it's authors.

Field Summary
private  char language
          Whether it is Greek (G) or Hebrew (H).
private  String part
          The part if any.
private static Pattern STRONGS_PATTERN
          The pattern of an acceptable Strong's number.
private  short strongsNumber
          The Strong's Number.
private static DecimalFormat ZERO_PAD
           
 
Constructor Summary
StrongsNumber(char language, short strongsNumber)
          Build an immutable Strong's Number.
StrongsNumber(char language, short strongsNumber, String part)
          Build an immutable Strong's Number.
StrongsNumber(String input)
          Build an immutable Strong's Number.
 
Method Summary
 boolean equals(Object obj)
           
 String getFullStrongsNumber()
          Return the canonical form of a Strong's Number, with the part, if any
 String getStrongsNumber()
          Return the canonical form of a Strong's Number, without the part.
 int hashCode()
           
 boolean isGreek()
           
 boolean isHebrew()
           
 boolean isPart()
           
 boolean isValid()
          Validates the number portion of this StrongsNumber.
private  void parse(String input)
          Do the actual parsing.
 String toString()
           
private  void validate()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

language

private char language
Whether it is Greek (G) or Hebrew (H).


strongsNumber

private short strongsNumber
The Strong's Number.


part

private String part
The part if any.


STRONGS_PATTERN

private static final Pattern STRONGS_PATTERN
The pattern of an acceptable Strong's number.


ZERO_PAD

private static final DecimalFormat ZERO_PAD
Constructor Detail

StrongsNumber

public StrongsNumber(String input)
              throws BookException
Build an immutable Strong's Number. Anything that does not match causes a BookException.

Parameters:
input - a string that needs to be parsed.
Throws:
BookException

StrongsNumber

public StrongsNumber(char language,
                     short strongsNumber)
              throws BookException
Build an immutable Strong's Number. If the language is not 'G' or 'H' or the number is invalid, a BookException.

Parameters:
language -
strongsNumber -
Throws:
BookException

StrongsNumber

public StrongsNumber(char language,
                     short strongsNumber,
                     String part)
              throws BookException
Build an immutable Strong's Number. If the language is not 'G' or 'H' or the number is invalid, a BookException.

Parameters:
language -
strongsNumber -
Throws:
BookException
Method Detail

getStrongsNumber

public String getStrongsNumber()
Return the canonical form of a Strong's Number, without the part.

Returns:
the strongsNumber

getFullStrongsNumber

public String getFullStrongsNumber()
Return the canonical form of a Strong's Number, with the part, if any

Returns:
the strongsNumber

isGreek

public boolean isGreek()
Returns:
true if the Strong's number is for Greek

isHebrew

public boolean isHebrew()
Returns:
true if the Strong's number is for Hebrew

isPart

public boolean isPart()
Returns:
true if this Strong's number is identified by a sub part

isValid

public boolean isValid()
Validates the number portion of this StrongsNumber. Hebrew Strong's numbers are in the range of: 1-8674 Greek Strong's numbers in the range of: 1-5624 (but not 1418, 2717, 3203-3302, 4452)

Returns:
true if the Strong's number is in range.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

parse

private void parse(String input)
            throws BookException
Do the actual parsing. Anything that does not match causes a BookException.

Parameters:
input -
Throws:
BookException

validate

private void validate()
               throws BookException
Throws:
BookException

Copyright ยจ 2003-2007