01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.casetool.patternimplementor;
12:
13: import java.util.ArrayList;
14: import java.util.StringTokenizer;
15:
16: public class MultiString {
17:
18: ArrayList strings;
19:
20: public MultiString() {
21: strings = new ArrayList();
22: }
23:
24: /**
25: * this should parse the 'string' into several strings uses white-spaces,
26: * comma "," and semicolon ";" as delimiter. eg: input: "as, afsiop, poa,
27: * asfs fmio, apom ;aspo" should be parsed to output:["as", "afsiop", "poa",
28: * "asfs", "fmio", "apom", "aspo"]
29: */
30: public static MultiString parse(String string) {
31: MultiString ms = new MultiString();
32: StringTokenizer st = new StringTokenizer(string, " \t\n\r\f,;");
33:
34: while (st.hasMoreTokens()) {
35: String tmp = st.nextToken();
36:
37: if (tmp.length() > 0) {
38: ms.add(tmp);
39: }
40: }
41:
42: return ms;
43: }
44:
45: public String toString() {
46: if (size() <= 0) {
47: return new String();
48: }
49:
50: String retval = new String(get(0));
51:
52: for (int i = 1; i < size(); i++) {
53: retval = retval + ", " + get(i);
54: }
55:
56: return retval;
57: }
58:
59: public int size() {
60: return strings.size();
61: }
62:
63: public void add(String string) {
64: strings.add(string);
65: }
66:
67: public String get(int i) {
68: return (String) strings.get(i);
69: }
70:
71: public void clear() {
72: strings.clear();
73: }
74: }
|