[jsword-svn] r1220 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/book bibledesktop/src/main/java/org/crosswire/bibledesktop/passage jsword/src/main/java/org/crosswire/jsword/examples jsword/src/main/java/org/crosswire/jsword/passage jsword/src/test/java/org/crosswire/jsword/passage jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Tue Dec 19 14:10:44 MST 2006
Author: dmsmith
Date: 2006-12-19 14:10:44 -0700 (Tue, 19 Dec 2006)
New Revision: 1220
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/KeyTreeNode.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferenceBookTreeNode.java
trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultKeyList.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
Log:
More work on Raw GenBook. Getting ready for TreeKeys
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -288,7 +288,7 @@
modifier.setRanked(rank);
Key results = selected.find(new DefaultSearchRequest(param, modifier));
- int total = results.getChildCount();
+ int total = results.getCardinality();
int partial = total;
// we get PassageTallys for rank searches
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeyListListModel.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -47,7 +47,7 @@
*/
public int getSize()
{
- return keys != null ? keys.getChildCount() : 0;
+ return keys != null ? keys.getCardinality() : 0;
}
/**
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -180,7 +180,7 @@
modifier.setRanked(rank);
Key results = bible.find(new DefaultSearchRequest("for god so loved the world", modifier)); //$NON-NLS-1$
- int total = results.getChildCount();
+ int total = results.getCardinality();
int partial = total;
// we get PassageTallys for rank searches
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -37,7 +37,7 @@
*/
public boolean isEmpty()
{
- return getChildCount() == 0;
+ return getCardinality() == 0;
}
/* (non-Javadoc)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -795,9 +795,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
*/
- public int getChildCount()
+ public int getCardinality()
{
return countVerses();
}
@@ -825,7 +825,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#isLeaf()
+ * @see org.crosswire.jsword.passage.Key#canHaveChildren()
*/
public boolean canHaveChildren()
{
@@ -833,6 +833,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
+ */
+ public int getChildCount()
+ {
+ return 0;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#get(int)
*/
public Key get(int index)
@@ -1292,7 +1300,7 @@
{
VerseRange range = (VerseRange) it.next();
out.writeInt(range.getStart().getOrdinal());
- out.writeInt(range.getVerseCount());
+ out.writeInt(range.getCardinality());
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultKeyList.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultKeyList.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -55,7 +55,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#isLeaf()
+ * @see org.crosswire.jsword.passage.Key#canHaveChildren()
*/
public boolean canHaveChildren()
{
@@ -63,10 +63,18 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
*/
public int getChildCount()
{
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
+ */
+ public int getCardinality()
+ {
return keys.size();
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -61,6 +61,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
+ */
+ public int getChildCount()
+ {
+ return 0;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.Key#getText()
*/
public String getName()
@@ -101,11 +109,11 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
*/
- public int getChildCount()
+ public int getCardinality()
{
- return 0;
+ return 1;
}
/* (non-Javadoc)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -84,18 +84,23 @@
Key getParent();
/**
- * Returns true if the receiver is a leaf node and can not have children.
+ * Returns false if the receiver is a leaf node and can not have children.
* Any attempt to add()/remove() wlll throw
*/
boolean canHaveChildren();
/**
+ * Returns the number of children that this node has. Leaf nodes return 0.
+ */
+ int getChildCount();
+
+ /**
* Returns the number of elements in this set (its cardinality). If this
* set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
* @return the number of elements in this set (its cardinality).
*/
- int getChildCount();
+ int getCardinality();
/**
* Does this Passage have 0 members
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -258,7 +258,7 @@
{
VerseRange range = (VerseRange) it.next();
index += toBinary(buffer, index, range.getStart().getOrdinal(), BibleInfo.versesInBible());
- index += toBinary(buffer, index, range.getVerseCount(), BibleInfo.versesInBible());
+ index += toBinary(buffer, index, range.getCardinality(), BibleInfo.versesInBible());
}
// chop to size
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -130,7 +130,7 @@
while (it.hasNext())
{
VerseRange range = (VerseRange) it.next();
- count += range.getVerseCount();
+ count += range.getCardinality();
}
return count;
@@ -392,7 +392,7 @@
{
VerseRange range = (VerseRange) it.next();
- for (int i = 0; i < range.getVerseCount(); i++)
+ for (int i = 0; i < range.getCardinality(); i++)
{
temp.add(new Verse(range.getStart().getOrdinal() + i));
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -42,15 +42,15 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
*/
- public int getChildCount()
+ public int getCardinality()
{
- return keys.getChildCount();
+ return keys.getCardinality();
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#isLeaf()
+ * @see org.crosswire.jsword.passage.Key#canHaveChildren()
*/
public boolean canHaveChildren()
{
@@ -58,6 +58,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
+ */
+ public int getChildCount()
+ {
+ return keys.getChildCount();
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#isEmpty()
*/
public boolean isEmpty()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -95,7 +95,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#isLeaf()
+ * @see org.crosswire.jsword.passage.Key#canHaveChildren()
*/
public boolean canHaveChildren()
{
@@ -103,7 +103,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
*/
public int getChildCount()
{
@@ -111,6 +111,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
+ */
+ public int getCardinality()
+ {
+ return ref.getCardinality();
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#iterator()
*/
public Iterator iterator()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -142,15 +142,15 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
*/
- public int getChildCount()
+ public int getCardinality()
{
return list.size();
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#isLeaf()
+ * @see org.crosswire.jsword.passage.Key#canHaveChildren()
*/
public boolean canHaveChildren()
{
@@ -158,6 +158,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
+ */
+ public int getChildCount()
+ {
+ return 0;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#get(int)
*/
public Key get(int index)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -79,16 +79,24 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
*/
- public synchronized int getChildCount()
+ public int getChildCount()
{
return ref.getChildCount();
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#isLeaf()
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
*/
+ public synchronized int getCardinality()
+ {
+ return ref.getCardinality();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#canHaveChildren()
+ */
public boolean canHaveChildren()
{
return ref.canHaveChildren();
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -878,7 +878,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
*/
public int getChildCount()
{
@@ -886,6 +886,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
+ */
+ public int getCardinality()
+ {
+ return 1;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#isEmpty()
*/
public boolean isEmpty()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -386,15 +386,6 @@
}
/**
- * How many verses in this range
- * @return The number of verses. Always >= 1.
- */
- public int getVerseCount()
- {
- return verseCount;
- }
-
- /**
* How many chapters in this range
* @return The number of chapters. Always >= 1.
*/
@@ -490,7 +481,7 @@
return false;
}
- if (vr.getVerseCount() != getVerseCount())
+ if (vr.getCardinality() != getCardinality())
{
return false;
}
@@ -536,15 +527,15 @@
int that_length = 1;
if (obj instanceof VerseRange)
{
- that_length = ((VerseRange) obj).getVerseCount();
+ that_length = ((VerseRange) obj).getCardinality();
}
- if (that_length == getVerseCount())
+ if (that_length == getCardinality())
{
return 0;
}
- if (that_length < getVerseCount())
+ if (that_length < getCardinality())
{
return 1;
}
@@ -1035,7 +1026,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Key#size()
+ * @see org.crosswire.jsword.passage.Key#getChildCount()
*/
public int getChildCount()
{
@@ -1043,6 +1034,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getCardinality()
+ */
+ public int getCardinality()
+ {
+ return verseCount;
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#isEmpty()
*/
public boolean isEmpty()
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -440,17 +440,17 @@
public void testGetVerseCount() throws Exception
{
- assertEquals(gen11_1.getVerseCount(), 1);
- assertEquals(gen11_2.getVerseCount(), 2);
- assertEquals(gen11_9.getVerseCount(), 31);
- assertEquals(gen11_a.getVerseCount(), 32);
- assertEquals(gen12_1.getVerseCount(), 1);
- assertEquals(gen_all.getVerseCount(), 1533);
- assertEquals(gen_ex1.getVerseCount(), 1534);
- assertEquals(gen_rev.getVerseCount(), 31102);
- assertEquals(rev99_9.getVerseCount(), 21);
- assertEquals(rev11_9.getVerseCount(), 404);
- assertEquals(rev99_1.getVerseCount(), 1);
+ assertEquals(gen11_1.getCardinality(), 1);
+ assertEquals(gen11_2.getCardinality(), 2);
+ assertEquals(gen11_9.getCardinality(), 31);
+ assertEquals(gen11_a.getCardinality(), 32);
+ assertEquals(gen12_1.getCardinality(), 1);
+ assertEquals(gen_all.getCardinality(), 1533);
+ assertEquals(gen_ex1.getCardinality(), 1534);
+ assertEquals(gen_rev.getCardinality(), 31102);
+ assertEquals(rev99_9.getCardinality(), 21);
+ assertEquals(rev11_9.getCardinality(), 404);
+ assertEquals(rev99_1.getCardinality(), 1);
}
public void testClone() throws Exception
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/KeyTreeNode.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/KeyTreeNode.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/KeyTreeNode.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -51,7 +51,7 @@
*/
public int getChildCount()
{
- return key.getChildCount();
+ return key.getCardinality();
}
/* (non-Javadoc)
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferenceBookTreeNode.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferenceBookTreeNode.java 2006-12-19 20:33:05 UTC (rev 1219)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/reference/ReferenceBookTreeNode.java 2006-12-19 21:10:44 UTC (rev 1220)
@@ -74,7 +74,7 @@
*/
public int getChildCount()
{
- return keys.getChildCount();
+ return keys.getCardinality();
}
/* (non-Javadoc)
More information about the jsword-svn
mailing list