[jsword-svn] r1332 - in trunk/jsword/src/main/java/org/crosswire/jsword: book/basic book/sword passage
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Fri May 18 04:42:15 MST 2007
Author: dmsmith
Date: 2007-05-18 04:42:14 -0700 (Fri, 18 May 2007)
New Revision: 1332
Modified:
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java
Log:
Improved handling of titles:
For Bibles, if there are not 2 or more ranges then don't output titles.
For GenBooks, don't output titles, as it is in the doc.
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2007-05-17 21:32:21 UTC (rev 1331)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2007-05-18 11:42:14 UTC (rev 1332)
@@ -67,22 +67,26 @@
{
Element osis = OSISUtil.createOsisFramework(getBookMetaData());
Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
+ Element div = OSISUtil.factory().createDiv();
+ text.addContent(div);
// For all the ranges in this Passage
Passage ref = KeyUtil.getPassage(key);
+ boolean hasRanges = ref.hasRanges(RestrictionType.CHAPTER);
Iterator rit = ref.rangeIterator(RestrictionType.CHAPTER);
while (rit.hasNext())
{
VerseRange range = (VerseRange) rit.next();
- Element div = OSISUtil.factory().createDiv();
- text.addContent(div);
+ // Only add the title if there are multiple ranges
+ if (hasRanges)
+ {
+ Element title = OSISUtil.factory().createTitle();
+ title.addContent(range.getName());
+ div.addContent(title);
+ }
- Element title = OSISUtil.factory().createTitle();
- title.addContent(range.getName());
- div.addContent(title);
-
// For all the verses in this range
Iterator vit = range.iterator();
while (vit.hasNext())
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java 2007-05-17 21:32:21 UTC (rev 1331)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java 2007-05-18 11:42:14 UTC (rev 1332)
@@ -123,9 +123,6 @@
Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
Element div = OSISUtil.factory().createDiv();
- Element title = OSISUtil.factory().createTitle();
- title.addContent(key.getName());
- div.addContent(title);
text.addContent(div);
String txt = backend.getRawText(key);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java 2007-05-17 21:32:21 UTC (rev 1331)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java 2007-05-18 11:42:14 UTC (rev 1332)
@@ -318,6 +318,27 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Passage#hasRanges(int)
+ */
+ public boolean hasRanges(RestrictionType restrict)
+ {
+ int count = 0;
+
+ Iterator it = rangeIterator(restrict);
+ while (it.hasNext())
+ {
+ it.next();
+ count++;
+ if (count == 2)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#countRanges(int)
*/
public int countRanges(RestrictionType restrict)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java 2007-05-17 21:32:21 UTC (rev 1331)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java 2007-05-18 11:42:14 UTC (rev 1332)
@@ -90,6 +90,15 @@
int countVerses();
/**
+ * Determine whether there are two or more ranges.
+ *
+ * @param restrict Do we break ranges at chapter/book boundries
+ * @return whether there are two or more ranges
+ * @see VerseRange
+ */
+ boolean hasRanges(RestrictionType restrict);
+
+ /**
* Like countVerses() that counts VerseRanges instead of Verses
* Returns the number of fragments in this collection.
* This does not mean the Passage needs to use VerseRanges, just that it
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java 2007-05-17 21:32:21 UTC (rev 1331)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java 2007-05-18 11:42:14 UTC (rev 1332)
@@ -215,8 +215,16 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#countRanges(int)
+ * @see org.crosswire.jsword.passage.Passage#hasRanges(org.crosswire.jsword.passage.RestrictionType)
*/
+ public boolean hasRanges(RestrictionType restrict)
+ {
+ return ref.hasRanges(restrict);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Passage#countRanges(org.crosswire.jsword.passage.RestrictionType)
+ */
public int countRanges(RestrictionType restrict)
{
return ref.countRanges(restrict);
@@ -231,7 +239,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#trimRanges(int, int)
+ * @see org.crosswire.jsword.passage.Passage#trimRanges(int, org.crosswire.jsword.passage.RestrictionType)
*/
public Passage trimRanges(int count, RestrictionType restrict)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java 2007-05-17 21:32:21 UTC (rev 1331)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java 2007-05-18 11:42:14 UTC (rev 1332)
@@ -196,8 +196,16 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#countRanges(int)
+ * @see org.crosswire.jsword.passage.Passage#hasRanges(org.crosswire.jsword.passage.RestrictionType)
*/
+ public synchronized boolean hasRanges(RestrictionType restrict)
+ {
+ return ref.hasRanges(restrict);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Passage#countRanges(org.crosswire.jsword.passage.RestrictionType)
+ */
public synchronized int countRanges(RestrictionType restrict)
{
return ref.countRanges(restrict);
@@ -212,7 +220,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#trimRanges(int, int)
+ * @see org.crosswire.jsword.passage.Passage#trimRanges(int, org.crosswire.jsword.passage.RestrictionType)
*/
public synchronized Passage trimRanges(int count, RestrictionType restrict)
{
More information about the jsword-svn
mailing list