[jsword-svn] r1034 -
trunk/common/src/main/java/org/crosswire/common/util
dmsmith at crosswire.org
dmsmith at crosswire.org
Sun Mar 5 05:36:12 MST 2006
Author: dmsmith
Date: 2006-03-05 05:36:08 -0700 (Sun, 05 Mar 2006)
New Revision: 1034
Modified:
trunk/common/src/main/java/org/crosswire/common/util/CollectionUtil.java
trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java
Log:
Updated to Java 5
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:26:56 UTC (rev 1033)
+++ trunk/common/src/main/java/org/crosswire/common/util/CollectionUtil.java 2006-03-05 12:36:08 UTC (rev 1034)
@@ -21,10 +21,15 @@
*/
package org.crosswire.common.util;
+import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Properties;
import java.util.Set;
/**
@@ -74,4 +79,23 @@
return reply;
}
+
+ public static Map<String, String> properties2Map(Properties prop)
+ {
+ Map<String, String> propMap = new HashMap<String, String>();
+ Iterator it = prop.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ propMap.put((String)entry.getKey(), (String)entry.getValue());
+ }
+ return propMap;
+ }
+
+ public static Map<String, String> properties2Map(URL propUrl) throws IOException
+ {
+ Properties prop = new Properties();
+ prop.load(propUrl.openStream());
+ return properties2Map(prop);
+ }
}
Modified: 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:26:56 UTC (rev 1033)
+++ trunk/common/src/main/java/org/crosswire/common/util/SortedListSet.java 2006-03-05 12:36:08 UTC (rev 1034)
@@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
/**
@@ -36,7 +37,7 @@
* 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>
+public class SortedListSet<E extends Comparable<E>> extends ArrayList<E> implements Set<E>, List<E>
{
/**
* Create an empty SortedListSet of default size.
@@ -140,11 +141,12 @@
* @param filter The criteria by which to filter.
* @return a filtered SortedListSet.
*/
- public SortedListSet filter(Filter filter)
+ @SuppressWarnings("unchecked")
+ public SortedListSet<E> filter(Filter filter)
{
// create a copy of the list and
// remove everything that fails the test.
- SortedListSet listSet = (SortedListSet) clone();
+ SortedListSet<E> listSet = (SortedListSet) clone();
Iterator iter = listSet.iterator();
while (iter.hasNext())
{
More information about the jsword-svn
mailing list