org.crosswire.jsword.passage

## Class KeyUtil

- java.lang.Object
- - org.crosswire.jsword.passage.KeyUtil

-     public final class KeyUtil
      extends Object

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

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `KeyUtil()` Prevent instantiation

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Passage` | `getPassage(Key key)` Cast a Key to a Passage.
    `static Verse` | `getVerse(Key key)` Cast a Key to a Verse.
    `static Versification` | `getVersification(Key key)` Get the versification for the key or the default versification.
    `static void` | `visit(Key key, KeyVisitor visitor)` Walk through a tree visiting the nodes and branches in the tree

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### KeyUtil

          private KeyUtil()

      Prevent instantiation

  - ### Method Detail

    - #### visit

          public static void visit(Key key,
                   KeyVisitor visitor)

      Walk through a tree visiting the nodes and branches in the tree
      Parameters:
        `key` - The node tree to walk through
        `visitor` - The visitor to notify whenever a node is found

    - #### getVerse

          public static Verse getVerse(Key key)

      Cast a Key to a Verse. Only those keys that are a Verse or can contain Verses (i.e. Passage and VerseRange) may be cast to one. Verse containers (i.e. Passage and VerseRange) return their first verse.
      Parameters:
        `key` - The key to cast
      Returns:
        The key cast to a Verse
      Throws:
        `ClassCastException`

    - #### getPassage

          public static Passage getPassage(Key key)

      Cast a Key to a Passage. Only those keys that are a Passage or can be held by a Passage (i.e. Verse and VerseRange) may be cast to one. If you pass a null key into this method, you get a null Passage out.
      Parameters:
        `key` - The key to cast
      Returns:
        The key cast to a Passage
      Throws:
        `ClassCastException`

    - #### getVersification

          public static Versification getVersification(Key key)

      Get the versification for the key or the default versification.
      Parameters:
        `key` - the key that should provide for the Versification
      Returns:
        the versification for the key