org.crosswire.jsword.passage

## Enum AccuracyType

- java.lang.Object
- - java.lang.Enum<AccuracyType>
  - - org.crosswire.jsword.passage.AccuracyType

- All Implemented Interfaces:
    Serializable, Comparable<AccuracyType>

      public enum AccuracyType
      extends Enum<AccuracyType>

  Types of Accuracy for verse references. For example:
  - Gen == BOOK_ONLY;
  - Gen 1 == BOOK_CHAPTER;
  - Gen 1:1 == BOOK_VERSE;
  - Jude 1 == BOOK_VERSE;
  - Jude 1:1 == BOOK_VERSE;
  - 1:1 == CHAPTER_VERSE;
  - 10 == BOOK_ONLY, CHAPTER_ONLY, or VERSE_ONLY

  With the last one, you will note that there is a choice. By itself there is not enough information to determine which one it is. There has to be a context in which it is used.

  It may be found in a verse range like: Gen 1:2 - 10. In this case the context of 10 is Gen 1:2, which is BOOK_VERSE. So in this case, 10 is VERSE_ONLY.

  If it is at the beginning of a range like 10 - 22:3, it has to have more context. If the context is a prior entry like Gen 2:5, 10 - 22:3, then its context is Gen 2:5, which is BOOK_VERSE and 10 is VERSE_ONLY.

  However if it is Gen 2, 10 - 22:3 then the context is Gen 2, BOOK_CHAPTER so 10 is understood as BOOK_CHAPTER.

  As a special case, if the preceding range is an entire chapter or book then 10 would understood as CHAPTER_ONLY or BOOK_ONLY (respectively)

  If the number has no preceding context, then it is understood as being BOOK_ONLY.

  In all of these examples, the start verse was being interpreted. In the case of a verse that is the end of a range, it is interpreted in the context of the range's start.

  Author:
    Joe Walker, DM Smith
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `BOOK_CHAPTER` The passage was specified to a book and chapter (no verse).
    `BOOK_ONLY` The passage was specified to a book only (no chapter or verse).
    `BOOK_VERSE` The verse was specified as book, chapter and verse.
    `CHAPTER_ONLY` There was only a chapter number
    `CHAPTER_VERSE` The passage was specified to a chapter and verse (no book).
    `VERSE_ONLY` There was only a verse number

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `VERSE_ALLOWED_DELIMS` What characters can we use to separate parts to a verse
    `static String` | `VERSE_END_MARK1` Characters that are used to indicate end of verse/chapter, part 1
    `static String` | `VERSE_END_MARK2` Characters that are used to indicate end of verse/chapter, part 2

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `private static NoSuchVerseException` | `buildVersePartsException(String original, String[] parts)`
    `private static void` | `checkValidChapterOrVerse(String text)` Is this text valid in a chapter/verse context
    `abstract Verse` | `createEndVerse(Versification v11n, Verse verseBasis, String[] endParts)`
    `abstract Verse` | `createStartVerse(Versification v11n, VerseRange verseRangeBasis, String[] parts)`
    `static AccuracyType` | `fromText(Versification v11n, String original, String[] parts)` Determine how closely the string defines a verse.
    `static AccuracyType` | `fromText(Versification v11n, String original, String[] parts, AccuracyType verseAccuracy)`
    `static AccuracyType` | `fromText(Versification v11n, String original, String[] parts, AccuracyType verseAccuracy, VerseRange basis)` Does this string exactly define a Verse.
    `static AccuracyType` | `fromText(Versification v11n, String original, String[] parts, VerseRange basis)`
    `static int` | `getChapter(Versification v11n, BibleBook lbook, String chapter)` Interprets the chapter value, which is either a number or "ff" or "$" (meaning "what follows")
    `protected static String` | `getSubIdentifier(String[] parts)`
    `static int` | `getVerse(Versification v11n, BibleBook lbook, int lchapter, String verse)` Interprets the verse value, which is either a number or "ff" or "$" (meaning "what follows")
    `private static boolean` | `hasSubIdentifier(String[] parts)`
    `boolean` | `isBook()`
    `boolean` | `isChapter()`
    `private static boolean` | `isEndMarker(String text)` Is this string a legal marker for 'to the end of the chapter'
    `boolean` | `isVerse()`
    `private static int` | `parseInt(String text)` This is simply a convenience function to wrap Integer.parseInt() and give us a reasonable exception on failure.
    `int` | `toInteger()` Get an integer representation for this AccuracyType
    `static String[]` | `tokenize(String input)` Take a string representation of a verse and parse it into an Array of Strings where each part is likely to be a verse part.
    `static AccuracyType` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static AccuracyType[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### BOOK_VERSE

          public static final AccuracyType BOOK_VERSE

      The verse was specified as book, chapter and verse. For example, Gen 1:1, Jude 3 (which only has one chapter)

    - #### BOOK_CHAPTER

          public static final AccuracyType BOOK_CHAPTER

      The passage was specified to a book and chapter (no verse). For example, Gen 1

    - #### BOOK_ONLY

          public static final AccuracyType BOOK_ONLY

      The passage was specified to a book only (no chapter or verse). For example, Gen

    - #### CHAPTER_VERSE

          public static final AccuracyType CHAPTER_VERSE

      The passage was specified to a chapter and verse (no book). For example, 1:1

    - #### CHAPTER_ONLY

          public static final AccuracyType CHAPTER_ONLY

      There was only a chapter number

    - #### VERSE_ONLY

          public static final AccuracyType VERSE_ONLY

      There was only a verse number

  - ### Field Detail

    - #### VERSE_ALLOWED_DELIMS

          public static final String VERSE_ALLOWED_DELIMS

      What characters can we use to separate parts to a verse
      See Also:
        Constant Field Values

    - #### VERSE_END_MARK1

          public static final String VERSE_END_MARK1

      Characters that are used to indicate end of verse/chapter, part 1
      See Also:
        Constant Field Values

    - #### VERSE_END_MARK2

          public static final String VERSE_END_MARK2

      Characters that are used to indicate end of verse/chapter, part 2
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### values

          public static AccuracyType[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (AccuracyType c : AccuracyType.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static AccuracyType valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### createStartVerse

          public abstract Verse createStartVerse(Versification v11n,
                               VerseRange verseRangeBasis,
                               String[] parts)
                                          throws NoSuchVerseException

      Parameters:
        `v11n` - the versification to which this reference pertains
        `verseRangeBasis` - the range that stood before the string reference
        `parts` - a tokenized version of the original
      Returns:
        a `Verse` for the original
      Throws:
        `NoSuchVerseException`

    - #### createEndVerse

          public abstract Verse createEndVerse(Versification v11n,
                             Verse verseBasis,
                             String[] endParts)
                                        throws NoSuchVerseException

      Parameters:
        `v11n` - the versification to which this reference pertains
        `verseBasis` - the verse at the beginning of the range
        `endParts` - a tokenized version of the original
      Returns:
        a `Verse` for the original
      Throws:
        `NoSuchVerseException`

    - #### isBook

          public boolean isBook()

      Returns:
        true if this AccuracyType specifies down to the book but not chapter or verse.

    - #### isChapter

          public boolean isChapter()

      Returns:
        true if this AccuracyType specifies down to the chapter but not the verse.

    - #### isVerse

          public boolean isVerse()

      Returns:
        true if this AccuracyType specifies down to the verse.

    - #### getChapter

          public static final int getChapter(Versification v11n,
                       BibleBook lbook,
                       String chapter)
                                      throws NoSuchVerseException

      Interprets the chapter value, which is either a number or "ff" or "$" (meaning "what follows")
      Parameters:
        `v11n` - the versification to which this reference pertains
        `lbook` - the book
        `chapter` - a string representation of the chapter. May be "ff" or "$" for "what follows".
      Returns:
        the number of the chapter
      Throws:
        `NoSuchVerseException`

    - #### getVerse

          public static final int getVerse(Versification v11n,
                     BibleBook lbook,
                     int lchapter,
                     String verse)
                                    throws NoSuchVerseException

      Interprets the verse value, which is either a number or "ff" or "$" (meaning "what follows")
      Parameters:
        `v11n` - the versification to which this reference pertains
        `lbook` - the integer representation of the book
        `lchapter` - the integer representation of the chapter
        `verse` - the string representation of the verse
      Returns:
        the number of the verse
      Throws:
        `NoSuchVerseException`

    - #### toInteger

          public int toInteger()

      Get an integer representation for this AccuracyType
      Returns:
        the ordinal representation

    - #### fromText

          public static AccuracyType fromText(Versification v11n,
                              String original,
                              String[] parts)
                                       throws NoSuchVerseException

      Determine how closely the string defines a verse.
      Parameters:
        `v11n` - the versification to which this reference pertains
        `original` -
        `parts` - is a reference split into parts
      Returns:
        what is the kind of accuracy of the string reference.
      Throws:
        `NoSuchVerseException`

    - #### fromText

          public static AccuracyType fromText(Versification v11n,
                              String original,
                              String[] parts,
                              AccuracyType verseAccuracy)
                                       throws NoSuchVerseException

      Parameters:
        `v11n` - the versification to which this reference pertains
        `original` -
        `parts` -
        `verseAccuracy` -
      Returns:
        the accuracy of the parts
      Throws:
        `NoSuchVerseException`

    - #### fromText

          public static AccuracyType fromText(Versification v11n,
                              String original,
                              String[] parts,
                              VerseRange basis)
                                       throws NoSuchVerseException

      Parameters:
        `v11n` - the versification to which this reference pertains
        `original` -
        `parts` -
        `basis` -
      Returns:
        the accuracy of the parts
      Throws:
        `NoSuchVerseException`

    - #### fromText

          public static AccuracyType fromText(Versification v11n,
                              String original,
                              String[] parts,
                              AccuracyType verseAccuracy,
                              VerseRange basis)
                                       throws NoSuchVerseException

      Does this string exactly define a Verse. For example:
      - fromText("Gen") == AccuracyType.BOOK_ONLY;
      - fromText("Gen 1:1") == AccuracyType.BOOK_VERSE;
      - fromText("Gen 1") == AccuracyType.BOOK_CHAPTER;
      - fromText("Jude 1") == AccuracyType.BOOK_VERSE;
      - fromText("Jude 1:1") == AccuracyType.BOOK_VERSE;
      - fromText("1:1") == AccuracyType.CHAPTER_VERSE;
      - fromText("1") == AccuracyType.VERSE_ONLY;
      Parameters:
        `v11n` - the versification to which this reference pertains
        `original` -
        `parts` -
        `verseAccuracy` -
        `basis` -
      Returns:
        the accuracy of the parts
      Throws:
        `NoSuchVerseException`

    - #### buildVersePartsException

          private static NoSuchVerseException buildVersePartsException(String original,
                                                      String[] parts)

    - #### checkValidChapterOrVerse

          private static void checkValidChapterOrVerse(String text)
                                                throws NoSuchVerseException

      Is this text valid in a chapter/verse context
      Parameters:
        `text` - The string to test for validity
      Throws:
        `NoSuchVerseException` - If the text is invalid

    - #### parseInt

          private static int parseInt(String text)
                               throws NoSuchVerseException

      This is simply a convenience function to wrap Integer.parseInt() and give us a reasonable exception on failure. It is called by VerseRange hence protected, however I would prefer private
      Parameters:
        `text` - The string to be parsed
      Returns:
        The correctly parsed chapter or verse
      Throws:
        `NoSuchVerseException` - If the reference is illegal

    - #### isEndMarker

          private static boolean isEndMarker(String text)

      Is this string a legal marker for 'to the end of the chapter'
      Parameters:
        `text` - The string to be checked
      Returns:
        true if this is a legal marker

    - #### hasSubIdentifier

          private static boolean hasSubIdentifier(String[] parts)

    - #### getSubIdentifier

          protected static String getSubIdentifier(String[] parts)

    - #### tokenize

          public static String[] tokenize(String input)
                                   throws NoSuchVerseException

      Take a string representation of a verse and parse it into an Array of Strings where each part is likely to be a verse part. The goal is to allow the greatest possible variations in user input.

      Parts can be separated by pretty much anything. No distinction is made between them. While chapter and verse need to be separated, a separator is assumed between digits and non-digits. Adjacent words, (i.e. sequences of non-digits) are understood to be a book reference. If a number runs up against a book name, it is considered to be either part of the book name (i.e. it is before it) or a chapter number (i.e. it stands after it.)

      Note: ff and $ are considered to be digits.

      Note: it is not necessary for this to be a BCV (book, chapter, verse), it may just be BC, B, C, V or CV. No distinction is needed here for a number that stands alone.

      Parameters:
        `input` - The string to parse.
      Returns:
        The string array
      Throws:
        `NoSuchVerseException`