Coverage Report - org.crosswire.jsword.passage.VerseFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
VerseFactory
0%
0/15
0%
0/12
2.333
 
 1  
 /**
 2  
  * Distribution License:
 3  
  * JSword is free software; you can redistribute it and/or modify it under
 4  
  * the terms of the GNU Lesser General Public License, version 2.1 or later
 5  
  * as published by the Free Software Foundation. This program is distributed
 6  
  * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 7  
  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 8  
  * See the GNU Lesser General Public License for more details.
 9  
  *
 10  
  * The License is available on the internet at:
 11  
  *      http://www.gnu.org/copyleft/lgpl.html
 12  
  * or by writing to:
 13  
  *      Free Software Foundation, Inc.
 14  
  *      59 Temple Place - Suite 330
 15  
  *      Boston, MA 02111-1307, USA
 16  
  *
 17  
  * © CrossWire Bible Society, 2005 - 2016
 18  
  *
 19  
  */
 20  
 package org.crosswire.jsword.passage;
 21  
 
 22  
 import org.crosswire.jsword.versification.Versification;
 23  
 
 24  
 /**
 25  
  * A factory to create a Verse from user input.
 26  
  * 
 27  
  * @see gnu.lgpl.License The GNU Lesser General Public License for details.
 28  
  * @author Joe Walker
 29  
  */
 30  0
 public final class VerseFactory {
 31  
     /**
 32  
      * Prevent a VerseFactory from being created.
 33  
      */
 34  0
     private VerseFactory() {
 35  0
     }
 36  
 
 37  
     /**
 38  
      * Construct a Verse from a String - something like "Gen 1:1". in case the
 39  
      * user does not want to have their typing 'fixed' by a meddling patronizing
 40  
      * computer. The following initial letters can not be matched at all -
 41  
      * 'bfquvwx'.
 42  
      * 
 43  
      * @param v11n
 44  
      *            the versification to which this reference pertains
 45  
      * @param original
 46  
      *            The text string to be converted
 47  
      * @return the Verse representation of the string
 48  
      * @exception NoSuchVerseException
 49  
      *                If the text can not be understood
 50  
      */
 51  
     public static Verse fromString(Versification v11n, String original) throws NoSuchVerseException {
 52  0
         if ("".equals(original)) {
 53  0
             return null;
 54  
         }
 55  0
         String[] parts = AccuracyType.tokenize(original);
 56  0
         AccuracyType accuracy = AccuracyType.fromText(v11n, original, parts);
 57  0
         assert accuracy != null;
 58  0
         return accuracy.createStartVerse(v11n, null, parts);
 59  
     }
 60  
 
 61  
     /**
 62  
      * Construct a Verse from a String and a VerseRange. For example given "2:2"
 63  
      * and a basis of Gen 1:1 - 12 the result would be Gen 2:2
 64  
      * 
 65  
      * @param v11n
 66  
      *            the versification to which this reference pertains
 67  
      * @param original
 68  
      *            The string describing the verse e.g "2:2"
 69  
      * @param verseRangeBasis
 70  
      *            The basis by which to understand the desc.
 71  
      * @return the verse representation of the string
 72  
      * @exception NoSuchVerseException
 73  
      *                If the reference is illegal
 74  
      */
 75  
     public static Verse fromString(Versification v11n, String original, VerseRange verseRangeBasis) throws NoSuchVerseException {
 76  0
         if ("".equals(original)) {
 77  0
             return null;
 78  
         }
 79  0
         String[] parts = AccuracyType.tokenize(original);
 80  0
         AccuracyType accuracy = AccuracyType.fromText(v11n, original, parts, null, verseRangeBasis);
 81  0
         assert accuracy != null;
 82  0
         return accuracy.createStartVerse(v11n, verseRangeBasis, parts);
 83  
     }
 84  
 
 85  
 }