[jsword-svn] r1048 - in trunk:
bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install
bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop
bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab
bibledesktop/src/main/java/org/crosswire/bibledesktop/passage
common/src/main/java/org/crosswire/common/config
common-swing/src/main/java/org/crosswire/common/progress/swing
common-swing/src/main/java/org/crosswire/common/swing
common-swing/src/main/java/org/crosswire/common/swing/desktop
jsword/src/main/java/org/crosswire/jsword/book
jsword/src/main/java/org/crosswire/jsword/book/basic
jsword/src/main/java/org/crosswire/jsword/book/filter
jsword/src/main/java/org/crosswire/jsword/book/filter/gbf
jsword/src/main/java/org/crosswire/jsword/book/filter/osis
jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext
jsword/src/main/java/org/crosswire/jsword/book/filter/thml
jsword/src/main/java/org/crosswire/jsword/book/install
jsword/src/main/java/org/crosswire/jsword/book/sword
jsword/src/main/java/org/crosswire/jsword/index/lucene
jsword/src/main/java/org/crosswire/jsword/passage
jsword/src/test/java jsword/src/test/java/org/crosswire/jsword/book
jsword/src/test/java/org/crosswire/jsword/passage
jsword-limbo/src/main/java/org/crosswire/jsword/book/basic
dmsmith at crosswire.org
dmsmith at crosswire.org
Tue Mar 14 20:34:38 MST 2006
Author: dmsmith
Date: 2006-03-14 20:33:12 -0700 (Tue, 14 Mar 2006)
New Revision: 1048
Removed:
trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/RangeListModel.java
trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/AbstractViewLayout.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java
trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/Viewable.java
trunk/common/src/main/java/org/crosswire/common/config/Config.java
trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookFilterIterator.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookList.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/DefaultBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/Filter.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFFilter.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/osis/OSISFilter.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java
trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.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/BitwisePassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.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/RocketPassage.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/Bench.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java
trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
Log:
Eliminated VerseBase, toVerseArray and verseIterator.
Replaced them with Key and iterator.
Did some more generic work with enhanced for loop and iterators.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -21,11 +21,11 @@
*/
package org.crosswire.bibledesktop.book.install;
-import java.util.Iterator;
import java.util.Set;
import javax.swing.tree.DefaultMutableTreeNode;
+import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookSet;
/**
@@ -45,21 +45,18 @@
if (level < grouping.length)
{
String key = (String) grouping[level];
- Set group = books.getGroup(key);
- Iterator it = group.iterator();
- while (it.hasNext())
+ Set<String> group = books.getGroup(key);
+ for (String value : group)
{
- String value = (String) it.next();
BookSet subBooks = books.filter(key, value);
add(new BookNode(value, subBooks, level + 1, grouping));
}
}
else if (books != null)
{
- Iterator iter = books.iterator();
- while (iter.hasNext())
+ for (Book book : books)
{
- add(new BookNode(iter.next(), null, level + 1, grouping));
+ add(new BookNode(book, null, level + 1, grouping));
}
}
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -27,7 +27,6 @@
import java.awt.FlowLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import java.util.Iterator;
import java.util.Map;
import javax.swing.BorderFactory;
@@ -123,10 +122,9 @@
protected final void addAllInstallers()
{
// Now add panels for book installation sites
- for (Iterator it = installers.keySet().iterator(); it.hasNext(); )
+ for (String name : installers.keySet())
{
- String name = (String) it.next();
- Installer installer = (Installer) installers.get(name);
+ Installer installer = installers.get(name);
SitePane site = new SitePane(installer);
tabMain.add(name, site);
@@ -220,7 +218,7 @@
/**
* The known installers fetched from InstallManager
*/
- private Map installers;
+ private Map<String, Installer> installers;
/**
* The current installer
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -30,7 +30,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -609,11 +608,10 @@
if (protocol.equals(BIBLE_PROTOCOL))
{
// Does a view contain the passage already?
- Iterator iter = views.iterator();
BibleViewPane clearView = null;
- while (iter.hasNext())
+ for (Component comp : views)
{
- BibleViewPane view = (BibleViewPane) iter.next();
+ BibleViewPane view = (BibleViewPane) comp;
if (view.isClear())
{
clearView = view;
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -25,7 +25,6 @@
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.net.URL;
-import java.util.Iterator;
import javax.swing.Action;
import javax.swing.JCheckBoxMenuItem;
@@ -167,10 +166,9 @@
{
boolean ok = false;
- Iterator it = getDesktop().getViews().iterator();
- while (it.hasNext())
+ for (Component comp : getDesktop().getViews())
{
- BibleViewPane view = (BibleViewPane) it.next();
+ BibleViewPane view = (BibleViewPane) comp;
if (view.maySave())
{
ok = true;
@@ -183,12 +181,11 @@
return;
}
- it = getDesktop().getViews().iterator();
- while (it.hasNext())
+ for (Component comp : getDesktop().getViews())
{
try
{
- BibleViewPane view = (BibleViewPane) it.next();
+ BibleViewPane view = (BibleViewPane) comp;
view.save();
}
catch (IOException ex)
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -25,7 +25,6 @@
import java.awt.Component;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -175,9 +174,8 @@
public void refresh()
{
// Now go through all the known tabs and refresh each
- for (Iterator it = displays.iterator(); it.hasNext(); )
+ for (BookDataDisplay bdd : displays)
{
- BookDataDisplay bdd = (BookDataDisplay) it.next();
bdd.refresh();
}
}
@@ -232,9 +230,8 @@
}
// Now go through all the known syncs and add this one in
- for (Iterator it = displays.iterator(); it.hasNext(); )
+ for (BookDataDisplay idp : displays)
{
- BookDataDisplay idp = (BookDataDisplay) it.next();
idp.addURLEventListener(listener);
}
}
@@ -254,9 +251,8 @@
}
// Now remove from all the known syncs
- for (Iterator it = displays.iterator(); it.hasNext(); )
+ for (BookDataDisplay idp : displays)
{
- BookDataDisplay idp = (BookDataDisplay) it.next();
idp.removeURLEventListener(listener);
}
}
@@ -344,9 +340,8 @@
// Add all the known listeners to this new BookDataDisplay
if (hyperlis != null)
{
- for (Iterator it = hyperlis.iterator(); it.hasNext(); )
+ for (URLEventListener li : hyperlis)
{
- URLEventListener li = (URLEventListener) it.next();
display.addURLEventListener(li);
}
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -156,10 +156,9 @@
}
else
{
- Iterator iter = selected.iterator();
- while (iter.hasNext())
+ for (Object obj : selected)
{
- Key k = (Key) iter.next();
+ Key k = (Key) obj;
// Create a copy so the selection can be restored
Key keyCopy = (Key) k.clone();
keyCopy.blur(amount, RestrictionType.getDefaultBlurRestriction());
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/RangeListModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/RangeListModel.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/RangeListModel.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -27,6 +27,7 @@
import javax.swing.AbstractListModel;
+import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.Passage;
import org.crosswire.jsword.passage.RestrictionType;
import org.crosswire.jsword.passage.VerseRange;
@@ -125,11 +126,10 @@
ranges.clear();
if (ref != null)
{
- Iterator iter = ref.rangeIterator(restrict);
+ Iterator<Key> iter = ref.rangeIterator(restrict);
while (iter.hasNext())
{
- VerseRange range = (VerseRange) iter.next();
- ranges.add(range);
+ ranges.add((VerseRange) iter.next());
}
}
}
Modified: trunk/common/src/main/java/org/crosswire/common/config/Config.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/config/Config.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common/src/main/java/org/crosswire/common/config/Config.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -124,10 +124,9 @@
// We are going to assume a DTD has validated the config file and
// just assume that everything is laid out properly.
Element root = xmlconfig.getRootElement();
- Iterator it = root.getChildren().iterator();
- while (it.hasNext())
+ for (Object obj : root.getChildren())
{
- Element element = (Element) it.next();
+ Element element = (Element) obj;
String key = element.getAttributeValue("key"); //$NON-NLS-1$
try
@@ -183,7 +182,7 @@
* The set of Choice Names that we are controlling
* @return An enumeration over the keys
*/
- public Iterator getNames()
+ public Iterator<String> getNames()
{
return keys.iterator();
}
@@ -239,11 +238,8 @@
*/
public void applicationToLocal()
{
- Iterator it = keys.iterator();
- while (it.hasNext())
+ for (String key : keys)
{
- String key = (String) it.next();
-
try
{
Choice model = getChoice(key);
@@ -369,10 +365,9 @@
*/
public void setProperties(Properties prop)
{
- Iterator it = prop.keySet().iterator();
- while (it.hasNext())
+ for (Object obj : prop.keySet())
{
- String key = (String) it.next();
+ String key = (String) obj;
String value = prop.getProperty(key);
if (value != null)
@@ -389,10 +384,8 @@
{
Properties prop = new Properties();
- Iterator it = keys.iterator();
- while (it.hasNext())
+ for (String key : keys)
{
- String key = (String) it.next();
String value = local.getProperty(key);
Choice model = getChoice(key);
Modified: trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common/src/main/java/org/crosswire/common/config/IntOptionsChoice.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -22,7 +22,6 @@
package org.crosswire.common.config;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
@@ -51,11 +50,9 @@
String prefix = option.getAttributeValue("key") + ".alternative."; //$NON-NLS-1$ //$NON-NLS-2$
List<String> list = new ArrayList<String>();
- List alts = option.getChildren("alternative"); //$NON-NLS-1$
- Iterator it = alts.iterator();
- while (it.hasNext())
+ for (Object obj : option.getChildren("alternative")) //$NON-NLS-1$
{
- Element alternative = (Element) it.next();
+ Element alternative = (Element) obj;
int number = Integer.parseInt(alternative.getAttributeValue("number")); //$NON-NLS-1$
String name = configResources.getString(prefix + number);
list.add(number, name);
Modified: trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -31,7 +31,6 @@
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -73,10 +72,9 @@
JobManager.addWorkListener(this);
- Set current = JobManager.getJobs();
- for (Iterator it = current.iterator(); it.hasNext(); )
+ Set<Job> current = JobManager.getJobs();
+ for (Job job : current)
{
- Job job = (Job) it.next();
addJob(job);
}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -30,7 +30,6 @@
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,10 +67,9 @@
JobManager.addWorkListener(this);
- Set current = JobManager.getJobs();
- for (Iterator it = current.iterator(); it.hasNext(); )
+ Set<Job> current = JobManager.getJobs();
+ for (Job job : current)
{
- Job job = (Job) it.next();
addJob(job);
}
}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/MapTableModel.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -22,7 +22,6 @@
package org.crosswire.common.swing;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -72,10 +71,8 @@
list.clear();
if (map != null)
{
- Iterator iter = map.entrySet().iterator();
- while (iter.hasNext())
+ for (Map.Entry me : map.entrySet())
{
- Map.Entry me = (Map.Entry) iter.next();
Object k = me.getKey();
Object v = me.getValue();
if (k == null || v == null)
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/AbstractViewLayout.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/AbstractViewLayout.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/AbstractViewLayout.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -43,7 +43,7 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public abstract class AbstractViewLayout implements Viewable
+public abstract class AbstractViewLayout implements Viewable, Iterable<Component>
{
/**
* This constructor is protected because it only needs to be seen by
@@ -90,11 +90,10 @@
return new ArrayList<Component>(views);
}
- /**
- * Get an iterator of a snapshot of views.
- * @return an iterator over the views.
+ /* (non-Javadoc)
+ * @see java.lang.Iterable#iterator()
*/
- public Iterator iterator()
+ public Iterator<Component> iterator()
{
return getViews().iterator();
}
@@ -112,10 +111,8 @@
}
// Go through the views removing them from the layout
// and adding them to the other
- Iterator it = iterator();
- while (it.hasNext())
+ for (Component view : this)
{
- Component view = (Component) it.next();
forceRemoveView(view);
other.addView(view);
}
@@ -127,10 +124,8 @@
*/
public void closeAll()
{
- Iterator it = iterator();
- while (it.hasNext())
+ for (Component view : this)
{
- Component view = (Component) it.next();
removeView(view);
}
}
@@ -141,10 +136,8 @@
*/
public void closeOthers(Component component)
{
- Iterator it = iterator();
- while (it.hasNext())
+ for (Component view : this)
{
- Component view = (Component) it.next();
if (view != component)
{
removeView(view);
@@ -158,10 +151,8 @@
*/
public void visit(ViewVisitor visitor)
{
- Iterator it = iterator();
- while (it.hasNext())
+ for (Component view : this)
{
- Component view = (Component) it.next();
visitor.visitView(view);
}
}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/ViewManager.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -222,7 +222,7 @@
/* (non-Javadoc)
* @see org.crosswire.common.swing.desktop.Viewable#iterator()
*/
- public Iterator iterator()
+ public Iterator<Component> iterator()
{
return getViewLayout().iterator();
}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/Viewable.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/Viewable.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/desktop/Viewable.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -23,8 +23,6 @@
import java.awt.Component;
import java.util.Collection;
-import java.util.Iterator;
-
import org.crosswire.common.swing.desktop.event.ViewEventListener;
/**
@@ -34,7 +32,7 @@
* The copyright to this program is held by it's authors.
* @author DM Smith [ dmsmith555 at yahoo dot com]
*/
-public interface Viewable
+public interface Viewable extends Iterable<Component>
{
/**
* Add a view to the set.
@@ -53,12 +51,6 @@
Collection<Component> getViews();
/**
- * Get an iterator of a snapshot of views.
- * @return an iterator over the views.
- */
- Iterator iterator();
-
- /**
* Copies all the views from the one layout to the other
* @param other the other layout
*/
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookFilterIterator.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookFilterIterator.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookFilterIterator.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -40,7 +40,7 @@
*/
public BookFilterIterator(Iterable<Book> books, BookFilter filter)
{
- this.it = books.iterator();
+ this.it = books.iterator();
this.filter = filter;
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookList.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookList.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -37,12 +37,12 @@
public interface BookList
{
/**
- * Get an iterator over all the Books of all types.
+ * Get a list of all the Books of all types.
*/
List<Book> getBooks();
/**
- * Get a filtered iterator over all the Books.
+ * Get a filtered list of all the Books.
* @see BookFilters
*/
List<Book> getBooks(BookFilter filter);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -24,7 +24,6 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -241,7 +240,7 @@
// Go through all the books and add all the new ones.
// Remove those that are not known to the driver, but used to be.
Book[] bookArray = driver.getBooks();
- Set current = CollectionUtil.createSet(new BookFilterIterator(getBooks(), BookFilters.getBooksByDriver(driver)));
+ Set<Book> current = CollectionUtil.createSet(new BookFilterIterator(getBooks(), BookFilters.getBooksByDriver(driver)));
for (int j = 0; j < bookArray.length; j++)
{
@@ -261,10 +260,9 @@
// Remove the books from the previous version of the driver
// that are not in this version.
- Iterator iter = current.iterator();
- while (iter.hasNext())
+ for (Book book : current)
{
- removeBook((Book) iter.next());
+ removeBook(book);
}
log.debug("end registering driver: " + driver.getClass().getName()); //$NON-NLS-1$
@@ -300,9 +298,8 @@
public synchronized BookDriver[] getDriversByClass(Class type)
{
List<BookDriver> matches = new ArrayList<BookDriver>();
- for (Iterator it = drivers.iterator(); it.hasNext(); )
+ for (BookDriver driver : drivers)
{
- BookDriver driver = (BookDriver) it.next();
if (driver.getClass() == type)
{
matches.add(driver);
@@ -328,9 +325,8 @@
public synchronized BookDriver[] getWritableDrivers()
{
int i = 0;
- for (Iterator it = drivers.iterator(); it.hasNext(); )
+ for (BookDriver driver : drivers)
{
- BookDriver driver = (BookDriver) it.next();
if (driver.isWritable())
{
i++;
@@ -340,9 +336,8 @@
BookDriver[] reply = new BookDriver[i];
i = 0;
- for (Iterator it = drivers.iterator(); it.hasNext(); )
+ for (BookDriver driver : drivers)
{
- BookDriver driver = (BookDriver) it.next();
if (driver.isWritable())
{
reply[i++] = driver;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/DefaultBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/DefaultBook.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/DefaultBook.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -131,11 +131,8 @@
return;
}
- List bookList = books.getBooks(filter);
- Iterator it = bookList.iterator();
- while (it.hasNext())
+ for (Book aBook : books.getBooks(filter))
{
- Book aBook = (Book) it.next();
if (name.equals(aBook.getFullName()))
{
setDefault(aBook);
@@ -152,12 +149,12 @@
*/
protected void checkReplacement()
{
- List bookList = books.getBooks(filter);
+ List<Book> bookList = books.getBooks(filter);
- Iterator it = bookList.iterator();
+ Iterator<Book> it = bookList.iterator();
if (it.hasNext())
{
- book = (Book) it.next();
+ book = it.next();
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Defaults.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -22,7 +22,6 @@
package org.crosswire.jsword.book;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.crosswire.common.config.ChoiceFactory;
@@ -479,10 +478,8 @@
*/
protected static void checkAllPreferable()
{
- List bmds = Books.installed().getBooks();
- for (Iterator it = bmds.iterator(); it.hasNext(); )
+ for (Book book : Books.installed().getBooks())
{
- Book book = (Book) it.next();
checkPreferable(book);
}
}
@@ -510,12 +507,10 @@
*/
private static String[] getFullNameArray(BookFilter filter)
{
- List<Book> books = Books.installed().getBooks(filter);
List<String> names = new ArrayList<String>();
- for (Iterator it = books.iterator(); it.hasNext(); )
+ for (Book book : Books.installed().getBooks(filter))
{
- Book book = (Book) it.next();
names.add(book.getFullName());
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -508,14 +508,10 @@
Element osisText = root.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
List<Element> divs = osisText.getChildren(OSISUtil.OSIS_ELEMENT_DIV);
- for (Iterator oit = divs.iterator(); oit.hasNext(); )
+ for (Element div : divs)
{
- Element div = (Element) oit.next();
-
- Iterator dit = div.getContent().iterator();
- while (dit.hasNext())
+ for (Object data : div.getContent())
{
- Object data = dit.next();
if (data instanceof Element)
{
Element ele = (Element) data;
@@ -571,9 +567,8 @@
StringBuffer buffer = new StringBuffer();
List<Content> content = ele.getContent();
- for (Iterator it = content.iterator(); it.hasNext(); )
+ for (Content next : content)
{
- Object next = it.next();
recurseElement(next, buffer);
}
@@ -657,10 +652,9 @@
reply.add(start);
}
- Iterator it = start.getContent().iterator();
- while (it.hasNext())
+ for (Object obj : start.getContent())
{
- Element ele = (Element) it.next();
+ Element ele = (Element) obj;
recurseDeepContent(ele, name, reply);
}
}
@@ -695,10 +689,8 @@
// ele is a JDOM Element that might have a getContent() method
try
{
- List content = ele.getContent();
- for (Iterator it = content.iterator(); it.hasNext(); )
+ for (Object sub : ele.getContent())
{
- Object sub = it.next();
recurseElement(sub, buffer);
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/SentenceUtil.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -22,7 +22,6 @@
package org.crosswire.jsword.book;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.crosswire.common.util.StringUtil;
@@ -109,9 +108,9 @@
// Create a String[]
String[] retcode = new String[tokens.size()];
int i = 0;
- for (Iterator it = tokens.iterator(); it.hasNext(); )
+ for (String token : tokens)
{
- retcode[i++] = (String) it.next();
+ retcode[i++] = token;
}
return retcode;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -38,6 +38,7 @@
import org.crosswire.jsword.passage.RestrictionType;
import org.crosswire.jsword.passage.Verse;
import org.crosswire.jsword.passage.VerseRange;
+import org.jdom.Content;
import org.jdom.Element;
/**
@@ -78,16 +79,14 @@
div.addContent(title);
// For all the verses in this range
- Iterator vit = range.verseIterator();
- while (vit.hasNext())
+ for (Key verse : range)
{
- Key verse = (Key) vit.next();
String txt = getText(verse);
// If the verse is empty then we shouldn't add the verse tag
if (txt.length() > 0)
{
- List osisContent = getFilter().toOSIS(verse, txt);
+ List<Content> osisContent = getFilter().toOSIS(verse, txt);
addOSIS(verse, div, osisContent);
}
@@ -110,7 +109,7 @@
* @param div The div element to which the key is being added
* @param osisContent The OSIS representation of the key being added.
*/
- public void addOSIS(Key key, Element div, List osisContent)
+ public void addOSIS(Key key, Element div, List<Content> osisContent)
{
assert key != null;
div.addContent(osisContent);
@@ -143,9 +142,8 @@
Element div = (Element) sit.next();
// For all of the Verses in the section
- for (Iterator vit = div.getContent().iterator(); vit.hasNext(); )
+ for (Object data : div.getContent())
{
- Object data = vit.next();
if (data instanceof Element)
{
Element overse = (Element) data;
@@ -235,10 +233,8 @@
VerseRange range = (VerseRange) rit.next();
// For all the verses in this range
- Iterator vit = range.verseIterator();
- while (vit.hasNext())
+ for (Key verse : range)
{
- Verse verse = (Verse) vit.next();
String txt = getText(verse);
// If the verse is empty then we shouldn't add the verse
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/Filter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/Filter.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/Filter.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -24,6 +24,7 @@
import java.util.List;
import org.crosswire.jsword.passage.Key;
+import org.jdom.Content;
/**
* A generic interface for things that can convert a String into OSIS data.
@@ -40,5 +41,5 @@
* @param plain The encoded text
* @return a List of OSIS Elements
*/
- List toOSIS(Key key, String plain) throws FilterException;
+ List<Content> toOSIS(Key key, String plain) throws FilterException;
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -22,7 +22,6 @@
package org.crosswire.jsword.book.filter;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.crosswire.common.util.ClassUtil;
@@ -107,9 +106,8 @@
public static Filter getFilter(String lookup)
{
Filter reply = null;
- for (Iterator it = filters.keySet().iterator(); it.hasNext(); )
+ for (String key : filters.keySet())
{
- String key = (String) it.next();
if (key.equalsIgnoreCase(lookup))
{
reply = filters.get(key);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFFilter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFFilter.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/gbf/GBFFilter.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -48,7 +48,8 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.filter.Filter#toOSIS(org.crosswire.jsword.book.filter.BookDataListener, java.lang.String)
*/
- public List toOSIS(Key key, String plain) throws FilterException
+ @SuppressWarnings("unchecked")
+ public List<Content> toOSIS(Key key, String plain) throws FilterException
{
DataPolice.setKey(key);
Element ele = OSISUtil.factory().createDiv();
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/osis/OSISFilter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/osis/OSISFilter.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/osis/OSISFilter.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -31,6 +31,7 @@
import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.filter.Filter;
import org.crosswire.jsword.passage.Key;
+import org.jdom.Content;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
@@ -49,7 +50,8 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.filter.Filter#toOSIS(org.crosswire.jsword.book.filter.BookDataListener, java.lang.String)
*/
- public List toOSIS(Key key, String plain)
+ @SuppressWarnings("unchecked")
+ public List<Content> toOSIS(Key key, String plain)
{
DataPolice.setKey(key);
Element ele = null;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/plaintext/PlainTextFilter.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -27,6 +27,7 @@
import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.filter.Filter;
import org.crosswire.jsword.passage.Key;
+import org.jdom.Content;
import org.jdom.Element;
/**
@@ -44,7 +45,8 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.filter.Filter#toOSIS(org.crosswire.jsword.book.filter.BookDataListener, java.lang.String)
*/
- public List toOSIS(Key key, String plain)
+ @SuppressWarnings("unchecked")
+ public List<Content> toOSIS(Key key, String plain)
{
OSISUtil.OSISFactory factory = OSISUtil.factory();
Element ele = factory.createDiv();
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -36,6 +36,7 @@
import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.filter.Filter;
import org.crosswire.jsword.passage.Key;
+import org.jdom.Content;
import org.jdom.Element;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -58,7 +59,8 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.filter.Filter#toOSIS(org.crosswire.jsword.book.filter.BookDataListener, java.lang.String)
*/
- public List toOSIS(Key key, String plain)
+ @SuppressWarnings("unchecked")
+ public List<Content> toOSIS(Key key, String plain)
{
DataPolice.setKey(key);
Element ele = null;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallManager.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -61,9 +61,8 @@
Properties sitemap = ResourceUtil.getProperties(getClass());
factories = ClassUtil.getImplementorsMap(InstallerFactory.class);
- for (Iterator it = sitemap.entrySet().iterator(); it.hasNext(); )
+ for (Map.Entry entry : sitemap.entrySet())
{
- Map.Entry entry = (Map.Entry) it.next();
String installerDefinition = (String) entry.getValue();
try
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntry.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -22,7 +22,6 @@
package org.crosswire.jsword.book.sword;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.crosswire.common.util.Histogram;
@@ -293,12 +292,11 @@
Element listEle = factory.createLG();
valueElement.addContent(listEle);
- Iterator iter = values.iterator();
- while (iter.hasNext())
+ for (String text : values)
{
Element itemEle = factory.createL();
listEle.addContent(itemEle);
- itemEle.addContent(XMLUtil.escape(iter.next().toString()));
+ itemEle.addContent(XMLUtil.escape(text));
}
}
return rowEle;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ConfigEntryTable.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -26,9 +26,9 @@
import java.io.IOException;
import java.io.Reader;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.book.BookCategory;
@@ -101,9 +101,9 @@
/**
* Returns an Enumeration of all the keys found in the config file.
*/
- public Iterator getKeys()
+ public Set<ConfigEntryType> getKeys()
{
- return table.keySet().iterator();
+ return table.keySet();
}
/**
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.book.sword;
-import java.util.Iterator;
import java.util.List;
import org.crosswire.common.activate.Activator;
@@ -32,6 +31,7 @@
import org.crosswire.jsword.book.filter.Filter;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.Verse;
+import org.jdom.Content;
import org.jdom.Element;
/**
@@ -98,17 +98,15 @@
* @see org.crosswire.jsword.book.basic.AbstractPassageBook#addOSIS(org.crosswire.jsword.passage.Key, org.jdom.Element, java.util.List)
*/
@Override
- public void addOSIS(Key key, Element div, List osisContent)
+ public void addOSIS(Key key, Element div, List<Content> osisContent)
{
// See if the text is marked up with verses
// If it is then just add it.
- Iterator iter = osisContent.iterator();
- while (iter.hasNext())
+ for (Content content : osisContent)
{
- Object obj = iter.next();
- if (obj instanceof Element)
+ if (content instanceof Element)
{
- Element ele = (Element) obj;
+ Element ele = (Element) content;
if (ele.getName().equals(OSISUtil.OSIS_ELEMENT_VERSE))
{
super.addOSIS(key, div, osisContent);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookMetaData.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -28,7 +28,6 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -259,9 +258,8 @@
private void buildProperties()
{
// merge entries into properties file
- for (Iterator kit = cet.getKeys(); kit.hasNext(); )
+ for (ConfigEntryType key : cet.getKeys())
{
- ConfigEntryType key = (ConfigEntryType) kit.next();
Object value = cet.getValue(key);
// value is null if the config entry was rejected.
@@ -274,9 +272,9 @@
List list = (List) value;
StringBuffer combined = new StringBuffer();
boolean appendSeparator = false;
- for (Iterator vit = list.iterator(); vit.hasNext(); )
+ for (Object obj : list)
{
- String element = (String) vit.next();
+ String element = (String) obj;
if (appendSeparator)
{
combined.append('\n');
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -23,7 +23,6 @@
import java.text.DecimalFormat;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
@@ -206,9 +205,8 @@
}
// First check for keys that match ignoring case
- for (Iterator it = map.keySet().iterator(); it.hasNext(); )
+ for (String keyName : map.keySet())
{
- String keyName = (String) it.next();
if (keyName.equalsIgnoreCase(text))
{
return map.get(keyName);
@@ -216,9 +214,8 @@
}
// Next keys that start with the given text
- for (Iterator it = map.keySet().iterator(); it.hasNext(); )
+ for (String keyName : map.keySet())
{
- String keyName = (String) it.next();
if (keyName.startsWith(text))
{
return map.get(keyName);
@@ -226,9 +223,8 @@
}
// Next try keys that contain the given text
- for (Iterator it = map.keySet().iterator(); it.hasNext(); )
+ for (String keyName : map.keySet())
{
- String keyName = (String) it.next();
if (keyName.indexOf(text) != -1)
{
return map.get(keyName);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -26,7 +26,6 @@
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.lucene.analysis.Analyzer;
@@ -146,10 +145,9 @@
if (errors.size() > 0)
{
StringBuffer buf = new StringBuffer();
- Iterator iter = errors.iterator();
- while (iter.hasNext())
+ for (Key key : errors)
{
- buf.append(iter.next());
+ buf.append(key);
buf.append('\n');
}
Reporter.informUser(this, Msg.BAD_VERSE, buf);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -45,7 +45,7 @@
*/
public boolean contains(Key key)
{
- for (Key temp : key)
+ for (Key temp : this)
{
if (key.equals(temp))
{
@@ -129,6 +129,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getName(org.crosswire.jsword.passage.Key)
+ */
+ public String getName(Key base)
+ {
+ return getName();
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#getOSISRef()
*/
public String getOsisRef()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -200,6 +200,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getName(org.crosswire.jsword.passage.Key)
+ */
+ public String getName(Key base)
+ {
+ return getName();
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#getOSISName()
*/
public String getOsisRef()
@@ -456,7 +464,7 @@
while (that_it.hasNext())
{
- if (!contains((VerseBase) that_it.next()))
+ if (!contains((Key) that_it.next()))
{
return false;
}
@@ -478,11 +486,9 @@
Passage remainder = (Passage) this.clone();
- Iterator it = iterator();
- while (it.hasNext())
+ for (Key verse : this)
{
i++;
- Verse verse = (Verse) it.next();
if (i > count)
{
@@ -570,7 +576,7 @@
while (that_it.hasNext())
{
// Avoid touching store to make thread safety easier.
- add((VerseBase) that_it.next());
+ add((Key) that_it.next());
}
lowerNormalizeProtection();
@@ -605,7 +611,7 @@
while (that_it.hasNext())
{
// Avoid touching store to make thread safety easier.
- remove((VerseBase) that_it.next());
+ remove((Key) that_it.next());
}
lowerNormalizeProtection();
@@ -627,11 +633,9 @@
raiseNormalizeProtection();
Passage temp = (Passage) this.clone();
- Iterator it = temp.iterator();
- while (it.hasNext())
+ for (Key verse : temp)
{
- Verse verse = (Verse) it.next();
if (!that.contains(verse))
{
remove(verse);
@@ -1096,30 +1100,6 @@
}
/**
- * Convert the Object to an array of Verses. If base is a VerseRange then return a
- * Verse array of the VersesRanges Verses.
- * @param base The Object to be cast
- * @return The Verse array
- * @exception java.lang.ClassCastException If this is not a Verse or a VerseRange
- */
- protected static Verse[] toVerseArray(VerseBase base) throws ClassCastException
- {
- assert base != null;
-
- if (base instanceof VerseRange)
- {
- VerseRange range = (VerseRange) base;
- return range.toVerseArray();
- }
- else if (base instanceof Verse)
- {
- return new Verse[] { (Verse) base };
- }
-
- throw new ClassCastException(Msg.ABSTRACT_CAST.toString());
- }
-
- /**
* Skip over verses that are part of a range
*/
protected static final class VerseRangeIterator implements Iterator<Key>
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -113,7 +113,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#verseIterator()
+ * @see java.lang.Iterable#iterator()
*/
public Iterator<Key> iterator()
{
@@ -132,13 +132,13 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#contains(org.crosswire.jsword.passage.VerseBase)
*/
- public boolean contains(VerseBase obj)
+ @Override
+ public boolean contains(Key obj)
{
- Verse[] verses = toVerseArray(obj);
-
- for (int i = 0; i < verses.length; i++)
+ for (Key key : obj)
{
- if (!store.get(verses[i].getOrdinal()))
+ Verse verse = (Verse) key;
+ if (!store.get(verse.getOrdinal()))
{
return false;
}
@@ -150,44 +150,54 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#add(org.crosswire.jsword.passage.VerseBase)
*/
- public void add(VerseBase obj)
+ public void add(Key obj)
{
optimizeWrites();
- Verse[] verses = toVerseArray(obj);
-
- for (int i = 0; i < verses.length; i++)
+ Verse firstVerse = null;
+ Verse lastVerse = null;
+ for (Key key : obj)
{
- store.set(verses[i].getOrdinal());
+ lastVerse = (Verse) key;
+ if (firstVerse == null)
+ {
+ firstVerse = lastVerse;
+ }
+ store.set(lastVerse.getOrdinal());
}
// we do an extra check here because the cost of calculating the
// params is non-zero and may be wasted
if (suppressEvents == 0)
{
- fireIntervalAdded(this, verses[0], verses[verses.length - 1]);
+ fireIntervalAdded(this, firstVerse, lastVerse);
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#remove(org.crosswire.jsword.passage.VerseBase)
*/
- public void remove(VerseBase obj)
+ public void remove(Key obj)
{
optimizeWrites();
- Verse[] verses = toVerseArray(obj);
-
- for (int i = 0; i < verses.length; i++)
+ Verse firstVerse = null;
+ Verse lastVerse = null;
+ for (Key key : obj)
{
- store.clear(verses[i].getOrdinal());
+ lastVerse = (Verse) key;
+ if (firstVerse == null)
+ {
+ firstVerse = lastVerse;
+ }
+ store.clear(lastVerse.getOrdinal());
}
// we do an extra check here because the cost of calculating the
// params is non-zero and may be wasted
if (suppressEvents == 0)
{
- fireIntervalRemoved(this, verses[0], verses[verses.length - 1]);
+ fireIntervalAdded(this, firstVerse, lastVerse);
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -69,6 +69,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getName(org.crosswire.jsword.passage.Key)
+ */
+ public String getName(Key base)
+ {
+ return getName();
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#getOSISRef()
*/
public String getOsisRef()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -100,7 +100,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#verseIterator()
+ * @see java.lang.Iterable#iterator()
*/
public Iterator<Key> iterator()
{
@@ -128,13 +128,12 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#contains(org.crosswire.jsword.passage.VerseBase)
*/
- public boolean contains(VerseBase obj)
+ @Override
+ public boolean contains(Key obj)
{
- Verse[] verses = toVerseArray(obj);
-
- for (int i = 0; i < verses.length; i++)
+ for (Key key : obj)
{
- if (!store.contains(verses[i]))
+ if (!store.contains(key))
{
return false;
}
@@ -146,44 +145,54 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#add(org.crosswire.jsword.passage.VerseBase)
*/
- public void add(VerseBase obj)
+ public void add(Key obj)
{
optimizeWrites();
- Verse[] verses = toVerseArray(obj);
-
- for (int i = 0; i < verses.length; i++)
+ Verse firstVerse = null;
+ Verse lastVerse = null;
+ for (Key key : obj)
{
- store.add(verses[i]);
+ lastVerse = (Verse) key;
+ if (firstVerse == null)
+ {
+ firstVerse = lastVerse;
+ }
+ store.add(lastVerse);
}
// we do an extra check here because the cost of calculating the
// params is non-zero an may be wasted
if (suppressEvents == 0)
{
- fireIntervalAdded(this, verses[0], verses[verses.length - 1]);
+ fireIntervalAdded(this, firstVerse, lastVerse);
}
}
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#remove(org.crosswire.jsword.passage.VerseBase)
*/
- public void remove(VerseBase obj)
+ public void remove(Key obj)
{
optimizeWrites();
- Verse[] verses = toVerseArray(obj);
-
- for (int i = 0; i < verses.length; i++)
+ Verse firstVerse = null;
+ Verse lastVerse = null;
+ for (Key key : obj)
{
- store.remove(verses[i]);
+ lastVerse = (Verse) key;
+ if (firstVerse == null)
+ {
+ firstVerse = lastVerse;
+ }
+ store.remove(lastVerse);
}
// we do an extra check here because the cost of calculating the
// params is non-zero an may be wasted
if (suppressEvents == 0)
{
- fireIntervalRemoved(this, verses[0], verses[verses.length - 1]);
+ fireIntervalAdded(this, firstVerse, lastVerse);
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.passage;
-import java.util.Iterator;
/**
* A Key is a Key that can contain other Keys.
@@ -45,6 +44,16 @@
String getName();
/**
+ * Translate the Key into a human readable string, with the
+ * assumption that the specified Key has just been output, so if we
+ * are in the same region, we do not need to display the region name, and
+ * so on.
+ * @param base The key to use to cut down unnecessary output.
+ * @return The string representation
+ */
+ String getName(Key base);
+
+ /**
* 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
@@ -99,11 +108,6 @@
boolean contains(Key key);
/**
- * @return an iterator over the elements in this set.
- */
- Iterator<Key> iterator();
-
- /**
* Adds the specified element to this set if it is not already present.
* @param key element to be added to this set.
* @throws NullPointerException if the specified element is null
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Passage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -175,26 +175,26 @@
* @param restrict Do we break ranges over chapters
* @return A list enumerator
*/
- Iterator rangeIterator(RestrictionType restrict);
+ Iterator<Key> rangeIterator(RestrictionType restrict);
/**
* Returns true if this collection contains all the specified Verse
* @param that Verse or VerseRange that may exist in this Passage
* @return true if this collection contains that
*/
- boolean contains(VerseBase that);
+ boolean contains(Key that);
/**
* Add this Verse/VerseRange to this Passage
* @param that The Verses to be removed from this Passage
*/
- void add(VerseBase that);
+ void add(Key that);
/**
* Remove this Verse/VerseRange from this Passage
* @param that The Verses to be removed from this Passage
*/
- void remove(VerseBase that);
+ void remove(Key that);
/**
* Returns true if this Passage contains all of the verses in that Passage
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageKeyFactory.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -326,10 +326,9 @@
index += toBinary(buffer, index, verses, BibleInfo.versesInBible());
// write the verse ordinals in a loop
- Iterator it = ref.iterator();
- while (it.hasNext())
+ for (Key key : ref)
{
- Verse verse = (Verse) it.next();
+ Verse verse = (Verse) key;
int ord = verse.getOrdinal();
index += toBinary(buffer, index, ord, BibleInfo.versesInBible());
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -338,13 +338,13 @@
* @param that The verses to test for
* @return true if all the verses exist in this tally
*/
- public boolean contains(VerseBase that)
+ @Override
+ public boolean contains(Key that)
{
- Verse[] verses = toVerseArray(that);
-
- for (int i = 0; i < verses.length; i++)
+ for (Key key : that)
{
- if (board[verses[i].getOrdinal() - 1] == 0)
+ Verse verse = (Verse) key;
+ if (board[verse.getOrdinal() - 1] == 0)
{
return false;
}
@@ -379,7 +379,7 @@
* Add/Increment this verses in the rankings
* @param that The verses to add/increment
*/
- public void add(VerseBase that)
+ public void add(Key that)
{
optimizeWrites();
@@ -395,7 +395,7 @@
* @param that The verses to add/increment
* @param count The amount to increment by
*/
- public void add(VerseBase that, int count)
+ public void add(Key that, int count)
{
optimizeWrites();
@@ -407,7 +407,7 @@
* Remove/Decrement this verses in the rankings
* @param that The verses to remove/decrement
*/
- public void unAdd(VerseBase that)
+ public void unAdd(Key that)
{
optimizeWrites();
@@ -420,15 +420,14 @@
* their rank to zero.
* @param that The verses to remove/decrement
*/
- public void remove(VerseBase that)
+ public void remove(Key that)
{
optimizeWrites();
- Verse[] verses = toVerseArray(that);
-
- for (int i = 0; i < verses.length; i++)
+ for (Key key : that)
{
- kill(verses[i].getOrdinal());
+ Verse verse = (Verse) key;
+ kill(verse.getOrdinal());
}
fireIntervalRemoved(this, null, null);
@@ -582,10 +581,9 @@
Passage remainder = (Passage) this.clone();
- Iterator it = iterator();
- while (it.hasNext())
+ for (Key key : this)
{
- Verse verse = (Verse) it.next();
+ Verse verse = (Verse) key;
if (i > count)
{
@@ -744,13 +742,12 @@
* @param that The verses to add/increment
* @param tally The amount to increment/decrement by
*/
- private void alterVerseBase(VerseBase that, int tally)
+ private void alterVerseBase(Key that, int tally)
{
- Verse[] verses = toVerseArray(that);
-
- for (int i = 0; i < verses.length; i++)
+ for (Key key : that)
{
- increment(verses[i].getOrdinal(), tally);
+ Verse verse = (Verse) key;
+ increment(verse.getOrdinal(), tally);
}
if (tally > 0)
@@ -1072,17 +1069,16 @@
{
TreeSet<TalliedVerseRange> output = new TreeSet<TalliedVerseRange>();
- Iterator rit = new VerseRangeIterator(vit, RestrictionType.NONE);
+ Iterator<Key> rit = new VerseRangeIterator(vit, RestrictionType.NONE);
while (rit.hasNext())
{
VerseRange range = (VerseRange) rit.next();
// Calculate the maximum rank for a verse
int rank = 0;
- Iterator vit2 = range.verseIterator();
- while (vit2.hasNext())
+ for (Key key : range)
{
- Verse verse = (Verse) vit2.next();
+ Verse verse = (Verse) key;
int temp = board[verse.getOrdinal() - 1];
if (temp > rank)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RangedPassage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -137,7 +137,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#verseIterator()
+ * @see java.lang.Iterable#iterator()
*/
public Iterator<Key> iterator()
{
@@ -170,7 +170,8 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#contains(org.crosswire.jsword.passage.VerseBase)
*/
- public boolean contains(VerseBase obj)
+ @Override
+ public boolean contains(Key obj)
{
// Even for the conatins(VerseRange) case, the simple
// 'return store.contains(that);' will not work because
@@ -196,7 +197,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#add(org.crosswire.jsword.passage.VerseBase)
*/
- public void add(VerseBase obj)
+ public void add(Key obj)
{
optimizeWrites();
@@ -228,7 +229,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#remove(org.crosswire.jsword.passage.VerseBase)
*/
- public void remove(VerseBase obj)
+ public void remove(Key obj)
{
optimizeWrites();
@@ -238,13 +239,12 @@
// This allows us to modify store which iterating through a copy
SortedSet<Key> new_store = new TreeSet<Key>();
new_store.addAll(store);
- Iterator it = new_store.iterator();
// go through all the VerseRanges
- while (it.hasNext())
+ for (Key key : new_store)
{
// if this range touches the range to be removed ...
- VerseRange this_range = (VerseRange) it.next();
+ VerseRange this_range = (VerseRange) key;
if (this_range.overlaps(that_range))
{
// ... remove it and add the remainder
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -142,6 +142,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getName(org.crosswire.jsword.passage.Key)
+ */
+ public String getName(Key base)
+ {
+ return keys.getName(base);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Key#getOSISRef()
*/
public String getOsisRef()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -151,6 +151,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getName(org.crosswire.jsword.passage.Key)
+ */
+ public String getName(Key base)
+ {
+ return ref.getName(base);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#getOSISName()
*/
public String getOsisRef()
@@ -257,23 +265,15 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#rangeIterator(int)
*/
- public Iterator rangeIterator(RestrictionType restrict)
+ public Iterator<Key> rangeIterator(RestrictionType restrict)
{
return ref.rangeIterator(restrict);
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#contains(org.crosswire.jsword.passage.VerseBase)
- */
- public boolean contains(VerseBase that)
- {
- return ref.contains(that);
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#add(org.crosswire.jsword.passage.VerseBase)
*/
- public void add(VerseBase that)
+ public void add(Key that)
{
if (ignore)
{
@@ -286,7 +286,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#remove(org.crosswire.jsword.passage.VerseBase)
*/
- public void remove(VerseBase that)
+ public void remove(Key that)
{
if (ignore)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -135,7 +135,7 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#verseIterator()
+ * @see java.lang.Iterable#iterator()
*/
@Override
public Iterator<Key> iterator()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -135,6 +135,14 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.passage.Key#getName(org.crosswire.jsword.passage.Key)
+ */
+ public synchronized String getName(Key base)
+ {
+ return ref.getName(base);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#getOSISName()
*/
public synchronized String getOsisRef()
@@ -241,23 +249,15 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#rangeIterator(int)
*/
- public synchronized Iterator rangeIterator(RestrictionType restrict)
+ public synchronized Iterator<Key> rangeIterator(RestrictionType restrict)
{
return ref.rangeIterator(restrict);
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.Passage#contains(org.crosswire.jsword.passage.VerseBase)
- */
- public synchronized boolean contains(VerseBase that)
- {
- return ref.contains(that);
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#add(org.crosswire.jsword.passage.VerseBase)
*/
- public synchronized void add(VerseBase that)
+ public synchronized void add(Key that)
{
ref.add(that);
}
@@ -265,7 +265,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#remove(org.crosswire.jsword.passage.VerseBase)
*/
- public synchronized void remove(VerseBase that)
+ public synchronized void remove(Key that)
{
ref.remove(that);
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -27,7 +27,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.crosswire.common.util.EmptyIterator;
import org.crosswire.common.util.Logger;
/**
@@ -58,7 +57,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public final class Verse implements VerseBase
+public final class Verse implements Key
{
/**
* The default Verse is Genesis 1:1. I didn't want to provide this
@@ -191,7 +190,7 @@
* @param base The verse to use to cut down unnecessary output.
* @return The string representation
*/
- public String getName(Verse base)
+ public String getName(Key base)
{
if (base == null)
{
@@ -205,10 +204,11 @@
return originalName;
}
+ Verse verseBase = (Verse) base;
// To cope with thing like Jude 2...
if (BibleInfo.chaptersInBook(book) == 1)
{
- if (base.book != book)
+ if (verseBase.book != book)
{
return BibleInfo.getBookName(book)
+ Verse.VERSE_PREF_DELIM1
@@ -218,7 +218,7 @@
return String.valueOf(verse);
}
- if (base.book != book)
+ if (verseBase.book != book)
{
return BibleInfo.getBookName(book)
+ Verse.VERSE_PREF_DELIM1
@@ -227,7 +227,7 @@
+ verse;
}
- if (base.chapter != chapter)
+ if (verseBase.chapter != chapter)
{
return chapter
+ Verse.VERSE_PREF_DELIM2
@@ -625,18 +625,6 @@
}
/**
- * Enumerate over the verse in this verse!.
- * This may seem silly, however is is very useful to be able to treat
- * Verses and Ranges the same (VerseBase) and this is a common accessor.
- * @return A verse iterator
- * @see org.crosswire.jsword.passage.VerseBase#verseIterator()
- */
- public Iterator verseIterator()
- {
- return new VerseIterator();
- }
-
- /**
* Create a new Verse being the last verse in the current book
* @return The last verse in this book
*/
@@ -928,7 +916,7 @@
*/
public Iterator<Key> iterator()
{
- return new EmptyIterator<Key>();
+ return new VerseIterator();
}
/* (non-Javadoc)
Deleted: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -1,67 +0,0 @@
-/**
- * Distribution License:
- * JSword is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License, version 2.1 as published by
- * the Free Software Foundation. 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 Lesser General Public License for more details.
- *
- * The License is available on the internet at:
- * http://www.gnu.org/copyleft/lgpl.html
- * or by writing to:
- * Free Software Foundation, Inc.
- * 59 Temple Place - Suite 330
- * Boston, MA 02111-1307, USA
- *
- * Copyright: 2005
- * The copyright to this program is held by it's authors.
- *
- * ID: $Id$
- */
-package org.crosswire.jsword.passage;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * The base unit that is collected by a Passage.
- *
- * @see gnu.lgpl.License for license details.
- * The copyright to this program is held by it's authors.
- * @author Joe Walker [joe at eireneh dot com]
- */
-public interface VerseBase extends Cloneable, Serializable, Key
-{
-
- /**
- * Translate the Passage into a human readable string, with the
- * assumption that the specified Verse has just been output, so if we
- * are in the same book, we do not need to display the book name, and
- * so on.
- * @param base The verse to use to cut down unnecessary output.
- * @return The string representation
- */
- String getName(Verse base);
-
- /**
- * Create an array of Verses.
- * See note on verseElements()
- * @return The array of verses that this makes up
- * @see #verseIterator()
- */
- Verse[] toVerseArray();
-
- /**
- * Enumerate over the verses in this object. I remember thinking at some
- * stage that I ought to just use one of toVerseArray() and verseElements()
- * and contemplated removing the other one, but didn't make the change. I
- * suspect the newer (and therefore probably better) implementation is going
- * to be further down the file (i.e. this one), and so toVerseArray should
- * not be used anymore. However I can't remember the reasoning behind it
- * other than the possibility of less Object generation if you are not
- * going to itterate over the whole array.
- * @return A verse iterator
- */
- Iterator verseIterator();
-}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -27,7 +27,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
-import org.crosswire.common.util.EmptyIterator;
import org.crosswire.common.util.Logger;
/**
@@ -43,7 +42,7 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public final class VerseRange implements VerseBase
+public final class VerseRange implements Key
{
/**
* The default VerseRange is a single verse - Genesis 1:1. I didn't
@@ -140,7 +139,7 @@
* @param base A reference to allow things like Gen 1:1,3,5 as an output
* @return A string like 'Gen 1:1-2'
*/
- public String getName(Verse base)
+ public String getName(Key base)
{
if (PassageUtil.isPersistentNaming() && originalName != null)
{
@@ -788,21 +787,12 @@
}
/**
- * Enumerate over the verse in this range
- * @return A verse iterator
- */
- public Iterator<Key> verseIterator()
- {
- return new VerseIterator(this);
- }
-
- /**
* Enumerate the subranges in this range
* @return a range iterator
*/
- public Iterator rangeIterator(RestrictionType restrict)
+ public Iterator<Key> rangeIterator(RestrictionType restrict)
{
- return new AbstractPassage.VerseRangeIterator(verseIterator(), restrict);
+ return new AbstractPassage.VerseRangeIterator(iterator(), restrict);
}
/* (non-Javadoc)
@@ -1080,7 +1070,7 @@
*/
public Iterator<Key> iterator()
{
- return new EmptyIterator<Key>();
+ return new VerseIterator(this);
}
/* (non-Javadoc)
Modified: trunk/jsword/src/test/java/Bench.java
===================================================================
--- trunk/jsword/src/test/java/Bench.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/test/java/Bench.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -1,4 +1,3 @@
-import java.util.Iterator;
import java.util.List;
import org.crosswire.common.util.Reporter;
@@ -77,10 +76,8 @@
private static void versions()
{
System.out.println(" Available versions:"); //$NON-NLS-1$
- List lbmds = Books.installed().getBooks();
- for (Iterator it = lbmds.iterator(); it.hasNext();)
+ for (Book book : Books.installed().getBooks())
{
- Book book = (Book) it.next();
System.out.println(" " + book.getName()); //$NON-NLS-1$
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.book;
-import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
@@ -50,15 +49,15 @@
@Override
protected void setUp() throws Exception
{
- List lbmds = Books.installed().getBooks(BookFilters.getBibles());
+ List<Book> lbmds = Books.installed().getBooks(BookFilters.getBibles());
bibles = new Book[lbmds.size()];
bmds = new BookMetaData[lbmds.size()];
int i = 0;
- for (Iterator it = lbmds.iterator(); it.hasNext();)
+ for (Book book : lbmds)
{
- bibles[i] = (Book) it.next();
- bmds[i] = bibles[i].getBookMetaData();
+ bibles[i] = book;
+ bmds[i] = book.getBookMetaData();
i++;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -607,7 +607,7 @@
public void testVerseElements() throws Exception
{
- Iterator it = gen11_1.verseIterator();
+ Iterator it = gen11_1.iterator();
while (it.hasNext())
{
assertTrue(it.hasNext());
@@ -615,7 +615,7 @@
assertEquals(v, gen11);
assertTrue(!it.hasNext());
}
- it = gen11_2.verseIterator();
+ it = gen11_2.iterator();
while (it.hasNext())
{
assertTrue(it.hasNext());
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java 2006-03-14 13:20:54 UTC (rev 1047)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java 2006-03-15 03:33:12 UTC (rev 1048)
@@ -70,7 +70,7 @@
int percent = -1;
// For every verse in the Bible
- Iterator it = WHOLE.verseIterator();
+ Iterator it = WHOLE.iterator();
while (it.hasNext())
{
// Create a Passage containing that verse alone
More information about the jsword-svn
mailing list