01: /*
02: * Created on Nov 8, 2004
03: */
04: package uk.org.ponder.stringutil;
05:
06: import java.util.HashSet;
07:
08: import uk.org.ponder.util.UniversalRuntimeException;
09:
10: /** A convenience wrapper for a typesafe Set of <code>String</code> objects.
11: * @author Antranig Basman (antranig@caret.cam.ac.uk)
12: */
13: public class StringSet extends HashSet {
14: public void addAll(String[] array) {
15: for (int i = 0; i < array.length; ++i) {
16: add(array[i]);
17: }
18: }
19:
20: public boolean add(Object o) {
21: if (!(o instanceof String)) {
22: throw new UniversalRuntimeException("Object " + o + " of "
23: + o.getClass() + " added to StringSet");
24: }
25: return super.add(o);
26: }
27: }
|