comparison servlet/src/digilib/util/OptionsSet.java @ 557:0885f5ca5b24 digilibPDF

more refactoring and rearranging pdf and image generation works now
author robcast
date Thu, 16 Dec 2010 21:19:11 +0100
parents servlet/src/digilib/servlet/OptionsSet.java@e1094c5ec032
children
comparison
equal deleted inserted replaced
556:5cc180bb0a5c 557:0885f5ca5b24
1 /**
2 *
3 */
4 package digilib.util;
5
6 import java.util.HashSet;
7 import java.util.StringTokenizer;
8
9 /**
10 * @author casties
11 *
12 */
13 @SuppressWarnings("serial")
14 public class OptionsSet extends HashSet<String> {
15
16 protected String optionSep = ",";
17
18 public OptionsSet() {
19 super();
20 }
21
22 /** Constructor with String of options.
23 * @param s
24 */
25 public OptionsSet(String s) {
26 super();
27 parseString(s);
28 }
29
30 /** Adds all options from String to Set.
31 * @param s
32 */
33 public void parseString(String s) {
34 if (s != null) {
35 StringTokenizer i = new StringTokenizer(s, optionSep);
36 while (i.hasMoreTokens()) {
37 String opt = i.nextToken();
38 this.add(opt);
39 }
40 }
41 }
42
43 public boolean hasOption(String opt) {
44 return this.contains(opt);
45 }
46
47 public String toString() {
48 StringBuffer b = new StringBuffer();
49 for (String s: this) {
50 if (b.length() > 0) {
51 b.append(optionSep);
52 }
53 b.append(s);
54 }
55 return b.toString();
56 }
57
58
59 public String getOptionSep() {
60 return optionSep;
61 }
62
63 public void setOptionSep(String optionSep) {
64 this.optionSep = optionSep;
65 }
66
67 }