--- /dev/null
+package jalview.util;
+
+import java.util.Vector;
+import java.util.Hashtable;
+
+public class DBRefUtils
+{
+ /**
+ * Utilities for handling DBRef objects and their collections.
+ */
+ public static Vector selectRefs(java.util.Vector dbrefs, String[] sources) {
+ if (dbrefs==null)
+ return null;
+ if (sources==null)
+ return dbrefs;
+ Hashtable srcs = new Hashtable();
+ Vector res=new Vector();
+ for (int i=0; i<sources.length; i++)
+ srcs.put(new String(sources[i]), new Integer(i));
+ for (int i=0, j=dbrefs.size(); i<j; i++)
+ if (dbrefs.get(i) instanceof jalview.datamodel.DBRefEntry) {
+ jalview.datamodel.DBRefEntry entry = (jalview.datamodel.DBRefEntry) dbrefs.get(i);
+ if (srcs.containsKey(entry.getSource()))
+ res.add(entry);
+ }
+ if (res.size()>0)
+ return res;
+ res = null;
+ // there are probable memory leaks in the hashtable!
+ return null;
+ }
+ }