[jsword-svn] jsword/java/jsword/org/crosswire/jsword/passage s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Sat Aug 13 07:41:43 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage
In directory www.crosswire.org:/tmp/cvs-serv27888/java/jsword/org/crosswire/jsword/passage

Modified Files:
	DefaultLeafKeyList.java SynchronizedPassage.java 
	AbstractKeyList.java BibleInfo.java ReadOnlyKeyList.java 
	Key.java ReadOnlyPassage.java KeyFactory.java 
	AbstractPassage.java VerseBase.java Verse.java VerseRange.java 
Log Message:
Split getOSISName into getOsisRef and getOsisID, since these are different.

Index: SynchronizedPassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/SynchronizedPassage.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** SynchronizedPassage.java	27 Jul 2005 23:25:45 -0000	1.19
--- SynchronizedPassage.java	13 Aug 2005 14:41:40 -0000	1.20
***************
*** 138,144 ****
       * @see org.crosswire.jsword.passage.Passage#getOSISName()
       */
!     public synchronized String getOSISName()
      {
!         return ref.getOSISName();
      }
  
--- 138,152 ----
       * @see org.crosswire.jsword.passage.Passage#getOSISName()
       */
!     public synchronized String getOsisRef()
      {
!         return ref.getOsisRef();
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISId()
!      */
!     public String getOsisID()
!     {
!         return ref.getOsisID();
      }
  

Index: AbstractPassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/AbstractPassage.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** AbstractPassage.java	27 Jul 2005 23:25:45 -0000	1.47
--- AbstractPassage.java	13 Aug 2005 14:41:40 -0000	1.48
***************
*** 201,215 ****
       * @see org.crosswire.jsword.passage.Passage#getOSISName()
       */
!     public String getOSISName()
      {
          StringBuffer retcode = new StringBuffer();
  
          Iterator it = rangeIterator(RestrictionType.NONE);
!         while (it.hasNext())
          {
              VerseRange range = (VerseRange) it.next();
!             retcode.append(range.getOSISName());
  
!             if (it.hasNext())
              {
                  retcode.append(AbstractPassage.REF_OSIS_DELIM);
--- 201,241 ----
       * @see org.crosswire.jsword.passage.Passage#getOSISName()
       */
!     public String getOsisRef()
      {
          StringBuffer retcode = new StringBuffer();
  
          Iterator it = rangeIterator(RestrictionType.NONE);
!         boolean hasNext = it.hasNext();
!         while (hasNext)
          {
              VerseRange range = (VerseRange) it.next();
!             retcode.append(range.getOsisRef());
  
!             hasNext = it.hasNext();
!             if (hasNext)
!             {
!                 retcode.append(AbstractPassage.REF_OSIS_DELIM);
!             }
!         }
! 
!         return retcode.toString();
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISId()
!      */
!     public String getOsisID()
!     {
!         StringBuffer retcode = new StringBuffer();
! 
!         Iterator it = rangeIterator(RestrictionType.NONE);
!         boolean hasNext = it.hasNext();
!         while (hasNext)
!         {
!             VerseRange range = (VerseRange) it.next();
!             retcode.append(range.getOsisID());
! 
!             hasNext = it.hasNext();
!             if (hasNext)
              {
                  retcode.append(AbstractPassage.REF_OSIS_DELIM);

Index: Verse.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/Verse.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** Verse.java	27 Jul 2005 23:25:45 -0000	1.41
--- Verse.java	13 Aug 2005 14:41:40 -0000	1.42
***************
*** 248,252 ****
       * @return a String containing the OSIS description of the verses
       */
!     public String getOSISName()
      {
          try
--- 248,252 ----
       * @return a String containing the OSIS description of the verses
       */
!     public String getOsisRef()
      {
          try
***************
*** 265,268 ****
--- 265,276 ----
      }
  
+     /* (non-Javadoc)
+      * @see org.crosswire.jsword.passage.Key#getOSISId()
+      */
+     public String getOsisID()
+     {
+         return getOsisRef();
+     }
+ 
      /**
       * Get a copy of ourselves. Points to note:

Index: ReadOnlyKeyList.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/ReadOnlyKeyList.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** ReadOnlyKeyList.java	27 Jul 2005 23:25:45 -0000	1.10
--- ReadOnlyKeyList.java	13 Aug 2005 14:41:40 -0000	1.11
***************
*** 143,151 ****
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISName()
       */
!     public String getOSISName()
      {
!         return keys.getOSISName();
      }
  
--- 143,159 ----
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISRef()
       */
!     public String getOsisRef()
      {
!         return keys.getOsisRef();
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISId()
!      */
!     public String getOsisID()
!     {
!         return keys.getOsisID();
      }
  

Index: DefaultLeafKeyList.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/DefaultLeafKeyList.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** DefaultLeafKeyList.java	27 Jul 2005 23:25:45 -0000	1.9
--- DefaultLeafKeyList.java	13 Aug 2005 14:41:40 -0000	1.10
***************
*** 71,83 ****
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISName()
       */
!     public String getOSISName()
      {
          return osisName;
      }
  
!     /**
!      * @return Returns the parent of this key
       */
      public Key getParent()
--- 71,91 ----
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISRef()
       */
!     public String getOsisRef()
      {
          return osisName;
      }
  
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISId()
!      */
!     public String getOsisID()
!     {
!         return getOsisRef();
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getParent()
       */
      public Key getParent()

Index: Key.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/Key.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Key.java	27 Jul 2005 23:25:45 -0000	1.9
--- Key.java	13 Aug 2005 14:41:40 -0000	1.10
***************
*** 46,54 ****
  
      /**
!      * The OSIS defined specification for this Passage.
!      * Uses short books names, with "." as a verse part separator.
       * @return a String containing the OSIS description of the verses
       */
!     String getOSISName();
  
      /**
--- 46,68 ----
  
      /**
!      * The OSIS defined reference specification for this Key.
!      * When the key is a single element, it is an OSIS book name with '.'
!      * separating the parts. When the key is multiple elements, it 
!      * uses a range notation. Note, this will create a comma separated
!      * list of ranges, which is improper OSIS.
!      *
       * @return a String containing the OSIS description of the verses
       */
!     String getOsisRef();
! 
!     /**
!      * The OSIS defined id specification for this Key.
!      * When the key is a single element, it is an OSIS book name with '.'
!      * separating the parts. When the key is multiple elements, it 
!      * uses a space to separate each.
!      *
!      * @return a String containing the OSIS description of the verses
!      */
!     String getOsisID();
  
      /**

Index: BibleInfo.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/BibleInfo.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** BibleInfo.java	12 Aug 2005 10:17:42 -0000	1.38
--- BibleInfo.java	13 Aug 2005 14:41:40 -0000	1.39
***************
*** 582,586 ****
  
          // Check the verse
!         if (validate && (verse < 1 || verse > versesInChapter(book, chapter)))
          {
              Object[] params = new Object[]
--- 582,586 ----
  
          // Check the verse
!         if (verse < 1 || verse > versesInChapter(book, chapter))
          {
              Object[] params = new Object[]
***************
*** 596,615 ****
  
      /**
-      * @return Returns the validate.
-      */
-     public static boolean isValidate()
-     {
-         return validate;
-     }
- 
-     /**
-      * @param validate The validate to set.
-      */
-     public static void setValidate(boolean validate)
-     {
-         BibleInfo.validate = validate;
-     }
- 
-     /**
       * Does the following represent a real verse?
       * @param ref An array of 3 ints, book, chapter, verse
--- 596,599 ----
***************
*** 962,970 ****
  
      /**
-      * Whether validate should throw an exception.
-      */
-     private static boolean validate = true;
- 
-     /**
       * Handy section finder. There is a bit of moderately bad programming
       * here because org.crosswire.jsword.control.map.sw*ng.GroupVerseColor
--- 946,949 ----

Index: AbstractKeyList.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/AbstractKeyList.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** AbstractKeyList.java	27 Jul 2005 23:25:45 -0000	1.13
--- AbstractKeyList.java	13 Aug 2005 14:41:40 -0000	1.14
***************
*** 130,138 ****
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISName()
       */
!     public String getOSISName()
      {
!         DefaultKeyVisitor visitor = new OSISNameVisitor();
          KeyUtil.visit(this, visitor);
          return visitor.toString();
--- 130,148 ----
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISRef()
       */
!     public String getOsisRef()
      {
!         DefaultKeyVisitor visitor = new OsisRefVisitor();
!         KeyUtil.visit(this, visitor);
!         return visitor.toString();
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISId()
!      */
!     public String getOsisID()
!     {
!         DefaultKeyVisitor visitor = new OsisIDVisitor();
          KeyUtil.visit(this, visitor);
          return visitor.toString();
***************
*** 218,222 ****
              {
                  // strip off the final ", "
!                 reply = reply.substring(0, reply.length() - AbstractPassage.REF_OSIS_DELIM.length());
              }
  
--- 228,232 ----
              {
                  // strip off the final ", "
!                 reply = reply.substring(0, reply.length() - AbstractPassage.REF_PREF_DELIM.length());
              }
  
***************
*** 228,235 ****
  
      /** 
!      * The <code>OSISNameVisitor</code> constructs a readable representation
       * of the Passage, using OSIS names.
       */
!     private static class OSISNameVisitor extends NameVisitor
      {
          /* (non-Javadoc)
--- 238,245 ----
  
      /** 
!      * The <code>OsisRefVisitor</code> constructs a readable representation
       * of the Passage, using OSIS names.
       */
!     private static class OsisRefVisitor extends NameVisitor
      {
          /* (non-Javadoc)
***************
*** 238,246 ****
          public void visitLeaf(Key key)
          {
!             buffer.append(key.getOSISName());
              buffer.append(AbstractPassage.REF_PREF_DELIM);
          }
      }
  
      /**
       * The common user visible name for this work
--- 248,286 ----
          public void visitLeaf(Key key)
          {
!             buffer.append(key.getOsisRef());
              buffer.append(AbstractPassage.REF_PREF_DELIM);
          }
      }
  
+     /** 
+      * The <code>OsisRefVisitor</code> constructs a readable representation
+      * of the Passage, using OSIS names.
+      */
+     private static class OsisIDVisitor extends NameVisitor
+     {
+         /* (non-Javadoc)
+          * @see org.crosswire.jsword.passage.KeyVisitor#visitLeaf(org.crosswire.jsword.passage.Key)
+          */
+         public void visitLeaf(Key key)
+         {
+             buffer.append(key.getOsisID());
+             buffer.append(AbstractPassage.REF_OSIS_DELIM);
+         }
+         /* (non-Javadoc)
+          * @see java.lang.Object#toString()
+          */
+         public String toString()
+         {
+             String reply = super.toString();
+             if (reply.length() > 0)
+             {
+                 // strip off the final " "
+                 reply = reply.substring(0, reply.length() - AbstractPassage.REF_OSIS_DELIM.length());
+             }
+ 
+             return reply;
+         }
+     }
+ 
      /**
       * The common user visible name for this work

Index: VerseBase.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/VerseBase.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** VerseBase.java	27 Jul 2005 23:25:45 -0000	1.15
--- VerseBase.java	13 Aug 2005 14:41:40 -0000	1.16
***************
*** 55,59 ****
       * @return a String containing the OSIS description of the verses
       */
!     String getOSISName();
  
      /**
--- 55,59 ----
       * @return a String containing the OSIS description of the verses
       */
!     String getOsisRef();
  
      /**

Index: KeyFactory.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/KeyFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** KeyFactory.java	12 Aug 2005 21:00:27 -0000	1.9
--- KeyFactory.java	13 Aug 2005 14:41:40 -0000	1.10
***************
*** 48,52 ****
       */
      Key getValidKey(String name);
!     
      /**
       * Someone has typed in a reference to find, but we need a Key to actually
--- 48,52 ----
       */
      Key getValidKey(String name);
! 
      /**
       * Someone has typed in a reference to find, but we need a Key to actually

Index: VerseRange.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/VerseRange.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** VerseRange.java	27 Jul 2005 23:25:45 -0000	1.45
--- VerseRange.java	13 Aug 2005 14:41:40 -0000	1.46
***************
*** 236,282 ****
  
      /**
!      * The OSIS defined specification for this VerseRange.
!      * Uses short books names, with "." as a verse part separator.
!      * NOTE(joe): Technically wrong - we should list verses separated by spaces
!      * But that could get very messy, so I'm keeping things simple.
       * @return a String containing the OSIS description of the verses
       */
!     public String getOSISName()
      {
-         // Cache these we're going to be using them a lot.
-         int startBook = start.getBook();
-         int startChapter = start.getChapter();
-         int startVerse = start.getVerse();
-         int endBook = end.getBook();
-         int endChapter = end.getChapter();
-         int endVerse = end.getVerse();
- 
          try
          {
              // If this is in 2 separate books
              if (startBook != endBook)
              {
!                 // This range is exactly a whole book
!                 if (isWholeBooks())
!                 {
!                     // Just report the name of the book, we don't need to worry about the
!                     // base since we start at the start of a book, and should have been
!                     // recently normalized()
!                     return BibleInfo.getOSISName(startBook)
!                          + VerseRange.RANGE_PREF_DELIM
!                          + BibleInfo.getOSISName(endBook);
!                 }
! 
!                 // If this range is exactly a whole chapter
!                 if (isWholeChapters())
!                 {
!                     // Just report book and chapter names
!                     return BibleInfo.getOSISName(startBook)
!                          + Verse.VERSE_OSIS_DELIM + startChapter
!                          + VerseRange.RANGE_PREF_DELIM + BibleInfo.getOSISName(endBook)
!                          + Verse.VERSE_OSIS_DELIM + endChapter;
!                 }
! 
!                 return start.getOSISName() + VerseRange.RANGE_PREF_DELIM + end.getOSISName();
              }
  
--- 236,253 ----
  
      /**
!      * The OSIS defined reference specification for this VerseRange.
!      * Uses osis books names, with "." as a verse part separator.
       * @return a String containing the OSIS description of the verses
       */
!     public String getOsisRef()
      {
          try
          {
              // If this is in 2 separate books
+             int startBook = start.getBook();
+             int endBook = end.getBook();
              if (startBook != endBook)
              {
!                 return start.getOsisRef() + VerseRange.RANGE_PREF_DELIM + end.getOsisRef();
              }
  
***************
*** 291,308 ****
  
              // If this is 2 separate chapters
              if (startChapter != endChapter)
              {
!                 // If this range is a whole number of chapters
!                 if (isWholeChapters())
!                 {
!                     // Just report the name of the book and the chapters
!                     return BibleInfo.getOSISName(startBook)
!                          + Verse.VERSE_OSIS_DELIM + startChapter
!                          + VerseRange.RANGE_PREF_DELIM + endChapter;
!                 }
! 
!                 return start.getOSISName()
!                      + VerseRange.RANGE_PREF_DELIM + endChapter
!                      + Verse.VERSE_OSIS_DELIM + endVerse;
              }
  
--- 262,270 ----
  
              // If this is 2 separate chapters
+             int startChapter = start.getChapter();
+             int endChapter = end.getChapter();
              if (startChapter != endChapter)
              {
!                 return start.getOsisRef() + VerseRange.RANGE_PREF_DELIM + end.getOsisRef();
              }
  
***************
*** 311,327 ****
              {
                  // Just report the name of the book and the chapter
!                 return BibleInfo.getOSISName(startBook)
!                      + Verse.VERSE_OSIS_DELIM + startChapter;
              }
  
              // If this is 2 separate verses
!             if (startVerse != endVerse)
              {
!                 return start.getOSISName()
!                      + VerseRange.RANGE_PREF_DELIM + endVerse;
              }
  
              // The range is a single verse
!             return start.getOSISName();
          }
          catch (NoSuchVerseException ex)
--- 273,287 ----
              {
                  // Just report the name of the book and the chapter
!                 return BibleInfo.getOSISName(startBook) + Verse.VERSE_OSIS_DELIM + startChapter;
              }
  
              // If this is 2 separate verses
!             if (start.getVerse() != end.getVerse())
              {
!                 return start.getOsisRef() + VerseRange.RANGE_PREF_DELIM + end.getOsisRef();
              }
  
              // The range is a single verse
!             return start.getOsisRef();
          }
          catch (NoSuchVerseException ex)
***************
*** 333,336 ****
--- 293,333 ----
  
      /**
+      * The OSIS defined id specification for this VerseRange.
+      * Uses osis books names, with "." as a verse part separator.
+      * Each verse is separated by a space.
+      * @return a String containing the OSIS description of the verses
+      */
+     public String getOsisID()
+     {
+         int startOrdinal = start.getOrdinal();
+         int endOrdinal = end.getOrdinal();
+ 
+         // Estimate the size of the buffer: book.dd.dd (where book is 3-5, 3 typical)
+         StringBuffer buf = new StringBuffer((endOrdinal - startOrdinal + 1) * 10);
+         buf.append(start.getOsisID());
+         for (int i = startOrdinal; i < endOrdinal; i++)
+         {
+             try
+             {
+                 buf.append(AbstractPassage.REF_OSIS_DELIM);
+                 buf.append(new Verse(i).getOsisID());
+             }
+             catch (NoSuchVerseException e)
+             {
+                 assert false : e;
+             }
+         }
+ 
+         // It just might be a single verse range!
+         if (startOrdinal != endOrdinal)
+         {
+             buf.append(AbstractPassage.REF_OSIS_DELIM);
+             buf.append(end.getOsisID());
+         }
+ 
+         return buf.toString();
+     }
+ 
+     /**
       * This just clones getName which seems the most sensible
       * type of string to return.

Index: ReadOnlyPassage.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/passage/ReadOnlyPassage.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** ReadOnlyPassage.java	27 Jul 2005 23:25:45 -0000	1.23
--- ReadOnlyPassage.java	13 Aug 2005 14:41:40 -0000	1.24
***************
*** 154,160 ****
       * @see org.crosswire.jsword.passage.Passage#getOSISName()
       */
!     public String getOSISName()
      {
!         return ref.getOSISName();
      }
  
--- 154,168 ----
       * @see org.crosswire.jsword.passage.Passage#getOSISName()
       */
!     public String getOsisRef()
      {
!         return ref.getOsisRef();
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.passage.Key#getOSISId()
!      */
!     public String getOsisID()
!     {
!         return ref.getOsisID();
      }
  



More information about the jsword-svn mailing list