org.crosswire.jsword.passage
Class VerseRangeFactory

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

public final class VerseRangeFactory
extends Object

A factory that creates VerseRanges from user input.

Distribution Licence:
JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
The copyright to this program is held by it's authors.

Version:
$Id: VerseRangeFactory.java,v 1.4 2004/09/21 17:46:23 dmsmith Exp $
Author:
Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
Licence

Constructor Summary
private VerseRangeFactory()
          prevent instantiation
 
Method Summary
static VerseRange fromString(String orginal)
          Construct a VerseRange from a human readable string.
static VerseRange fromString(String original, VerseRange basis)
          Construct a VerseRange from a String and a VerseRange.
private static VerseRange fromText(String original, String startVerseDesc, String endVerseDesc, VerseRange basis)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VerseRangeFactory

private VerseRangeFactory()
prevent instantiation

Method Detail

fromString

public static VerseRange fromString(String orginal)
                             throws NoSuchVerseException
Construct a VerseRange from a human readable string. For example "Gen 1:1-3" in case the user does not want to have their typing 'fixed' by a meddling patronizing computer.

Parameters:
orginal - The textual representation
Throws:
NoSuchVerseException - If the text can not be understood

fromString

public static VerseRange fromString(String original,
                                    VerseRange basis)
                             throws NoSuchVerseException
Construct a VerseRange from a String and a VerseRange. For example given "2:2" and a basis of Gen 1:1-2 the result would be range of 1 verse starting at Gen 2:2. Also given "2:2-5" and a basis of Gen 1:1-2 the result would be a range of 5 verses starting at Gen 1:1.

This constructor is different from the (String, Verse) constructor in that if the basis is a range that exactly covers a chapter and the string is a single number, then we assume that the number referrs to a chapter and not to a verse. This allows us to have a Passage like "Gen 1,2" and have the 2 understood as chapter 2 and not verse 2 of Gen 1, which would have occured otherwise.

Parameters:
original - The string describing the verse e.g "2:2"
basis - The verse that forms the basis by which to understand the orginal.
Throws:
NoSuchVerseException - If the reference is illegal

fromText

private static VerseRange fromText(String original,
                                   String startVerseDesc,
                                   String endVerseDesc,
                                   VerseRange basis)
                            throws NoSuchVerseException
Throws:
NoSuchVerseException

Copyright ? 2003-2004