Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.jsword.passage
Class AccuracyType

    java.lang.Object
      org.crosswire.jsword.passage.AccuracyType

All Implemented Interfaces:
  Serializable

    public abstract class AccuracyType

extends Object
implements Serializable

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 preceeding range is an entire chapter or book then 10 would understood as CHAPTER_ONLY or BOOK_ONLY (respectively)

  If the number has no preceeding 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 [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
  See Also:
    `for license details. The copyright to this program is held by it's authors.`, Serialized Form

  Field Summary
  `static AccuracyType` | `BOOK_CHAPTER` The passage was specified to a book and chapter (no verse).
  `static AccuracyType` | `BOOK_ONLY` The passage was specified to a book only (no chapter or verse).
  `static AccuracyType` | `BOOK_VERSE` The verse was specified as book, chapter and verse.
  `static AccuracyType` | `CHAPTER_ONLY` There was only a chapter number
  `static AccuracyType` | `CHAPTER_VERSE` The passage was specified to a chapter and verse (no book).
  `private String` | `name` The name of the object
  `private static int` | `nextObj`
  `private int` | `obj`
  `private static AccuracyType[]` | `VALUES`
  `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
  `static AccuracyType` | `VERSE_ONLY` There was only a verse number

  Constructor Summary
  `AccuracyType(String name)` Simple ctor

  Method Summary
  `private static void` | `checkValidChapterOrVerse(String text)` Is this text valid in a chapter/verse context
  `abstract Verse` | `createEndVerse(String endVerseDesc, Verse verseBasis, String[] endParts)`
  `abstract Verse` | `createStartVerse(String original, VerseRange verseRangeBasis, String[] parts)`
  `boolean` | `equals(Object o)` Prevent subclasses from overriding canonical identity based Object methods
  `static AccuracyType` | `fromInteger(int i)` Lookup method to convert from an integer
  `static AccuracyType` | `fromString(String name)` Lookup method to convert from a String
  `static AccuracyType` | `fromText(String original, String[] parts)` Determine how closely the string defines a verse.
  `static AccuracyType` | `fromText(String original, String[] parts, AccuracyType verseAccuracy)`
  `static AccuracyType` | `fromText(String original, String[] parts, AccuracyType verseAccuracy, VerseRange basis)` Does this string exactly define a Verse.
  `static AccuracyType` | `fromText(String original, String[] parts, VerseRange basis)`
  `static int` | `getChapter(int lbook, String chapter)` Interprets the chapter value, which is either a number or "ff" or "$" (meaning "what follows")
  `static int` | `getVerse(int lbook, int lchapter, String verse)` Interprets the verse value, which is either a number or "ff" or "$" (meaning "what follows")
  `int` | `hashCode()` Prevent subclasses from overriding canonical identity based Object methods
  `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.
  `(package private) Object` | `readResolve()`
  `int` | `toInteger()` Get an integer representation for this RestrictionType
  `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.
  `String` | `toString()`

  Methods inherited from class java.lang.Object
  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  Field 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

  ### 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

  ### name

      private String name

    The name of the object

  ### nextObj

      private static int nextObj

  ### obj

      private final int obj

  ### VALUES

      private static final AccuracyType[] 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

  Constructor Detail

  ### AccuracyType

      public AccuracyType(String name)

    Simple ctor

  Method Detail

  ### createStartVerse

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

    Parameters:
      `original` - the original verse reference as a string
      `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(String endVerseDesc,
                                           Verse verseBasis,
                                           String[] endParts)
                                    throws NoSuchVerseException

    Parameters:
      `endVerseDesc` - the original verse reference as a string
      `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(int lbook,
                                         String chapter)
                                  throws NoSuchVerseException

    Interprets the chapter value, which is either a number or "ff" or "$" (meaning "what follows")

    Parameters:
      `lbook` - the integer representation of 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(int lbook,
                                       int lchapter,
                                       String verse)
                                throws NoSuchVerseException

    Interprets the verse value, which is either a number or "ff" or "$" (meaning "what follows")

    Parameters:
      `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 RestrictionType

  ### fromText

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

    Determine how closely the string defines a verse.

    Parameters:
      `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(String original,
                                          String[] parts,
                                          AccuracyType verseAccuracy)
                                   throws NoSuchVerseException

    Parameters:
      `original` -
      `parts` -
      `verseAccuracy` -
    Returns:
      the accuracy of the parts
    Throws:
      `NoSuchVerseException`

  ### fromText

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

    Parameters:
      `original` -
      `parts` -
      `basis` -
    Returns:
      the accuracy of the parts
    Throws:
      `NoSuchVerseException`

  ### fromText

      public static AccuracyType fromText(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:
      `parts` -
      `verseAccuracy` -
      `basis` -
    Returns:
      the accuracy of the parts
    Throws:
      `NoSuchVerseException`

  ### 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

  ### tokenize

      public 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. 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

  ### fromString

      public static AccuracyType fromString(String name)

    Lookup method to convert from a String

    Parameters:
      `name` - the name of the AccuracyType
    Returns:
      the AccuracyType

  ### fromInteger

      public static AccuracyType fromInteger(int i)

    Lookup method to convert from an integer

    Parameters:
      `i` - the i-th AccuracyType
    Returns:
      the AccuracyType

  ### equals

      public final boolean equals(Object o)

    Prevent subclasses from overriding canonical identity based Object methods

    Overrides:
      `equals` in class `Object`
    See Also:
      `Object.equals(java.lang.Object)`

  ### hashCode

      public final int hashCode()

    Prevent subclasses from overriding canonical identity based Object methods

    Overrides:
      `hashCode` in class `Object`
    See Also:
      `Object.hashCode()`

  ### toString

      public String toString()

    Overrides:
      `toString` in class `Object`

  ### readResolve

      Object readResolve()

  Overview | Package | Class | Use | Tree | Deprecated | Index | Help
  | Copyright ¨ 2003-2005
  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD