public static Vector filterDistinct(Vector tupels, String key) { Vector res = new Vector(); key = key.toLowerCase(); for (int i = 0; i < tupels.size(); i++) { DB_Tupel tupel = (DB_Tupel) tupels.get(i); Object o = tupel.get(key); if (o instanceof String) { String s = (String) o; boolean found = false; for (int j = 0; j < res.size(); j++) { String t = (String) res.get(j); if (s.equalsIgnoreCase(t)) { found = true; break; } } if (!found) res.add(s); } else { if (!res.contains(o)) res.add(o); } } return res; }
/** * Filtert alle Tupel aus, bei denen der Wert, der durch den Schlüssel key bestimmt wird, gleich * value ist */ public static Vector filter(Vector tupels, String key, Object value) { key = key.toLowerCase(); Vector res = new Vector(); for (int i = 0; i < tupels.size(); i++) { DB_Tupel tupel = (DB_Tupel) tupels.get(i); if (tupel.get(key).equals(value)) res.add(tupel); } return res; }