private static NoSuchVerseException buildVersePartsException(String original, String[] parts) { StringBuilder buffer = new StringBuilder(original); for (int i = 0; i < parts.length; i++) { buffer.append(", ").append(parts[i]); } // TRANSLATOR: The user specified a verse with too many separators. {0} is a placeholder for the allowable separators. return new NoSuchVerseException(JSMsg.gettext("Too many parts to the Verse. (Parts are separated by any of {0})", buffer.toString())); }
/** * 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 * * @param text * The string to be parsed * @return The correctly parsed chapter or verse */ protected static int parseInt(String text) throws NoSuchVerseException { try { return Integer.parseInt(shaper.unshape(text)); } catch (NumberFormatException ex) { // TRANSLATOR: The chapter or verse number is actually not a number, but something else. // {0} is a placeholder for what the user supplied. throw new NoSuchVerseException(JSMsg.gettext("Cannot understand {0} as a chapter or verse.", text)); } }
if (tokenCount >= args.length) { throw new NoSuchVerseException(JSMsg.gettext("Too many parts to the Verse. (Parts are separated by any of {0})", input)); throw new NoSuchVerseException(JSMsg.gettext("Too many parts to the Verse. (Parts are separated by any of {0})", input));
/** * 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 * * @param text * The string to be parsed * @return The correctly parsed chapter or verse * @exception NoSuchVerseException * If the reference is illegal */ private static int parseInt(String text) throws NoSuchVerseException { try { return Integer.parseInt(new NumberShaper().unshape(text)); } catch (NumberFormatException ex) { // TRANSLATOR: The chapter or verse number is actually not a number, but something else. // {0} is a placeholder for what the user supplied. throw new NoSuchVerseException(JSMsg.gettext("Cannot understand {0} as a chapter or verse.", text)); } }
throw new NoSuchVerseException(JSOtherMsg.lookupText("Book must not be null")); throw new NoSuchVerseException(JSMsg.gettext("Chapter should be between {0} and {1,number,integer} for {2} (given {3,number,integer}).", Integer.valueOf(0), Integer.valueOf(maxChapter), getPreferredName(book), Integer.valueOf(chapter) )); throw new NoSuchVerseException(JSMsg.gettext("Verse should be between {0} and {1,number,integer} for {2} {3,number,integer} (given {4,number,integer}).", Integer.valueOf(0), Integer.valueOf(maxVerse), getPreferredName(book), Integer.valueOf(chapter), Integer.valueOf(verse) ));
@Override public Verse createStartVerse(Versification v11n, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException { if (verseRangeBasis == null) { // TRANSLATOR: The user supplied a verse reference but did not give the book of the Bible. throw new NoSuchVerseException(JSMsg.gettext("Book is missing")); } BibleBook book = verseRangeBasis.getEnd().getBook(); int chapter = getChapter(v11n, book, parts[0]); int verse = 0; // chapter > 0 ? 1 : 0; // 0 ? return new Verse(v11n, book, chapter, verse); }
throw new NoSuchVerseException(JSMsg.gettext("A verse range cannot have more than 2 parts. (Parts are separated by {0}) Given {1}", VerseRange.RANGE_OSIS_DELIM, original));
@Override public Verse createStartVerse(Versification v11n, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException { if (verseRangeBasis == null) { // TRANSLATOR: The user supplied a verse reference but did not give the book of the Bible. throw new NoSuchVerseException(JSMsg.gettext("Book is missing")); } BibleBook book = verseRangeBasis.getEnd().getBook(); int chapter = getChapter(v11n, book, parts[0]); int verse = getVerse(v11n, book, chapter, parts[1]); return new Verse(v11n, book, chapter, verse, getSubIdentifier(parts)); }
@Override public Verse createStartVerse(Versification v11n, VerseRange verseRangeBasis, String[] parts) throws NoSuchVerseException { if (verseRangeBasis == null) { // TRANSLATOR: The user supplied a verse reference but did not give the book or chapter of the Bible. throw new NoSuchVerseException(JSMsg.gettext("Book and chapter are missing")); } BibleBook book = verseRangeBasis.getEnd().getBook(); int chapter = verseRangeBasis.getEnd().getChapter(); int verse = getVerse(v11n, book, chapter, parts[0]); return new Verse(v11n, book, chapter, verse, getSubIdentifier(parts)); }