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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Mon Jan 24 17:02:34 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book
In directory www.crosswire.org:/tmp/cvs-serv22965/java/jsword/org/crosswire/jsword/book

Modified Files:
	Msg.java Msg.properties StudyTool.java Books.java 
	BookFilterIterator.java 
Added Files:
	BookMetaDataSet.java 
Log Message:
Added language to the book installer tree.

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Msg.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Msg.java	16 Aug 2004 22:08:43 -0000	1.17
--- Msg.java	25 Jan 2005 00:02:32 -0000	1.18
***************
*** 48,51 ****
--- 48,53 ----
      static final Msg OPEN_COMMERCIAL = new Msg("Openness.Commercial"); //$NON-NLS-1$
  
+     static final Msg BOOK_METADATA_SET_OTHER = new Msg("BookMetaDataSet.Other"); //$NON-NLS-1$
+ 
      static final Msg STRONGS_GREEK = new Msg("Strongs.Greek"); //$NON-NLS-1$
      static final Msg STRONGS_HEBREW = new Msg("Strongs.Hebrew"); //$NON-NLS-1$

--- NEW FILE: BookMetaDataSet.java ---
package org.crosswire.jsword.book;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

import org.crosswire.common.util.Filter;
import org.crosswire.common.util.SortedListSet;

/**
 * BookMetaDataSet represents a collection of descriptions about Books
 * which may be subsetted into other BookMetaDataSets.
 * Each set is naturally ordered.
 * 
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 *
 * Distribution Licence:<br />
 * JSword is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.<br />
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.<br />
 * The License is available on the internet
 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA<br />
 * The copyright to this program is held by it's authors.
 * </font></td></tr></table>
 * @see gnu.gpl.Licence
 * @author DM Smith [dmsmith555 at yahoo dot com]
 * @version $Id: BookMetaDataSet.java,v 1.1 2005/01/25 00:02:32 dmsmith Exp $
 */
public class BookMetaDataSet extends SortedListSet
{

    public BookMetaDataSet()
    {
        super();
    }

    public BookMetaDataSet(Collection bmds)
    {
        super(bmds);
    }

    /**
     * Gets the sorted set of all keys which can be used for groupings.
     * These are all the property keys across the BookMetaDatas in this list.
     * @return the set of all keys which can be used for grouping.
     */
    public Set getGroups()
    {
        Set results = new TreeSet();
        Iterator bmdIter = iterator();
        while (bmdIter.hasNext())
        {
            BookMetaData bmd = (BookMetaData) bmdIter.next();
            results.addAll(bmd.getProperties().keySet());
        }
        return results;
    }

    /**
     * Get the sorted set of all values for a particular key.
     * If there is a BookMetaData that does not have a value
     * for that key, then null will be in the set. This can be use
     * to categorize books that don't have that key.
     * For example, "Language" will return all the languages
     * for this BookMetaDataList and null for which the language
     * is unknown.
     * @param key
     * @return the values for a particular key.
     */
    public Set getGroup(String key)
    {
        Set results = new TreeSet();
        Iterator bmdIter = iterator();
        while (bmdIter.hasNext())
        {
            BookMetaData bmd = (BookMetaData) bmdIter.next();
            Object property = bmd.getProperties().get(key);
            String propertyValue = property == null ? Msg.BOOK_METADATA_SET_OTHER.toString() : property.toString();
            results.add(propertyValue);
        }
        return results;
    }

    public BookMetaDataSet filter(String key, String value)
    {
        return (BookMetaDataSet) filter(new GroupFilter(key, value));
    }
    
    private static final class GroupFilter implements Filter
    {
        public GroupFilter(String aKey, String aValue)
        {
            key = aKey;
            value = aValue;
        }

        public boolean test(Object obj)
        {
            BookMetaData bmd = (BookMetaData) obj;
            return bmd.getProperties().get(key) == value;
        }
        private String key;
        private String value;
    }

    /**
     * Serialization ID
     */
    private static final long serialVersionUID = 3258688806185154867L;
}

Index: StudyTool.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/StudyTool.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** StudyTool.java	9 Oct 2004 21:45:05 -0000	1.9
--- StudyTool.java	25 Jan 2005 00:02:32 -0000	1.10
***************
*** 72,80 ****
                      if (trans == null)
                      {
!                         trans = new Translation(word, strongs);
                          reply.put(strongs, trans);
                      }
  
!                     trans.getRef().add(OSISUtil.getVerse(w));
                  }
              }
--- 72,80 ----
                      if (trans == null)
                      {
!                         trans = new Translation(word, strongs, key);
                          reply.put(strongs, trans);
                      }
  
!                     trans.getKey().addAll(OSISUtil.getVerse(w));
                  }
              }
***************
*** 121,129 ****
                      if (trans == null)
                      {
!                         trans = new Translation(translated, number);
                          reply.put(translated, trans);
                      }
  
!                     trans.getRef().add(OSISUtil.getVerse(w));
                  }
              }
--- 121,129 ----
                      if (trans == null)
                      {
!                         trans = new Translation(translated, number, key);
                          reply.put(translated, trans);
                      }
  
!                     trans.getKey().addAll(OSISUtil.getVerse(w));
                  }
              }

Index: Books.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Books.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** Books.java	28 Nov 2004 21:36:46 -0000	1.37
--- Books.java	25 Jan 2005 00:02:32 -0000	1.38
***************
*** 193,197 ****
          books.add(bmd);
  
!         fireBooksChanged(Books.class, bmd, true);
      }
  
--- 193,197 ----
          books.add(bmd);
  
!         fireBooksChanged(instance, bmd, true);
      }
  
***************
*** 210,214 ****
          if (removed)
          {
!             fireBooksChanged(Books.class, bmd, true);
          }
          else
--- 210,214 ----
          if (removed)
          {
!             fireBooksChanged(instance, bmd, true);
          }
          else
***************
*** 412,416 ****
       * So it just acts as a means of commenting out code.
       */
!     private boolean threaded =  false;
  
      /**
--- 412,416 ----
       * So it just acts as a means of commenting out code.
       */
!     private boolean threaded;
  
      /**

Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Msg.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Msg.properties	27 Jun 2004 22:09:14 -0000	1.2
--- Msg.properties	25 Jan 2005 00:02:32 -0000	1.3
***************
*** 25,28 ****
--- 25,30 ----
  Openness.Commercial=Commercial
  
+ BookMetaDataSet.Other=Other
+ 
  Strongs.Greek=Greek:
  Strongs.Hebrew=Hebrew:

Index: BookFilterIterator.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookFilterIterator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** BookFilterIterator.java	8 Sep 2004 19:55:07 -0000	1.5
--- BookFilterIterator.java	25 Jan 2005 00:02:32 -0000	1.6
***************
*** 1,3 ****
- 
  package org.crosswire.jsword.book;
  
--- 1,2 ----
***************
*** 27,30 ****
--- 26,30 ----
   * @see gnu.gpl.Licence
   * @author Joe Walker [joe at eireneh dot com]
+  * @author DM Smith [dmsmith555 at yahoo dot com]
   * @version $Id$
   */
***************
*** 39,58 ****
          this.it = it;
          this.filter = filter;
- 
-         findNext();
      }
  
!     /**
!      * Are there any more?
       * @see java.util.Iterator#hasNext()
       */
      public boolean hasNext()
      {
          return next != null;
      }
  
!     /**
!      * Get the next. Hmmm using finally to avoid creating a temporary local
!      * variable. Just how evil is this?
       * @see java.util.Iterator#next()
       */
--- 39,54 ----
          this.it = it;
          this.filter = filter;
      }
  
!     /* (non-Javadoc)
       * @see java.util.Iterator#hasNext()
       */
      public boolean hasNext()
      {
+         next = findNext();
          return next != null;
      }
  
!     /* (non-Javadoc)
       * @see java.util.Iterator#next()
       */
***************
*** 63,79 ****
              throw new NoSuchElementException();
          }
! 
!         try
!         {
!             return next;
!         }
!         finally
!         {
!             findNext();
!         }
      }
  
!     /**
!      * Can't do this.
       * @see java.util.Iterator#remove()
       */
--- 59,66 ----
              throw new NoSuchElementException();
          }
!         return next;
      }
  
!     /* (non-Javadoc)
       * @see java.util.Iterator#remove()
       */
***************
*** 84,108 ****
  
      /**
!      * Store the next (if there is one)
       */
!     private void findNext()
      {
!         if (filter == null)
!         {
!             next = null;
!             return;
!         }
! 
!         do
          {
!             if (!it.hasNext())
              {
!                 next = null;
!                 return;
              }
- 
-             next = (BookMetaData) it.next();
          }
!         while (!filter.test(next));
      }
  
--- 71,88 ----
  
      /**
!      * Find the next (if there is one)
       */
!     private BookMetaData findNext()
      {
!         while (it.hasNext())
          {
!             BookMetaData bmd = (BookMetaData) it.next();
!             if (filter == null || filter.test(bmd))
              {
!                 return bmd;
              }
          }
! 
!         return null;
      }
  



More information about the jsword-svn mailing list