[jsword-svn] r1871 - trunk/jsword/src/main/java/org/crosswire/jsword/book

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Mon Jun 9 04:51:44 MST 2008


Author: dmsmith
Date: 2008-06-09 04:51:44 -0700 (Mon, 09 Jun 2008)
New Revision: 1871

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
Log:
Fixed an indexing bug, found in ESV Ps.95.9, where adjacent words were run together.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2008-06-08 15:26:02 UTC (rev 1870)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java	2008-06-09 11:51:44 UTC (rev 1871)
@@ -671,7 +671,15 @@
             }
             else if (data instanceof Text)
             {
-                buffer.append(((Text) data).getText());
+                // make sure that adjacent text elements are separated by whitespace
+                // TODO(dms): verify that the xml parser does not split words containing entities.
+                int lastIndex = buffer.length() - 1;
+                String text = ((Text) data).getText();
+                if (lastIndex >= 0 && !Character.isWhitespace(buffer.charAt(lastIndex)) && !Character.isWhitespace(text.charAt(0)))
+                {
+                    buffer.append(' ');
+                }
+                buffer.append(text);
             }
         }
 
@@ -826,7 +834,15 @@
             }
             else if (data instanceof Text)
             {
-                buffer.append(((Text) data).getText());
+                // make sure that adjacent text elements are separated by whitespace
+                // TODO(dms): verify that the xml parser does not split words containing entities.
+                int lastIndex = buffer.length() - 1;
+                String text = ((Text) data).getText();
+                if (lastIndex >= 0 && !Character.isWhitespace(buffer.charAt(lastIndex)) && !Character.isWhitespace(text.charAt(0)))
+                {
+                    buffer.append(' ');
+                }
+                buffer.append(text);
             }
         }
     }




More information about the jsword-svn mailing list