/** * @param key * @return */ private String getVersification(Key key) { String v11nName=""; if (key instanceof VerseKey) { // must save a VerseKey's versification along with the key! v11nName = ((VerseKey<?>) key).getVersification().getName(); } return v11nName; }
/** * Get the versification for the key or the default versification. * * @param key the key that should provide for the Versification * @return the versification for the key */ public static Versification getVersification(Key key) { if (key instanceof VerseKey) { return ((VerseKey) key).getVersification(); } return Versifications.instance().getVersification(Versifications.DEFAULT_V11N); } }
/** * 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. * * @param key The key to cast * @return The key cast to a Passage * @throws ClassCastException */ public static Passage getPassage(Key key) { if (key == null) { return null; } if (key instanceof Passage) { return (Passage) key; } if (key instanceof VerseKey) { VerseKey verseKey = (VerseKey) key; Key ref = PassageKeyFactory.instance().createEmptyKeyList(verseKey.getVersification()); ref.addAll(verseKey); return (Passage) ref; } throw new ClassCastException("Expected key to be a Verse, VerseRange or Passage"); }