[jsword-svn] r2158 - in trunk/jsword/src: main/java/org/crosswire/jsword/book test/java/org/crosswire/jsword/book/sword

dmsmith at crosswire.org dmsmith at crosswire.org
Sat Apr 9 19:00:05 MST 2011


Author: dmsmith
Date: 2011-04-09 19:00:05 -0700 (Sat, 09 Apr 2011)
New Revision: 2158

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
   trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/ConfigEntryTableTest.java
Log:
JS-188 Fixed OSISUtil problem found by Martin Denham

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2011-04-09 16:22:00 UTC (rev 2157)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2011-04-10 02:00:05 UTC (rev 2158)
@@ -699,7 +699,7 @@
     public static String getStrongsNumbers(Element root) {
         StringBuilder buffer = new StringBuilder();
 
-        for (Content content : getDeepContent(root, OSISUtil.OSIS_ELEMENT_TITLE)) {
+        for (Content content : getDeepContent(root, OSISUtil.OSIS_ELEMENT_W)) {
             Element ele = (Element) content;
             String attr = ele.getAttributeValue(OSISUtil.ATTRIBUTE_W_LEMMA);
             if (attr != null) {
@@ -726,7 +726,7 @@
         KeyFactory keyf = PassageKeyFactory.instance();
         Key collector = keyf.createEmptyKeyList();
 
-        for (Content content : getDeepContent(root, OSISUtil.OSIS_ELEMENT_TITLE)) {
+        for (Content content : getDeepContent(root, OSISUtil.OSIS_ELEMENT_REFERENCE)) {
             Element ele = (Element) content;
             String attr = ele.getAttributeValue(OSISUtil.OSIS_ATTR_REF);
             if (attr != null) {
@@ -750,7 +750,7 @@
     public static String getNotes(Element root) {
         StringBuilder buffer = new StringBuilder();
 
-        for (Content content : getDeepContent(root, OSISUtil.OSIS_ELEMENT_TITLE)) {
+        for (Content content : getDeepContent(root, OSISUtil.OSIS_ELEMENT_NOTE)) {
             Element ele = (Element) content;
             String attr = ele.getAttributeValue(OSISUtil.OSIS_ATTR_TYPE);
             if (attr == null || !attr.equals(NOTETYPE_REFERENCE)) {

Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/ConfigEntryTableTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/ConfigEntryTableTest.java	2011-04-09 16:22:00 UTC (rev 2157)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/sword/ConfigEntryTableTest.java	2011-04-10 02:00:05 UTC (rev 2158)
@@ -27,6 +27,15 @@
 import junit.framework.TestCase;
 
 import org.crosswire.common.util.Language;
+import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookData;
+import org.crosswire.jsword.book.BookException;
+import org.crosswire.jsword.book.Books;
+import org.crosswire.jsword.book.FeatureType;
+import org.crosswire.jsword.book.OSISUtil;
+import org.crosswire.jsword.passage.Key;
+import org.crosswire.jsword.passage.NoSuchKeyException;
+import org.jdom.Element;
 
 /**
  * A Raw File format that allows for each verse to have it's own storage.
@@ -48,6 +57,40 @@
 
         table.add(ConfigEntryType.LANG, "de");
         assertEquals("de", ((Language) table.getValue(ConfigEntryType.LANG)).getCode());
+        FeatureType feature = FeatureType.STRONGS_NUMBERS;
+        table.add(ConfigEntryType.FEATURE, FeatureType.STRONGS_NUMBERS.toString());
+        if (table.match(ConfigEntryType.FEATURE, feature.toString())) {
+            assertTrue("Should have Strongs", true);
+        } else {
+            // Many "features" are GlobalOptionFilters, which in the Sword C++ API
+            // indicate a class to use for filtering.
+            // These mostly have the source type prepended to the feature
+            StringBuilder buffer = new StringBuilder((String) table.getValue(ConfigEntryType.SOURCE_TYPE));
+            buffer.append(feature);
+            if (table.match(ConfigEntryType.GLOBAL_OPTION_FILTER, buffer.toString())) {
+                assertTrue("Should have Strongs", true);
+            } else {
+                // But some do not
+                assertTrue("Should have Strongs",  table.match(ConfigEntryType.GLOBAL_OPTION_FILTER, feature.toString()));
+            }
+        }
+        Book book = Books.installed().getBook("KJV");
+        assertTrue("Should have Strongs", book.getBookMetaData().hasFeature(FeatureType.STRONGS_NUMBERS));
+
+        try {
+            Key key = book.getKey("Gen 1:1");
+            BookData data = new BookData(book, key);
+            try {
+                Element osis = data.getOsisFragment();
+                String strongsNumbers = OSISUtil.getStrongsNumbers(osis);
+                assertTrue("No Strongs in KJV", strongsNumbers.length()>0);
+            } catch (BookException e) {
+                fail("Should have Gen 1:1 data");
+            }
+        } catch (NoSuchKeyException e1) {
+            fail("Should have Gen 1:1 key");
+        }
+        
     }
 
     public void testSaveConfigEntryTable() {




More information about the jsword-svn mailing list