org.crosswire.jsword.passage
Class KeyUtil

java.lang.Object
  extended by org.crosswire.jsword.passage.KeyUtil

public final class KeyUtil
extends Object

.

Author:
Joe Walker [joe at eireneh dot com], DM Smith
See Also:
for license details.
The copyright to this program is held by it's authors.

Constructor Summary
private KeyUtil()
          Prevent instantiation
 
Method Summary
static Passage getPassage(Key key)
          Cast a Key to a Passage.
static Passage getPassage(Versification v11n, Key key)
          Deprecated. getPassage(Key)
static Verse getVerse(Key key)
          Cast a Key to a Verse.
static Verse getVerse(Versification v11n, Key key)
          Deprecated. use getVerse(Key)
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

getVerse

@Deprecated
public static Verse getVerse(Versification v11n,
                                        Key key)
Deprecated. use getVerse(Key)

Not all keys represent verses, but we ought to be able to get something close to a verse from anything that does verse like work.


getPassage

@Deprecated
public static Passage getPassage(Versification v11n,
                                            Key key)
Deprecated. getPassage(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:
v11n -
key - The key to cast
Returns:
The key cast to a Passage

Copyright ? 2003-2011