public final class Verse extends Object implements VerseKey<Verse>
( v11n, book, chapter, verse )
A Verse is designed to be immutable. This is a necessary from a collections point of view. A Verse should always be valid, although some versions may not return any text for verses that they consider to be untranslated in some way.
The GNU Lesser General Public License for details.
,
Serialized FormModifier and Type | Field and Description |
---|---|
private BibleBook |
book
The book of the Bible.
|
private int |
chapter
The chapter number
|
static Verse |
DEFAULT
The default verse
|
private static org.slf4j.Logger |
log |
private int |
ordinal
The ordinal value for this verse within its versification.
|
private static long |
serialVersionUID
To make serialization work across new versions
|
private static NumberShaper |
shaper
Allow the conversion to and from other number representations.
|
private String |
subIdentifier
The OSIS Sub-identifier if present.
|
private Versification |
v11n
The versification for this verse.
|
private int |
verse
The verse number
|
static char |
VERSE_OSIS_DELIM
What characters should we use to separate parts of an OSIS verse
reference
|
static char |
VERSE_OSIS_SUB_PREFIX
What characters should we use to start an OSIS sub identifier
|
static char |
VERSE_PREF_DELIM1
What characters should we use to separate the book from the chapter
|
static char |
VERSE_PREF_DELIM2
What characters should we use to separate the chapter from the verse
|
Constructor and Description |
---|
Verse(Versification v11n,
BibleBook book,
int chapter,
int verse)
Create a Verse from book, chapter and verse numbers, throwing up if the
specified Verse does not exist.
|
Verse(Versification v11n,
BibleBook book,
int chapter,
int verse,
boolean patchUp)
Create a Verse from book, chapter and verse numbers, patching up if the
specified verse does not exist.
|
Verse(Versification v11n,
BibleBook book,
int chapter,
int verse,
String subIdentifier)
Create a Verse from book, chapter and verse numbers, throwing up if the
specified Verse does not exist.
|
Verse(Versification v11n,
int ordinal)
Set a Verse using a verse ordinal number - WARNING Do not use this method
unless you really know the dangers of doing so.
|
Modifier and Type | Method and Description |
---|---|
void |
addAll(Key key)
Adds the specified element to this set if it is not already present.
|
void |
blur(int by,
RestrictionType restrict)
Widen the range of the verses/keys in this list.
|
static boolean |
bothNullOrEqual(Object x,
Object y)
Determine whether two objects are equal, allowing nulls
|
boolean |
canHaveChildren()
Returns false if the receiver is a leaf node and can not have children.
|
void |
clear()
Removes all of the elements from this set (optional operation).
|
Verse |
clone()
This needs to be declared here so that it is visible as a method on a
derived Key.
|
int |
compareTo(Key obj) |
boolean |
contains(Key key)
Returns true if this set contains the specified element.
|
private String |
doGetName(Verse verseBase)
Compute the verse representation given the context.
|
boolean |
equals(Object obj)
This needs to be declared here so that it is visible as a method on a
derived Key.
|
Key |
get(int index)
Gets a key from a specific point in this list of children.
|
BibleBook |
getBook()
Return the book that we refer to
|
int |
getCardinality()
Returns the number of elements in this set (its cardinality).
|
int |
getChapter()
Return the chapter that we refer to
|
int |
getChildCount()
Returns the number of children that this node has.
|
String |
getName()
A Human readable version of the Key.
|
String |
getName(Key base)
Translate the Key into a human readable string, with the assumption that
the specified Key has just been output, so if we are in the same region,
we do not need to display the region name, and so on.
|
int |
getOrdinal()
Return the ordinal value of the verse in its versification.
|
String |
getOsisID()
The OSIS defined id specification for this Key.
|
String |
getOsisIDNoSubIdentifier() |
String |
getOsisRef()
The OSIS defined reference specification for this Key.
|
Key |
getParent()
All keys have parents unless they are the root of a Key.
|
String |
getRootName()
A Human readable version of the Key's top level name.
|
String |
getSubIdentifier()
Return the sub identifier if any
|
int |
getVerse()
Return the verse that we refer to
|
private StringBuilder |
getVerseIdentifier()
Gets the common name of the verse, excluding any !abc sub-identifier
|
Versification |
getVersification()
Get the Versification that defines the Verses in this VerseKey.
|
Verse |
getWhole()
Convert this reference into one without a sub-identifier.
|
int |
hashCode()
This needs to be declared here so that it is visible as a method on a
derived Key.
|
int |
indexOf(Key that)
Reverse a Key into the position the key holds in the list of children
|
boolean |
isEmpty()
Does this Key have 0 members
|
boolean |
isWhole()
A VerseKey that does not have an OSIS sub identifier is a whole reference.
|
Iterator<Key> |
iterator() |
protected static int |
parseInt(String text)
This is simply a convenience function to wrap Integer.parseInt() and give
us a reasonable exception on failure.
|
private void |
readObject(ObjectInputStream in)
Write out the object to the given ObjectOutputStream
|
void |
removeAll(Key key)
Removes the specified elements from this set if it is present.
|
void |
retainAll(Key key)
Removes all but the specified element from this set.
|
Verse |
reversify(Versification newVersification)
Cast this VerseKey into another Versification.
|
String |
toString() |
Verse[] |
toVerseArray()
Create an array of Verses
|
private void |
writeObject(ObjectOutputStream out)
Write out the object to the given ObjectOutputStream
|
public static final char VERSE_OSIS_DELIM
public static final char VERSE_OSIS_SUB_PREFIX
public static final char VERSE_PREF_DELIM1
public static final char VERSE_PREF_DELIM2
public static final Verse DEFAULT
private static NumberShaper shaper
private transient Versification v11n
private int ordinal
private transient BibleBook book
private transient int chapter
private transient int verse
private String subIdentifier
private static final org.slf4j.Logger log
private static final long serialVersionUID
public Verse(Versification v11n, BibleBook book, int chapter, int verse)
v11n
- The versification to which this verse belongsbook
- The book number (Genesis = 1)chapter
- The chapter numberverse
- The verse numberpublic Verse(Versification v11n, BibleBook book, int chapter, int verse, String subIdentifier)
v11n
- The versification to which this verse belongsbook
- The book number (Genesis = 1)chapter
- The chapter numberverse
- The verse numbersubIdentifier
- The optional sub identifierpublic Verse(Versification v11n, BibleBook book, int chapter, int verse, boolean patchUp)
The actual value of the boolean is ignored. However for future proofing
you should only use 'true'. Do not use patch_up=false, use
Verse(int, int, int)
This so that we can declare this
constructor to not throw an exception. Is there a better way of doing
this?
v11n
- The versification to which this verse belongsbook
- The book number (Genesis = 1)chapter
- The chapter numberverse
- The verse numberpatchUp
- True to trigger reference fixingpublic Verse(Versification v11n, int ordinal)
v11n
- The versification to which this verse belongsordinal
- The verse idpublic boolean isWhole()
VerseKey
public Verse getWhole()
VerseKey
public String getName()
Key
public String getName(Key base)
Key
public String getRootName()
Key
getRootName
in interface Key
public String getOsisRef()
Key
getOsisRef
in interface Key
public String getOsisID()
Key
public String getOsisIDNoSubIdentifier()
private StringBuilder getVerseIdentifier()
public Verse clone()
Key
public boolean equals(Object obj)
Key
public int hashCode()
Key
public int compareTo(Key obj)
compareTo
in interface Comparable<Key>
public Versification getVersification()
VerseKey
getVersification
in interface VerseKey<Verse>
public Verse reversify(Versification newVersification)
VerseKey
Note: This is dangerous as it does not consider chapter boundaries or whether the verses in this VerseKey are actually part of the new versification. It should only be used when the start and end verses are in both Versifications. You have been warned.
public BibleBook getBook()
public int getChapter()
public int getVerse()
public String getSubIdentifier()
public int getOrdinal()
public Verse[] toVerseArray()
public Key getParent()
Key
public static boolean bothNullOrEqual(Object x, Object y)
x
- y
- private String doGetName(Verse verseBase)
verseBase
- the context or null if there is noneprotected static int parseInt(String text) throws NoSuchVerseException
text
- The string to be parsedNoSuchVerseException
private void writeObject(ObjectOutputStream out) throws IOException
out
- The stream to write our state toIOException
- if the read failsprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
in
- The stream to read our state fromIOException
- if the read failsClassNotFoundException
- If the read data is incorrectpublic boolean canHaveChildren()
Key
canHaveChildren
in interface Key
public int getChildCount()
Key
getChildCount
in interface Key
public int getCardinality()
Key
This method is potentially expensive, as it often requires cycling through all the keys in the set.
getCardinality
in interface Key
public boolean isEmpty()
Key
public boolean contains(Key key)
Key
public void addAll(Key key)
Key
public void removeAll(Key key)
Key
public void retainAll(Key key)
Key
public void clear()
Key
public Key get(int index)
Key
public int indexOf(Key that)
Key
public void blur(int by, RestrictionType restrict)
Key