public void setBasisRef(Key basisRef) { // KeyUtil always returns a Verse even if it is only Gen 1:1 this.basisRef = KeyUtil.getVerse(basisRef); } public boolean isRedLetter() {
final Passage ref = KeyUtil.getPassage(key); final Iterator<VerseRange> rit = ref.rangeIterator(RestrictionType.CHAPTER); while (rit.hasNext()) { currentVerse = KeyUtil.getVerse(verseInRange); try { String rawText = readRawContent(openFileState, currentVerse);
public String getOsisRef() { DefaultKeyVisitor visitor = new OsisRefVisitor(); KeyUtil.visit(this, visitor); return visitor.toString(); }
public boolean contains(Key key) { Passage ref = KeyUtil.getPassage(key); return containsAll(ref); }
@Override public void processContent(Book book, Key key, Element ele) { String refstr = ele.getValue(); try { if (ele.getAttribute(OSISUtil.OSIS_ATTR_REF) == null) { Passage ref = PassageKeyFactory.instance().getKey(KeyUtil.getVersification(key), refstr, key); String osisname = ref.getOsisRef(); ele.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname); } } catch (NoSuchKeyException ex) { DataPolice.report(book, key, "scripRef has no passage attribute, unable to guess: (" + refstr + ") due to " + ex.getMessage()); } } }
/** * Get a Passage containing all the Verses in this Versification. * This differs from {@link org.crosswire.jsword.book.Book#getGlobalKeyList} which gets the * verses in the Book, which may be a small part of the whole. * * @param v11n * The Versification to which this Passage belongs. * @return the Passage with all the Verses in the Versification */ public Key getGlobalKeyList(Versification v11n) { return new ReadOnlyPassage(KeyUtil.getPassage(v11n.getAllVerses()), true); }
@Override public Element processTag(Book book, Key key, Element ele, Attributes attrs) { Element reference = null; String refstr = attrs.getValue("passage"); if (refstr != null) { Passage ref = null; try { ref = PassageKeyFactory.instance().getKey(KeyUtil.getVersification(key), refstr, key); } catch (NoSuchKeyException ex) { DataPolice.report(book, key, "Unparsable passage: (" + refstr + ") due to " + ex.getMessage()); } // If we don't have a Passage then use the original string String osisname = ref != null ? ref.getOsisRef() : refstr; reference = OSISUtil.factory().createReference(); reference.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname); } else { // The reference will be filled in by processContent reference = OSISUtil.factory().createReference(); } if (ele != null) { ele.addContent(reference); } return reference; }
@Override public Verse getSingleKey() { Key key = doGetKey(true); // it is already a Verse but this avoids a downcast return KeyUtil.getVerse(key); }
Passage ref = VersificationsMapper.instance().map(KeyUtil.getPassage(key), this.getVersification());
public String getName() { if (name != null) { return name; } DefaultKeyVisitor visitor = new NameVisitor(); KeyUtil.visit(this, visitor); return visitor.toString(); }
public MyNoteMarker(OsisToHtmlParameters parameters, VerseInfo verseInfo, HtmlTextWriter writer) { this.parameters = parameters; this.verseInfo = verseInfo; this.writer = writer; // create hashmap of verses to optimise verse note lookup myNoteVerses.clear(); if (parameters.getVersesWithNotes()!=null) { for (Key key : parameters.getVersesWithNotes()) { Verse verse = KeyUtil.getVerse(key); myNoteVerses.add(verse.getVerse()); } } }
Passage ref = KeyUtil.getPassage(key); ref.trimVerses(35); dummyDisplay(ref);
public String getOsisID() { DefaultKeyVisitor visitor = new OsisIDVisitor(); KeyUtil.visit(this, visitor); return visitor.toString(); }
/** set key without notification * * @param key */ public void doSetKey(Key key) { if (key!=null) { Verse verse = KeyUtil.getVerse(key); //TODO av11n should this be the verse Versification or the Module/doc's Versification getCurrentBibleVerse().setVerseSelected(getVersification(), verse); } }
passages[i] = VersificationsMapper.instance().map(KeyUtil.getPassage(key), getVersification(i)); Passage passageOfInterest = KeyUtil.getPassage(verseInRelavantBookContents); Iterator<Key> passageKeys = passageOfInterest.iterator(); while (passageKeys.hasNext()) {
/** * Walk through a tree visiting the nodes and branches in the tree * * @param key * The node tree to walk through * @param visitor * The visitor to notify whenever a node is found */ public static void visit(Key key, KeyVisitor visitor) { for (Key subkey : key) { if (subkey.canHaveChildren()) { visitor.visitBranch(subkey); visit(subkey, visitor); } else { visitor.visitLeaf(subkey); } } }
/** set key without notification * * @param key */ public void doSetKey(Key key) { if (key!=null) { Verse verse = KeyUtil.getVerse(key); getCurrentBibleVerse().setVerseSelected(getVersification(), verse); } }
private boolean isStartOrEndOfBook(Key key) { boolean isStartOrEnd = false; try { if (key instanceof VerseKey) { Verse verse = KeyUtil.getVerse(key); int chapter = verse.getChapter(); BibleBook book = verse.getBook(); isStartOrEnd = chapter == 1 || chapter == verse.getVersification().getLastChapter(book); } } catch (Exception e) { Log.e(TAG, "Verse error", e); isStartOrEnd = false; } return isStartOrEnd; } }
/** * Convert the verse correctly to the v11n or return null */ @Nullable private Verse convertVerseStrictly(Verse verse, Versification toVersification) { try { Key key = versificationsMapper.mapVerse(verse, toVersification); Verse mappedVerse = KeyUtil.getVerse(key); // If target v11n does not contain mapped verse then an exception normally occurs and the ordinal is set to 0 if (mappedVerse.getOrdinal()>0) { return mappedVerse; } } catch (Exception e) { // unexpected problem during mapping Log.e(TAG, "JSword Versification mapper failed to map "+verse.getOsisID()+" from "+verse.getVersification().getName()+" to "+toVersification.getName(), e); } return null; } }
/** * get user note with this key if it exists or return null */ public MyNoteDto getMyNoteByStartVerse(Key key) { Verse startVerse = KeyUtil.getVerse(key); MyNoteDBAdapter db = new MyNoteDBAdapter(); MyNoteDto myNote = null; try { db.open(); myNote = db.getMyNoteByStartVerse(startVerse.getOsisRef()); } finally { db.close(); } return myNote; }