[jsword-svn] r1037 - in trunk: bibledesktop/.settings
bibledesktop/src/main/java/org/crosswire/bibledesktop/book
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/splitlist
bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab
bibledesktop/src/main/java/org/crosswire/bibledesktop/passage
common/src/main/java/org/crosswire/common/util
common-swing/src/main/java/org/crosswire/common/config/swing
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/thml
jsword/src/main/java/org/crosswire/jsword/book/install/sword
jsword/src/main/java/org/crosswire/jsword/book/readings
jsword/src/main/java/org/crosswire/jsword/passage
jsword-limbo/src/main/java/org/crosswire/common/util
jsword-sword/src/main/java/org/crosswire/sword/keys
jsword-web/src/main/java/org/crosswire/jsword/view/web
dmsmith at crosswire.org
dmsmith at crosswire.org
Sun Mar 5 14:46:21 MST 2006
Author: dmsmith
Date: 2006-03-05 14:45:11 -0700 (Sun, 05 Mar 2006)
New Revision: 1037
Added:
trunk/jsword-limbo/src/main/java/org/crosswire/common/util/SortedListSet.java
Removed:
trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java
Modified:
trunk/bibledesktop/.settings/org.eclipse.jdt.core.prefs
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallManagerComboBoxModel.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallerFactoryComboBoxModel.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/AboutPane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/splitlist/SplitBookDataDisplay.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/config/swing/MapField.java
trunk/common/src/main/java/org/crosswire/common/util/ClassUtil.java
trunk/common/src/main/java/org/crosswire/common/util/CollectionUtil.java
trunk/common/src/main/java/org/crosswire/common/util/Convert.java
trunk/common/src/main/java/org/crosswire/common/util/ReflectionUtil.java
trunk/jsword-sword/src/main/java/org/crosswire/sword/keys/SWKey.java
trunk/jsword-web/src/main/java/org/crosswire/jsword/view/web/DownloadSet.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookFilterIterator.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookList.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.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/DefaultLeafKeyList.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.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/SynchronizedPassage.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java
Log:
Updated to Java 5 generics
Modified: trunk/bibledesktop/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/bibledesktop/.settings/org.eclipse.jdt.core.prefs 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/.settings/org.eclipse.jdt.core.prefs 2006-03-05 21:45:11 UTC (rev 1037)
@@ -1,4 +1,4 @@
-#Thu Mar 02 07:48:36 EST 2006
+#Sat Mar 04 11:18:40 EST 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -56,7 +56,7 @@
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -26,8 +26,8 @@
import org.crosswire.common.swing.CompositeIcon;
import org.crosswire.common.swing.GuiUtil;
+import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookCategory;
-import org.crosswire.jsword.book.BookMetaData;
/**
* Generates the appropriate icon for a book.
@@ -45,7 +45,7 @@
{
}
- public static Icon getIcon(BookMetaData book)
+ public static Icon getIcon(Book book)
{
Icon icon = ICON_OTHER;
BookCategory type = book.getBookCategory();
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -30,7 +30,7 @@
import javax.swing.UIManager;
import javax.swing.border.Border;
-import org.crosswire.jsword.book.BookMetaData;
+import org.crosswire.jsword.book.Book;
/**
* A custom list view that paints icons alongside the words.
@@ -96,9 +96,9 @@
setBorder(focus ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocus); //$NON-NLS-1$
}
- if (value instanceof BookMetaData)
+ if (value instanceof Book)
{
- BookMetaData book = (BookMetaData) value;
+ Book book = (Book) value;
String displayName = book.toString();
setText(displayName);
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksListModel.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -29,6 +29,7 @@
import javax.swing.event.ListDataListener;
import org.crosswire.common.util.Logger;
+import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookFilter;
import org.crosswire.jsword.book.BookList;
import org.crosswire.jsword.book.Books;
@@ -155,7 +156,7 @@
*/
protected final synchronized void cacheData()
{
- books = new ArrayList();
+ books = new ArrayList<Book>();
books.addAll(bookList.getBooks(filter));
Collections.sort(books);
}
@@ -216,7 +217,7 @@
* ensure that one thread can't update the list of books while another is
* trying to create a JList based on this class.
*/
- protected List books;
+ protected List<Book> books;
/**
* The log stream
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-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookNode.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -39,19 +39,19 @@
public class BookNode extends DefaultMutableTreeNode
{
- public BookNode(Object node, BookSet books, Object [] grouping, int level)
+ public BookNode(Object node, BookSet books, int level, Object... grouping)
{
setUserObject(node);
if (level < grouping.length)
{
String key = (String) grouping[level];
Set group = books.getGroup(key);
- Iterator iter = group.iterator();
- while (iter.hasNext())
+ Iterator it = group.iterator();
+ while (it.hasNext())
{
- String value = iter.next().toString();
+ String value = (String) it.next();
BookSet subBooks = books.filter(key, value);
- add(new BookNode(value, subBooks, grouping, level + 1));
+ add(new BookNode(value, subBooks, level + 1, grouping));
}
}
else if (books != null)
@@ -59,7 +59,7 @@
Iterator iter = books.iterator();
while (iter.hasNext())
{
- add(new BookNode(iter.next(), null, grouping, level + 1));
+ add(new BookNode(iter.next(), null, level + 1, grouping));
}
}
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallManagerComboBoxModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallManagerComboBoxModel.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallManagerComboBoxModel.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -134,7 +134,7 @@
/**
* A cache of the names in the Install Manager
*/
- private List names = new ArrayList();
+ private List<String> names = new ArrayList<String>();
/**
* The install manager that we are representing
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallerFactoryComboBoxModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallerFactoryComboBoxModel.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/InstallerFactoryComboBoxModel.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -45,8 +45,8 @@
*/
public InstallerFactoryComboBoxModel(InstallManager imanager)
{
- Set nameset = imanager.getInstallerFactoryNames();
- names = new ArrayList();
+ Set<String> nameset = imanager.getInstallerFactoryNames();
+ names = new ArrayList<String>();
names.addAll(nameset);
Collections.sort(names);
}
@@ -86,7 +86,7 @@
/**
* The list of installer names
*/
- private List names;
+ private List<String> names;
/**
* The currently selected object
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -239,7 +239,7 @@
{
// return new BooksTreeModel(books);
BookSet bmds = new BookSet(books.getBooks());
- TreeNode bookRoot = new BookNode("root", bmds, new Object[] { BookMetaData.KEY_CATEGORY, BookMetaData.KEY_LANGUAGE }, 0); //$NON-NLS-1$
+ TreeNode bookRoot = new BookNode("root", bmds, 0, BookMetaData.KEY_CATEGORY, BookMetaData.KEY_LANGUAGE); //$NON-NLS-1$
return new DefaultTreeModel(bookRoot);
}
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/AboutPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/AboutPane.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/AboutPane.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -48,6 +48,7 @@
import org.crosswire.common.swing.AntiAliasedTextPane;
import org.crosswire.common.swing.GuiUtil;
import org.crosswire.common.swing.MapTableModel;
+import org.crosswire.common.util.CollectionUtil;
/**
* AboutPane is a window that contains various advanced user tools in
@@ -146,7 +147,7 @@
{
// create and add the System Properties tab
JTable tblProps = new JTable();
- MapTableModel mdlProps = new MapTableModel(System.getProperties());
+ MapTableModel mdlProps = new MapTableModel(CollectionUtil.properties2Map(System.getProperties()));
tblProps.setModel(mdlProps);
JScrollPane scrProps = new JScrollPane();
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-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -956,9 +956,9 @@
refreshBooks();
// And the array of allowed osis>html converters
- Map converters = ConverterFactory.getKnownConverters();
- Set keys = converters.keySet();
- String[] names = (String[]) keys.toArray(new String[keys.size()]);
+ Map<String, Class> converters = ConverterFactory.getKnownConverters();
+ Set<String> keys = converters.keySet();
+ String[] names = keys.toArray(new String[keys.size()]);
ChoiceFactory.getDataMap().put(CONV_KEY, names);
// The choice of configurable XSL stylesheets
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/splitlist/SplitBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/splitlist/SplitBookDataDisplay.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/splitlist/SplitBookDataDisplay.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -174,7 +174,7 @@
*/
public synchronized void addKeyChangeListener(KeyChangeListener listener)
{
- List temp = new ArrayList(2);
+ List<KeyChangeListener> temp = new ArrayList<KeyChangeListener>(2);
if (keyChangeListeners != null)
{
@@ -195,7 +195,7 @@
{
if (keyChangeListeners != null && keyChangeListeners.contains(listener))
{
- List temp = new ArrayList();
+ List<KeyChangeListener> temp = new ArrayList<KeyChangeListener>();
temp.addAll(keyChangeListeners);
temp.remove(listener);
@@ -212,7 +212,7 @@
{
for (int i = 0; i < keyChangeListeners.size(); i++)
{
- KeyChangeListener listener = (KeyChangeListener) keyChangeListeners.get(i);
+ KeyChangeListener listener = keyChangeListeners.get(i);
listener.keyChanged(ev);
}
}
@@ -226,7 +226,7 @@
/**
* The listener for KeyChangeEvents
*/
- private transient List keyChangeListeners;
+ private transient List<KeyChangeListener> keyChangeListeners;
/**
* What book are we currently viewing?
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-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/tab/TabbedBookDataDisplay.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -214,7 +214,7 @@
{
// First add to our list of listeners so when we get more event syncs
// we can add this new listener to the new sync
- List temp = new ArrayList();
+ List<URLEventListener> temp = new ArrayList<URLEventListener>();
if (hyperlis == null)
{
temp.add(listener);
@@ -247,7 +247,7 @@
// First remove from the list of listeners
if (hyperlis != null && hyperlis.contains(listener))
{
- List temp = new ArrayList();
+ List<URLEventListener> temp = new ArrayList<URLEventListener>();
temp.addAll(hyperlis);
temp.remove(listener);
hyperlis = temp;
@@ -328,7 +328,7 @@
{
Object o = tabMain.getSelectedComponent();
JScrollPane sp = (JScrollPane) o;
- return (BookDataDisplay) views.get(sp);
+ return views.get(sp);
}
return pnlView;
}
@@ -400,7 +400,7 @@
/**
* A list of all the HyperlinkListeners
*/
- private transient List hyperlis;
+ private transient List<URLEventListener> hyperlis;
/**
* The passage that we are displaying (in one or more tabs)
@@ -435,12 +435,12 @@
/**
* An map of compnents to their views
*/
- private Map views = new HashMap();
+ private Map<Component, BookDataDisplay> views = new HashMap<Component, BookDataDisplay>();
/**
* A list of all the InnerDisplayPanes so we can control listeners
*/
- private List displays = new ArrayList();
+ private List<BookDataDisplay> displays = new ArrayList<BookDataDisplay>();
/**
* Pointer to whichever of the above is currently in use
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-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -144,7 +144,7 @@
private void doBlur(int amount)
{
// Remember what was selected
- List selected = new ArrayList(Arrays.asList(list.getSelectedValues()));
+ List<Object> selected = new ArrayList<Object>(Arrays.asList(list.getSelectedValues()));
// Make sure that key changes are not visible until blur is done.
Key copy = (Key) key.clone();
@@ -334,7 +334,7 @@
*/
public synchronized void addKeyChangeListener(KeyChangeListener listener)
{
- List temp = new ArrayList(2);
+ List<KeyChangeListener> temp = new ArrayList<KeyChangeListener>(2);
if (keyChangeListeners != null)
{
@@ -355,7 +355,7 @@
{
if (keyChangeListeners != null && keyChangeListeners.contains(listener))
{
- List temp = new ArrayList();
+ List<KeyChangeListener> temp = new ArrayList<KeyChangeListener>();
temp.addAll(keyChangeListeners);
temp.remove(listener);
@@ -372,7 +372,7 @@
{
for (int i = 0; i < keyChangeListeners.size(); i++)
{
- KeyChangeListener li = (KeyChangeListener) keyChangeListeners.get(i);
+ KeyChangeListener li = keyChangeListeners.get(i);
li.keyChanged(ev);
}
}
@@ -400,7 +400,7 @@
/**
* The listener for KeyChangeEvents
*/
- private transient List keyChangeListeners;
+ private transient List<KeyChangeListener> keyChangeListeners;
/*
* GUI Components
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-05 12:38:55 UTC (rev 1036)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/RangeListModel.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -49,7 +49,7 @@
public RangeListModel(RestrictionType theRestriction)
{
restrict = theRestriction;
- ranges = new ArrayList();
+ ranges = new ArrayList<VerseRange>();
}
/**
@@ -142,7 +142,7 @@
/**
* The list of ranges in the passage.
*/
- private List ranges;
+ private List<VerseRange> ranges;
/**
* If we are modelling in groups, do we break at chapter/book boundries
Modified: trunk/common/src/main/java/org/crosswire/common/util/ClassUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/ClassUtil.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/common/src/main/java/org/crosswire/common/util/ClassUtil.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -132,7 +132,7 @@
* @param clazz The class or interface to find implementors of.
* @return The list of implementing classes.
*/
- public static Class[] getImplementors(Class clazz)
+ public static Class[] getImplementors(Class<?> clazz)
{
try
{
@@ -143,7 +143,7 @@
try
{
String name = (String) obj;
- Class impl = Class.forName(name);
+ Class<?> impl = Class.forName(name);
if (clazz.isAssignableFrom(impl))
{
matches.add(impl);
@@ -180,7 +180,7 @@
* @param clazz The class or interface to find implementors of.
* @return The map of implementing classes.
*/
- public static Map<String, Class> getImplementorsMap(Class clazz)
+ public static Map<String, Class> getImplementorsMap(Class<?> clazz)
{
Map<String, Class> matches = new HashMap<String, Class>();
@@ -193,7 +193,7 @@
{
String key = (String) obj;
String value = props.getProperty(key);
- Class impl = Class.forName(value);
+ Class<?> impl = Class.forName(value);
if (clazz.isAssignableFrom(impl))
{
matches.put(key, impl);
@@ -232,12 +232,12 @@
* @throws ClassCastException if the read contents are not valid
* @see ClassUtil#getImplementors(Class)
*/
- public static Class getImplementor(Class clazz) throws IOException, ClassNotFoundException, ClassCastException
+ public static Class getImplementor(Class<?> clazz) throws IOException, ClassNotFoundException, ClassCastException
{
Properties props = ResourceUtil.getProperties(clazz);
String name = props.getProperty(DEFAULT);
- Class impl = Class.forName(name);
+ Class<?> impl = Class.forName(name);
if (!clazz.isAssignableFrom(impl))
{
throw new ClassCastException(Msg.NOT_ASSIGNABLE.toString(new Object[] { impl.getName(), clazz.getName() }));
Modified: trunk/common/src/main/java/org/crosswire/common/util/CollectionUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/CollectionUtil.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/common/src/main/java/org/crosswire/common/util/CollectionUtil.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -49,32 +49,32 @@
}
/**
- * Create a List from an Iterator.
+ * Create a List from an Iterable.
* @param it The source of data for the list
* @return List
*/
- public static List createList(Iterator it)
+ public static <T> List<T> createList(Iterable<T> it)
{
- List<Object> reply = new ArrayList<Object>();
- while (it.hasNext())
+ List<T> reply = new ArrayList<T>();
+ for (T t : it)
{
- reply.add(it.next());
+ reply.add(t);
}
return reply;
}
/**
- * Create a Set from an Iterator.
+ * Create a Set from an Iterable.
* @param it The source of data for the list
* @return the created set
*/
- public static Set createSet(Iterator it)
+ public static <T> Set<T> createSet(Iterable<T> it)
{
- Set<Object> reply = new HashSet<Object>();
- while (it.hasNext())
+ Set<T> reply = new HashSet<T>();
+ for (T t : it)
{
- reply.add(it.next());
+ reply.add(t);
}
return reply;
Modified: trunk/common/src/main/java/org/crosswire/common/util/Convert.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/Convert.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/common/src/main/java/org/crosswire/common/util/Convert.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -157,7 +157,7 @@
* @param data the thing to convert
* @return the converted data
*/
- public static Map<String, String> string2Hashtable(String data, Class superclass)
+ public static Map<String, String> string2Hashtable(String data, Class<?> superclass)
{
Map<String, String> commands = new HashMap<String, String>();
@@ -170,7 +170,7 @@
int equ_pos = entry.indexOf('=');
String key = entry.substring(0, equ_pos);
String value = entry.substring(equ_pos + 1);
- Class clazz = Class.forName(value);
+ Class<?> clazz = Class.forName(value);
if (clazz.isAssignableFrom(superclass))
{
Modified: trunk/common/src/main/java/org/crosswire/common/util/ReflectionUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/ReflectionUtil.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/common/src/main/java/org/crosswire/common/util/ReflectionUtil.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -49,7 +49,7 @@
public static Object invoke(Object base, String methodName, Object[] params) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
// Create a Class array describing the params
- Class[] calledTypes = new Class[params.length];
+ Class<?>[] calledTypes = new Class[params.length];
for (int i = 0; i < params.length; i++)
{
calledTypes[i] = params[i].getClass();
@@ -72,7 +72,7 @@
}
// The right number of params
- Class[] testTypes = testMethod.getParameterTypes();
+ Class<?>[] testTypes = testMethod.getParameterTypes();
if (testTypes.length != calledTypes.length)
{
continue;
@@ -107,14 +107,14 @@
String methodName = call.substring(lastDot + 1);
// Create a Class array describing the params
- Class[] calledTypes = new Class[params.length];
+ Class<?>[] calledTypes = new Class[params.length];
for (int i = 0; i < params.length; i++)
{
calledTypes[i] = params[i].getClass();
}
// Reflection
- Class clazz = Class.forName(className);
+ Class<?> clazz = Class.forName(className);
// The bad news is that we can't use something like:
// clazz.getMethod(called_method_name, called_types);
@@ -130,7 +130,7 @@
}
// The right number of params
- Class[] testTypes = testMethod.getParameterTypes();
+ Class<?>[] testTypes = testMethod.getParameterTypes();
if (testTypes.length != calledTypes.length)
{
continue;
Deleted: trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -1,166 +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.common.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Maintains a sorted list of unique objects. It is expected
- * that the objects implement Comparable. Methods that take an index
- * to indicate an insertion point are ignored.
- *
- * @see gnu.lgpl.License for license details.
- * The copyright to this program is held by it's authors.
- * @author DM Smith [dmsmith555 at yahoo dot com]
- */
-public class SortedListSet<E extends Comparable<E>> extends ArrayList<E> implements Set<E>, List<E>
-{
- /**
- * Create an empty SortedListSet of default size.
- */
- public SortedListSet()
- {
- super();
- }
-
- /**
- * Create an empty SortedListSet of the stated capacity
- * @param initialCapacity
- */
- public SortedListSet(int initialCapacity)
- {
- super(initialCapacity);
- }
-
- /**
- * @param c
- */
- public SortedListSet(Collection<? extends E> c)
- {
- this(c.size());
- // Might be better to add all then sort.
- addAll(c);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#add(int, java.lang.Object)
- */
- @Override
- public void add(int index, E element)
- {
- // ignore the requested index
- add(element);
- }
-
- /* (non-Javadoc)
- * @see java.util.Collection#add(java.lang.Object)
- */
- @Override
- public boolean add(E o)
- {
- // Add the item only if it is not in the list.
- // Add it into the list so that it is in sorted order.
- int pos = Collections.binarySearch(this, o);
- if (pos < 0)
- {
- super.add(-pos - 1, o);
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.util.Collection#addAll(java.util.Collection)
- */
- @Override
- public boolean addAll(Collection<? extends E> c)
- {
- // Might be better to add the list to the end
- // and then sort the list.
- // This can be revisited if the list performs badly.
- boolean added = false;
- for (E e : c)
- {
- if (add(e))
- {
- added = true;
- }
- }
- return added;
- }
-
- /* (non-Javadoc)
- * @see java.util.List#addAll(int, java.util.Collection)
- */
- @Override
- public boolean addAll(int index, Collection<? extends E> c)
- {
- // Ignore the index
- return addAll(c);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#set(int, java.lang.Object)
- */
- @Override
- public E set(int index, E element)
- {
- // remove the item at the index (keep it to return it),
- // then insert the item into the sorted list.
- E item = remove(index);
- add(element);
- return item;
- }
-
- /**
- * Get a filtered list set.
- * @param filter The criteria by which to filter.
- * @return a filtered SortedListSet.
- */
- @SuppressWarnings("unchecked")
- public SortedListSet<E> filter(Filter filter)
- {
- // create a copy of the list and
- // remove everything that fails the test.
- SortedListSet<E> listSet = (SortedListSet) clone();
- Iterator iter = listSet.iterator();
- while (iter.hasNext())
- {
- Object obj = iter.next();
- if (!filter.test(obj))
- {
- iter.remove();
- }
- }
- return listSet;
- }
-
- /**
- * Serialization ID
- */
- private static final long serialVersionUID = 3258413945407484212L;
-}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/config/swing/MapField.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/config/swing/MapField.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/common-swing/src/main/java/org/crosswire/common/config/swing/MapField.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -189,7 +189,7 @@
{
try
{
- Class clazz = Class.forName(name);
+ Class<?> clazz = Class.forName(name);
if (!superclass.isAssignableFrom(clazz))
{
@@ -324,7 +324,7 @@
/**
* The class that everything must inherit from
*/
- private Class superclass;
+ private Class<?> superclass;
/**
* Serialization ID
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -21,10 +21,15 @@
*/
package org.crosswire.jsword.book;
+import java.util.Map;
+
import org.crosswire.common.activate.Activatable;
+import org.crosswire.jsword.index.IndexStatus;
+import org.crosswire.jsword.index.IndexStatusListener;
import org.crosswire.jsword.index.search.SearchRequest;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.KeyFactory;
+import org.jdom.Document;
/**
* Book is the most basic store of textual data - It can retrieve data
@@ -35,7 +40,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public interface Book extends Activatable, KeyFactory, BookMetaData
+public interface Book extends Activatable, KeyFactory, Comparable<Book>
{
/**
* Meta-Information: What version of the Bible is this?
@@ -82,4 +87,149 @@
* @throws BookException If anything goes wrong with this method
*/
Key find(String request) throws BookException;
+
+ /**
+ * The name of the book, for example "King James Version" or
+ * "Bible in Basic English" or "Greek".
+ * In general it should be possible to deduce the initials from the name by
+ * removing all the non-capital letters. Although this is only a generalization.
+ * This method should not return null or a blank string.
+ * @return The name of this book
+ */
+ String getName();
+
+ /**
+ * What category of content is this, a Bible or a reference work like a
+ * Dictionary or Commentary.
+ * @return The category of book
+ */
+ BookCategory getBookCategory();
+
+ /**
+ * Accessor for the driver that runs this Book.
+ * Note this method should only be used to delete() Books. Everything else
+ * you should want to do to a Book should be available in other ways.
+ */
+ BookDriver getDriver();
+
+ /**
+ * The language of the book is the common name for the iso639 code.
+ * @return the common name for the language
+ */
+ String getLanguage();
+
+ /**
+ * The initials of this book - how people familiar with this book will know
+ * it, for example "NIV", "KJV".
+ * @return The book's initials
+ */
+ String getInitials();
+
+ /**
+ * Calculated field: Get an OSIS identifier for the OsisText.setOsisIDWork()
+ * and the Work.setOsisWork() methods.
+ * The response will generally be of the form [Bible][Dict..].getInitials
+ * @return The osis id of this book
+ */
+ String getOsisID();
+
+ /**
+ * Calculated field: The full name of the book, for example
+ * The format is "name, (Driver)"
+ * @return The full name of this book
+ */
+ String getFullName();
+
+ /**
+ * Indicate whether this book is supported by JSword.
+ * Since the expectation is that all books are supported,
+ * abstract implementations should return true and let
+ * specific implementations return false if they cannot
+ * support the book.
+ *
+ * @return true if the book is supported
+ */
+ public boolean isSupported();
+
+ /**
+ * Indicate whether this book is enciphered and without a key.
+ * Since the expectation is that most books are unenciphered,
+ * abstract implementations should return false and let
+ * specific implementations return true otherwise.
+ *
+ * @return true if the book is enciphered
+ */
+ public boolean isEnciphered();
+
+ /**
+ * Indicate whether this book is questionable. A book may
+ * be deemed questionable if it's quality or content has not
+ * been confirmed.
+ * Since the expectation is that all books are not questionable,
+ * abstract implementations should return false and let
+ * specific implementations return true if the book is questionable.
+ *
+ * @return true if the book is questionable
+ */
+ public boolean isQuestionable();
+
+ /**
+ * Calculated field: The name of the name, which could be helpful to
+ * distinguish similar Books available through 2 BookDrivers.
+ * @return The driver name
+ */
+ String getDriverName();
+
+ /**
+ * Return the orientation of the language of the Book. If a book contains more than one language,
+ * it refers to the dominate language of the book. This will be used to present
+ * Arabic and Hebrew in their propper orientation.
+ * @return true if the orientation for the dominate language is LeftToRight.
+ */
+ boolean isLeftToRight();
+
+ /**
+ * Return whether the feature is supported by the book.
+ */
+ boolean hasFeature(FeatureType feature);
+
+ /**
+ * Get a list of all the properties available to do with this Book.
+ * The returned Properties will be read-only so any attempts to alter it
+ * will fail.
+ */
+ Map<String, String> getProperties();
+
+ /**
+ * Has anyone generated a search index for this Book?
+ * @see org.crosswire.jsword.index.IndexManager
+ */
+ IndexStatus getIndexStatus();
+
+ /**
+ * This method does not alter the index status, however it is for Indexers
+ * that are responsible for indexing and have changed the status themselves.
+ * @see org.crosswire.jsword.index.IndexManager
+ */
+ void setIndexStatus(IndexStatus status);
+
+ /**
+ * Get an OSIS representation of information concerning this Book.
+ */
+ Document toOSIS();
+
+ /**
+ * Adds a <code>IndexStatusListener</code> to the listener list.
+ * <p>A <code>IndexStatusEvent</code> will get fired in response
+ * to <code>setIndexStatus</code>.
+ * @param li the <code>IndexStatusListener</code> to be added
+ */
+ void addIndexStatusListener(IndexStatusListener li);
+
+ /**
+ * Removes a <code>IndexStatusListener</code> from the listener list.
+ * @param li the <code>IndexStatusListener</code> to be removed
+ */
+ void removeIndexStatusListener(IndexStatusListener li);
+
}
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookFilterIterator.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -32,19 +32,27 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public class BookFilterIterator implements Iterator
+public class BookFilterIterator implements Iterable<Book>, Iterator<Book>
{
/**
* Simple ctor
* @param filter The filter to use, if null, will iterate over all values
*/
- public BookFilterIterator(Iterator it, BookFilter filter)
+ public BookFilterIterator(Iterable<Book> books, BookFilter filter)
{
- this.it = it;
+ this.it = books.iterator();
this.filter = filter;
}
/* (non-Javadoc)
+ * @see java.lang.Iterable#iterator()
+ */
+ public Iterator<Book> iterator()
+ {
+ return this;
+ }
+
+ /* (non-Javadoc)
* @see java.util.Iterator#hasNext()
*/
public boolean hasNext()
@@ -56,7 +64,7 @@
/* (non-Javadoc)
* @see java.util.Iterator#next()
*/
- public Object next()
+ public Book next()
{
if (next == null)
{
@@ -95,13 +103,11 @@
*/
private Book next;
- /**
- * The source of filtered values
- */
private Iterator it;
/**
* The value filter
*/
private BookFilter filter;
+
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookMetaData.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -24,7 +24,6 @@
import java.util.Map;
import org.crosswire.jsword.index.IndexStatus;
-import org.crosswire.jsword.index.IndexStatusListener;
import org.jdom.Document;
/**
@@ -44,7 +43,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public interface BookMetaData extends Comparable
+public interface BookMetaData extends Comparable<BookMetaData>
{
/**
* The name of the book, for example "King James Version" or
@@ -177,20 +176,6 @@
Document toOSIS();
/**
- * Adds a <code>IndexStatusListener</code> to the listener list.
- * <p>A <code>IndexStatusEvent</code> will get fired in response
- * to <code>setIndexStatus</code>.
- * @param li the <code>IndexStatusListener</code> to be added
- */
- void addIndexStatusListener(IndexStatusListener li);
-
- /**
- * Removes a <code>IndexStatusListener</code> from the listener list.
- * @param li the <code>IndexStatusListener</code> to be removed
- */
- void removeIndexStatusListener(IndexStatusListener li);
-
- /**
* The key for the type in the properties map
*/
String KEY_CATEGORY = "Category"; //$NON-NLS-1$
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookSet.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -21,13 +21,15 @@
*/
package org.crosswire.jsword.book;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.crosswire.common.util.Filter;
-import org.crosswire.common.util.SortedListSet;
/**
* BookSet represents a collection of descriptions about Books
@@ -38,17 +40,16 @@
* The copyright to this program is held by it's authors.
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public class BookSet<E extends Comparable<E>> extends SortedListSet<E>
+public class BookSet extends ArrayList<Book> implements List<Book>, Set<Book>
{
-
public BookSet()
{
- super();
- }
+ }
- public BookSet(Collection<? extends E> books)
+ public BookSet(Collection<? extends Book> books)
{
- super(books);
+ this();
+ addAll(books);
}
/**
@@ -59,10 +60,8 @@
public Set<String> getGroups()
{
Set<String> results = new TreeSet<String>();
- Iterator bookIter = iterator();
- while (bookIter.hasNext())
+ for (Book book : this)
{
- Book book = (Book) bookIter.next();
results.addAll(book.getProperties().keySet());
}
return results;
@@ -82,10 +81,8 @@
public Set<String> getGroup(String key)
{
Set<String> results = new TreeSet<String>();
- Iterator bookIter = iterator();
- while (bookIter.hasNext())
+ for (Book book : this)
{
- Book book = (Book) bookIter.next();
Object property = book.getProperties().get(key);
String propertyValue = property == null ? Msg.BOOK_METADATA_SET_OTHER.toString() : property.toString();
results.add(propertyValue);
@@ -93,11 +90,98 @@
return results;
}
- public BookSet<E> filter(String key, String value)
+ public BookSet filter(String key, String value)
{
- return (BookSet) filter(new GroupFilter(key, value));
+ return filter(new GroupFilter(key, value));
}
+ /* (non-Javadoc)
+ * @see java.util.List#add(int, java.lang.Object)
+ */
+ @Override
+ public void add(int index, Book element)
+ {
+ // ignore the requested index
+ add(element);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#add(java.lang.Object)
+ */
+ @Override
+ public boolean add(Book book)
+ {
+ // Add the item only if it is not in the list.
+ // Add it into the list so that it is in sorted order.
+ int pos = Collections.binarySearch(this, book);
+ if (pos < 0)
+ {
+ super.add(-pos - 1, book);
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#addAll(java.util.Collection)
+ */
+ @Override
+ public boolean addAll(Collection<? extends Book> c)
+ {
+ // Might be better to add the list to the end
+ // and then sort the list.
+ // This can be revisited if the list performs badly.
+ boolean added = false;
+ for (Book book : c)
+ {
+ if (add(book))
+ {
+ added = true;
+ }
+ }
+ return added;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#addAll(int, java.util.Collection)
+ */
+ @Override
+ public boolean addAll(int index, Collection<? extends Book> c)
+ {
+ // Ignore the index
+ return addAll(c);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#set(int, java.lang.Object)
+ */
+ @Override
+ public Book set(int index, Book element)
+ {
+ // remove the item at the index (keep it to return it),
+ // then insert the item into the sorted list.
+ Book item = remove(index);
+ add(element);
+ return item;
+ }
+
+ public BookSet filter(Filter filter)
+ {
+ // create a copy of the list and
+ // remove everything that fails the test.
+ BookSet listSet = (BookSet) clone();
+ Iterator iter = listSet.iterator();
+ while (iter.hasNext())
+ {
+ Object obj = iter.next();
+ if (!filter.test(obj))
+ {
+ iter.remove();
+ }
+ }
+ return listSet;
+ }
+
/**
* GroupFilter does the SQL traditional group by.
*/
@@ -122,4 +206,5 @@
* Serialization ID
*/
private static final long serialVersionUID = 3258688806185154867L;
+
}
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -133,7 +133,7 @@
*/
public synchronized List<Book> getBooks(BookFilter filter)
{
- List<Book> temp = CollectionUtil.createList(new BookFilterIterator(getBooks().iterator(), filter));
+ List<Book> temp = CollectionUtil.createList(new BookFilterIterator(getBooks(), filter));
return new BookSet(temp);
}
@@ -241,7 +241,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().iterator(), BookFilters.getBooksByDriver(driver)));
+ Set current = CollectionUtil.createSet(new BookFilterIterator(getBooks(), BookFilters.getBooksByDriver(driver)));
for (int j = 0; j < bookArray.length; j++)
{
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -500,6 +500,7 @@
* the markup stripped out.
* @return The Bible text without markup
*/
+ @SuppressWarnings("unchecked")
public static String getPlainText(Element root)
{
StringBuffer buffer = new StringBuffer();
@@ -564,6 +565,7 @@
}
}
+ @SuppressWarnings("unchecked")
private static String getTextContent(Element ele)
{
StringBuffer buffer = new StringBuffer();
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -21,8 +21,11 @@
*/
package org.crosswire.jsword.book.basic;
+import java.beans.PropertyChangeListener;
import java.util.Map;
+import javax.swing.event.EventListenerList;
+
import org.crosswire.common.activate.Lock;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookCategory;
@@ -31,6 +34,7 @@
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.FeatureType;
import org.crosswire.jsword.index.IndexStatus;
+import org.crosswire.jsword.index.IndexStatusEvent;
import org.crosswire.jsword.index.IndexStatusListener;
import org.crosswire.jsword.index.search.DefaultSearchRequest;
import org.crosswire.jsword.index.search.SearchRequest;
@@ -151,9 +155,11 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#setIndexStatus(org.crosswire.jsword.book.IndexStatus)
*/
- public void setIndexStatus(IndexStatus status)
+ public void setIndexStatus(IndexStatus newStatus)
{
- bmd.setIndexStatus(status);
+ IndexStatus oldStatus = bmd.getIndexStatus();
+ bmd.setIndexStatus(newStatus);
+ firePropertyChange(oldStatus, newStatus);
}
/* (non-Javadoc)
@@ -245,21 +251,63 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#removeIndexStatusListener(org.crosswire.jsword.index.IndexStatusListener)
+ * @see org.crosswire.jsword.book.Book#addIndexStatusListener(org.crosswire.jsword.index.IndexStatusListener)
*/
- public void removeIndexStatusListener(IndexStatusListener li)
+ public void addIndexStatusListener(IndexStatusListener listener)
{
- bmd.removeIndexStatusListener(li);
+ if (listeners == null)
+ {
+ listeners = new EventListenerList();
+ }
+ listeners.add(IndexStatusListener.class, listener);
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#addIndexStatusListener(org.crosswire.jsword.index.IndexStatusListener)
+ * @see org.crosswire.jsword.book.Book#removeIndexStatusListener(org.crosswire.jsword.index.IndexStatusListener)
*/
- public void addIndexStatusListener(IndexStatusListener li)
+ public void removeIndexStatusListener(IndexStatusListener listener)
{
- bmd.addIndexStatusListener(li);
+ if (listeners == null)
+ {
+ return;
+ }
+
+ listeners.remove(IndexStatusListener.class, listener);
}
+ /**
+ * Reports bound property changes.
+ * If <code>oldValue</code> and <code>newValue</code> are not equal and the
+ * <code>PropertyChangeEvent</code> listener list isn't empty,
+ * then fire a <code>PropertyChange</code> event to each listener.
+ * @param oldStatus the old value of the property (as an Object)
+ * @param newStatus the new value of the property (as an Object)
+ */
+ protected void firePropertyChange(IndexStatus oldStatus, IndexStatus newStatus)
+ {
+ if (listeners != null)
+ {
+ if (oldStatus != null && newStatus != null && oldStatus.equals(newStatus))
+ {
+ return;
+ }
+
+ if (listeners != null)
+ {
+ Object[] listenerList = listeners.getListenerList();
+ for (int i = 0; i <= listenerList.length - 2; i += 2)
+ {
+ if (listenerList[i] == PropertyChangeListener.class)
+ {
+ IndexStatusEvent ev = new IndexStatusEvent(this, newStatus);
+ IndexStatusListener li = (IndexStatusListener) listenerList[i + 1];
+ li.statusChanged(ev);
+ }
+ }
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see org.crosswire.jsword.book.BookMetaData#toOSIS()
*/
@@ -308,10 +356,9 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(Book obj)
{
- Book that = (Book) obj;
- return this.bmd.compareTo(that.getBookMetaData());
+ return this.bmd.compareTo(obj.getBookMetaData());
}
/* (non-Javadoc)
@@ -332,4 +379,9 @@
* The meta data for this book
*/
private BookMetaData bmd;
+
+ /**
+ * The list of property change listeners
+ */
+ private transient EventListenerList listeners;
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookList.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookList.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -49,7 +49,7 @@
*/
public List<Book> getBooks(BookFilter filter)
{
- List<Book> temp = CollectionUtil.createList(new BookFilterIterator(getBooks().iterator(), filter));
+ List<Book> temp = CollectionUtil.createList(new BookFilterIterator(getBooks(), filter));
return Collections.unmodifiableList(temp);
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookMetaData.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -21,15 +21,12 @@
*/
package org.crosswire.jsword.book.basic;
-import java.beans.PropertyChangeListener;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import javax.swing.event.EventListenerList;
-
import org.crosswire.common.util.CWClassLoader;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.StringUtil;
@@ -37,8 +34,6 @@
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.FeatureType;
import org.crosswire.jsword.index.IndexStatus;
-import org.crosswire.jsword.index.IndexStatusEvent;
-import org.crosswire.jsword.index.IndexStatusListener;
import org.jdom.Document;
/**
@@ -193,10 +188,8 @@
*/
public void setIndexStatus(IndexStatus newValue)
{
- IndexStatus oldValue = this.indexStatus;
- this.indexStatus = newValue;
+ indexStatus = newValue;
prop.put(KEY_INDEXSTATUS, newValue.name());
- firePropertyChange(oldValue, newValue);
}
/* (non-Javadoc)
@@ -294,13 +287,12 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(BookMetaData obj)
{
- BookMetaData that = (BookMetaData) obj;
- int result = this.getBookCategory().compareTo(that.getBookCategory());
+ int result = this.getBookCategory().compareTo(obj.getBookCategory());
if (result == 0)
{
- result = this.getInitials().compareTo(that.getInitials());
+ result = this.getInitials().compareTo(obj.getInitials());
}
return result;
}
@@ -322,65 +314,7 @@
return displayName;
}
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#addIndexStatusListener(org.crosswire.jsword.index.IndexStatusListener)
- */
- public void addIndexStatusListener(IndexStatusListener listener)
- {
- if (listeners == null)
- {
- listeners = new EventListenerList();
- }
- listeners.add(IndexStatusListener.class, listener);
- }
-
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.BookMetaData#removeIndexStatusListener(org.crosswire.jsword.index.IndexStatusListener)
- */
- public void removeIndexStatusListener(IndexStatusListener listener)
- {
- if (listeners == null)
- {
- return;
- }
-
- listeners.remove(IndexStatusListener.class, listener);
- }
-
/**
- * Reports bound property changes.
- * If <code>oldValue</code> and <code>newValue</code> are not equal and the
- * <code>PropertyChangeEvent</code> listener list isn't empty,
- * then fire a <code>PropertyChange</code> event to each listener.
- * @param oldStatus the old value of the property (as an Object)
- * @param newStatus the new value of the property (as an Object)
- */
- protected void firePropertyChange(IndexStatus oldStatus, IndexStatus newStatus)
- {
- if (listeners != null)
- {
- if (oldStatus != null && newStatus != null && oldStatus.equals(newStatus))
- {
- return;
- }
-
- if (listeners != null)
- {
- Object[] listenerList = listeners.getListenerList();
- for (int i = 0; i <= listenerList.length - 2; i += 2)
- {
- if (listenerList[i] == PropertyChangeListener.class)
- {
- IndexStatusEvent ev = new IndexStatusEvent(this, newStatus);
- IndexStatusListener li = (IndexStatusListener) listenerList[i + 1];
- li.statusChanged(ev);
- }
- }
- }
- }
- }
-
- /**
* The log stream
*/
private static final Logger log = Logger.getLogger(AbstractBookMetaData.class);
@@ -388,11 +322,6 @@
public static final String DEFAULT_LANG_CODE = "en"; //$NON-NLS-1$
private static final String UNKNOWN_LANG_CODE = "und"; //$NON-NLS-1$
- /**
- * The list of property change listeners
- */
- private transient EventListenerList listeners;
-
private static/*final*/ResourceBundle languages;
static
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/SyncTag.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -57,6 +57,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.filter.thml.Tag#processTag(org.jdom.Element, org.xml.sax.Attributes)
*/
+ @SuppressWarnings("unchecked")
@Override
public Element processTag(Element ele, Attributes attrs)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -63,7 +63,7 @@
* @author Joe Walker [joe at eireneh dot com]
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
-public abstract class AbstractSwordInstaller extends AbstractBookList implements Installer
+public abstract class AbstractSwordInstaller extends AbstractBookList implements Installer, Comparable
{
/**
* Utility to download a file from a remote site
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsKey.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -118,7 +118,7 @@
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public int compareTo(Object obj)
+ public int compareTo(Key obj)
{
ReadingsKey that = (ReadingsKey) obj;
return this.date.compareTo(that.date);
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractKeyList.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -152,9 +152,9 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(Key obj)
{
- Key that = (Key) obj;
+ Key that = obj;
Key thisfirst = (Key) this.iterator().next();
Key thatfirst = (Key) that.iterator().next();
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/AbstractPassage.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -68,7 +68,7 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(Key obj)
{
if (!(obj instanceof Passage))
{
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/DefaultLeafKeyList.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -227,7 +227,7 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(Key obj)
{
DefaultLeafKeyList that = (DefaultLeafKeyList) obj;
return name.compareTo(that.name);
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Key.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -34,7 +34,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public interface Key extends Comparable, Cloneable
+public interface Key extends Comparable<Key>, Cloneable
{
/**
* A Human readable version of the Key.
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/PassageTally.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -1028,7 +1028,7 @@
* JDK: Hack to make this work with J2SE 1.1 as well as J2SE 1.2
* This compared 2 Integers
*/
- private static class TalliedVerse implements Comparable
+ private static class TalliedVerse implements Comparable<TalliedVerse>
{
/**
* Convenience ctor to set the public variables
@@ -1044,10 +1044,8 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(TalliedVerse that)
{
- TalliedVerse that = (TalliedVerse) obj;
-
if (that.tally == this.tally)
{
return this.ord - that.ord;
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyKeyList.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -160,7 +160,7 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object o)
+ public int compareTo(Key o)
{
return keys.compareTo(o);
}
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/ReadOnlyPassage.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -423,7 +423,7 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object o)
+ public int compareTo(Key o)
{
return ref.compareTo(o);
}
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/SynchronizedPassage.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -356,7 +356,7 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public synchronized int compareTo(Object o)
+ public synchronized int compareTo(Key o)
{
return ref.compareTo(o);
}
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/Verse.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -58,7 +58,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, Comparable
+public final class Verse implements VerseBase
{
/**
* The default Verse is Genesis 1:1. I didn't want to provide this
@@ -364,7 +364,7 @@
* @param obj The thing to compare against
* @return 1 means he is earlier than me, -1 means he is later ...
*/
- public int compareTo(Object obj)
+ public int compareTo(Key obj)
{
Verse that = null;
if (obj instanceof Verse)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseBase.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -31,7 +31,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public interface VerseBase extends Cloneable, Comparable, Serializable, Key
+public interface VerseBase extends Cloneable, Serializable, Key
{
/**
* Translate the Passage into a human readable string
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-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/VerseRange.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -516,7 +516,7 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(Key obj)
{
// This ensures a ClassCastException without further test
Verse that = null;
Copied: trunk/jsword-limbo/src/main/java/org/crosswire/common/util/SortedListSet.java (from rev 1034, trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java)
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java 2006-03-05 12:36:08 UTC (rev 1034)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/common/util/SortedListSet.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -0,0 +1,166 @@
+/**
+ * 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.common.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Maintains a sorted list of unique objects. It is expected
+ * that the objects implement Comparable. Methods that take an index
+ * to indicate an insertion point are ignored.
+ *
+ * @see gnu.lgpl.License for license details.
+ * The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class SortedListSet<E extends Comparable<E>> extends ArrayList<E> implements Set<E>, List<E>
+{
+ /**
+ * Create an empty SortedListSet of default size.
+ */
+ public SortedListSet()
+ {
+ super();
+ }
+
+ /**
+ * Create an empty SortedListSet of the stated capacity
+ * @param initialCapacity
+ */
+ public SortedListSet(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+
+ /**
+ * @param c
+ */
+ public SortedListSet(Collection<? extends E> c)
+ {
+ this(c.size());
+ // Might be better to add all then sort.
+ addAll(c);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#add(int, java.lang.Object)
+ */
+ @Override
+ public void add(int index, E element)
+ {
+ // ignore the requested index
+ add(element);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#add(java.lang.Object)
+ */
+ @Override
+ public boolean add(E o)
+ {
+ // Add the item only if it is not in the list.
+ // Add it into the list so that it is in sorted order.
+ int pos = Collections.binarySearch(this, o);
+ if (pos < 0)
+ {
+ super.add(-pos - 1, o);
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#addAll(java.util.Collection)
+ */
+ @Override
+ public boolean addAll(Collection<? extends E> c)
+ {
+ // Might be better to add the list to the end
+ // and then sort the list.
+ // This can be revisited if the list performs badly.
+ boolean added = false;
+ for (E e : c)
+ {
+ if (add(e))
+ {
+ added = true;
+ }
+ }
+ return added;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#addAll(int, java.util.Collection)
+ */
+ @Override
+ public boolean addAll(int index, Collection<? extends E> c)
+ {
+ // Ignore the index
+ return addAll(c);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#set(int, java.lang.Object)
+ */
+ @Override
+ public E set(int index, E element)
+ {
+ // remove the item at the index (keep it to return it),
+ // then insert the item into the sorted list.
+ E item = remove(index);
+ add(element);
+ return item;
+ }
+
+ /**
+ * Get a filtered list set.
+ * @param filter The criteria by which to filter.
+ * @return a filtered SortedListSet.
+ */
+ @SuppressWarnings("unchecked")
+ public SortedListSet<E> filter(Filter filter)
+ {
+ // create a copy of the list and
+ // remove everything that fails the test.
+ SortedListSet<E> listSet = (SortedListSet) clone();
+ Iterator iter = listSet.iterator();
+ while (iter.hasNext())
+ {
+ Object obj = iter.next();
+ if (!filter.test(obj))
+ {
+ iter.remove();
+ }
+ }
+ return listSet;
+ }
+
+ /**
+ * Serialization ID
+ */
+ private static final long serialVersionUID = 3258413945407484212L;
+}
Property changes on: trunk/jsword-limbo/src/main/java/org/crosswire/common/util/SortedListSet.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/jsword-sword/src/main/java/org/crosswire/sword/keys/SWKey.java
===================================================================
--- trunk/jsword-sword/src/main/java/org/crosswire/sword/keys/SWKey.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword-sword/src/main/java/org/crosswire/sword/keys/SWKey.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -5,7 +5,7 @@
* SWKey is the basis for all types of keys for indexing into modules
* (e.g. verse, word, place, etc.)
*/
-public class SWKey implements Cloneable, Comparable
+public class SWKey implements Cloneable, Comparable<SWKey>
{
public static final char KEYERR_OUTOFBOUNDS = 1;
public static final char TOP = 1;
@@ -123,11 +123,9 @@
* ENT: ikey - key to compare with this one
* RET: > 0 if this key is greater than compare key < 0
*/
- public int compareTo(Object ikey)
+ public int compareTo(SWKey ikey)
{
- if (ikey instanceof SWKey)
- return toString().compareTo(ikey.toString());
- return -1;
+ return toString().compareTo(ikey.toString());
}
/**
Modified: trunk/jsword-web/src/main/java/org/crosswire/jsword/view/web/DownloadSet.java
===================================================================
--- trunk/jsword-web/src/main/java/org/crosswire/jsword/view/web/DownloadSet.java 2006-03-05 12:38:55 UTC (rev 1036)
+++ trunk/jsword-web/src/main/java/org/crosswire/jsword/view/web/DownloadSet.java 2006-03-05 21:45:11 UTC (rev 1037)
@@ -20,7 +20,7 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public class DownloadSet implements Comparable
+public class DownloadSet implements Comparable<DownloadSet>
{
public static final String BIN_ZIP = "-bin.zip"; //$NON-NLS-1$
public static final String BIN_TGZ = "-bin.tar.gz"; //$NON-NLS-1$
@@ -79,15 +79,8 @@
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public int compareTo(Object obj)
+ public int compareTo(DownloadSet that)
{
- if (!(obj instanceof DownloadSet))
- {
- log.error("Asked to compare to non DownloadSet"); //$NON-NLS-1$
- return 0;
- }
-
- DownloadSet that = (DownloadSet) obj;
if (datesort)
{
try
More information about the jsword-svn
mailing list